Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 18 19:35
    @SethTisue banned @lunaterra22
  • Sep 14 18:08
    @SethTisue banned @discjock:matrix.org
  • Sep 12 20:37
    @SethTisue banned @manuelzamoratetherbtcusa:matrix.org
  • Sep 06 14:29
    @SethTisue banned @white_hat_hacker:minds.com
  • Sep 06 14:29
    @SethTisue banned @alexchole:matrix.org
  • Aug 31 17:03
    @SethTisue banned @andersonwatts7:matrix.org
  • Jul 19 20:37
    @SethTisue banned @tonyobanon
  • Jan 02 23:58
    @SethTisue banned @fakubishes:nerdsin.space
  • Dec 15 2021 05:01
    som-snytt commented #12516
  • Dec 15 2021 04:38
    SethTisue edited #1312
  • Dec 15 2021 04:38
    SethTisue opened #2273
  • Dec 15 2021 04:31
    jackkoenig opened #12516
  • Dec 15 2021 04:29
    SethTisue edited #1312
  • Dec 15 2021 04:28
    SethTisue edited #1312
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    scala-jenkins milestoned #9831
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    SethTisue opened #9831
  • Dec 15 2021 03:35
    som-snytt commented #11339
  • Dec 15 2021 03:27
    som-snytt labeled #12494
Ghost
@ghost~5c2a2354d73408ce4fb3431e
I'd love to see a counter example to this!
Matthew de Detrich
@mdedetrich
Sure I was just saying why it was hot stuff at that time in Haskell
Li Haoyi
@lihaoyi
yeah i dunno why “finally tagless” is a thing
it’s just a type parameter
Fabio Labella
@SystemFw
MonadError is a final tagless effect
Ghost
@ghost~5c2a2354d73408ce4fb3431e
@SystemFw ok, let's be more precise about what our words mean. What do you call something like MyDbAlgebra?
the general name
algebra?
then I rephrase: MonadError cannot be refactored as an algebra, because it has F[_] in contravariant position (and the algebra could not have an FFunctor, or FunctorK as cats calls it)
Fabio Labella
@SystemFw
@lihaoyi it's a type parameter plus the idea of encoding languages as their interpreters. The business logic application of it is quite simple. In the context of DSLs more in general, there's more to that like optimisations and parsing. But even the basic idea looks simple, but papers discovering were very innovative. Hindsight is 20/20: the expression problem and having typed languages with no tags or GADTs were not solved problems before. It's so innovative that an OO paper that basically rediscovered the same thing (and named it object algebras), won a best paper award (Extensibility for the masses)
Gunnar Lilleaasen
@heksesang
@lihaoyi When using sourcecode in Dotty, should I import it with Dotty compatibility, or is there a published “native” version for Dotty?
Ghost
@ghost~5c2a2354d73408ce4fb3431e
contrast to something like MonadReader or MonadState which can be encoded as an algebra, because F[_] only appears in covariant position.
Fabio Labella
@SystemFw
by algebra do you mean a datatype?
Ghost
@ghost~5c2a2354d73408ce4fb3431e
@lihaoyi I'm with you on this... it's just "using higher kinded types" but with a really fancy name.
Fabio Labella
@SystemFw
you can do final tagless in many applications with no higher kinds at all
e.g. I just had a use case for a BigQuery DSL which translates to json directly
Ghost
@ghost~5c2a2354d73408ce4fb3431e
@SystemFw in scala it would be a trait that would be abstracted over F[_]
I loathe to call that a data type
Fabio Labella
@SystemFw
ok then
I would agree that is an algebra
Dennis van der Bij
@DennisVDB
@fommil Ah true, didn't think of that. The more precise question: is there any loop fusion happening on anything from the stdlib? My works codebase uses Seq. I'm looking into mostly using directly List but I'm scared that it could make matters worse as it doesn't fuse and some of the collections hidden behind some of the Seq might do it.
Fabio Labella
@SystemFw
in which case MonadError is a final tagless algebra

the ideas behind final tagless are two:

  • An algebra is represented in terms of its eliminators == a language is represented as its interpreter == you encode things using functions.
  • the result is expressed as a type param.

This is a genius idea, not trivial at all, and the technique definitely deserves a name, especially when you take it in its entirety (e.g. do parsing or optimisations on final tagless languages)

Ghost
@ghost~5c2a2354d73408ce4fb3431e
sure, but so is any typeclass. In Haskell nobody ever talks about final tagless. It was a curious paper, with no real implications on how peple were already doing MTL
Fabio Labella
@SystemFw
what
MTL didn't even exist
it was influenced by that paper
also if you look into the DSL space then you'll find that final tagless is definitely talked about
it's also not specific to typeclasses
Ghost
@ghost~5c2a2354d73408ce4fb3431e
sorry, I spoke historically, I mean in the present "nobody in Haskell talks about final tagless today"
Fabio Labella
@SystemFw
you can encode the same idea with records of functions or ML modules, or java interfaces
well, there is a whole bunch of libraries that tries to improve on mtl
that is basically researching final tagless problems
like, a lot of libraries and different approaches
e.g MonadLayers,monad-control, and so on
Ghost
@ghost~5c2a2354d73408ce4fb3431e
I haven't hit any problems with mtl yet, so I've had no need to use anything more advanced ¯\_(ツ)_/¯
Matthew de Detrich
@mdedetrich
I also have a suspicion that in the past (moreso around 10 years ago) people in Haskell weren't dealing with the problems that tagless/free primarily solved
Fabio Labella
@SystemFw
write a library, and see how many instances of other libs you need to provide (and how many deps you therefore need to import to avoid orphans) :)
this is why lens pulls in the whole world
Ghost
@ghost~5c2a2354d73408ce4fb3431e
@SystemFw monad-control looks like it's just another mtl typeclass, what am I missing?
Matthew de Detrich
@mdedetrich
(or that Haskell people simply didn't care that much)
Ghost
@ghost~5c2a2354d73408ce4fb3431e
or do you mean mtl in the strictest sense of being the mtl library... not "mtl style"
Fabio Labella
@SystemFw
yes, the mtl library
anything that goes beyond that is basically trying to solve final tagless problems
Ghost
@ghost~5c2a2354d73408ce4fb3431e
right, well sure... I consider "mtl style" to be more general. there are a few extensions to the base lib.
Fabio Labella
@SystemFw

I consider "mtl style" to be more general.

yeah, so I think we agree that "this thing" needs a name cause there are different things to talk about ;)

Ghost
@ghost~5c2a2354d73408ce4fb3431e
one thing Haskell is missing is a decent FFunctor library and TH generator
it's not a terrible about of work to write an FFunctor for an algebra, but it'd be nice to have something like @autoFunctorK
Fabio Labella
@SystemFw
this is also another interesting article about a final tagless encoding for effects which disagrees with MTL https://www.tweag.io/posts/2018-10-04-capability.html