Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 18 2022 19:35
    @SethTisue banned @lunaterra22
  • Sep 14 2022 18:08
    @SethTisue banned @discjock:matrix.org
  • Sep 12 2022 20:37
    @SethTisue banned @manuelzamoratetherbtcusa:matrix.org
  • Sep 06 2022 14:29
    @SethTisue banned @white_hat_hacker:minds.com
  • Sep 06 2022 14:29
    @SethTisue banned @alexchole:matrix.org
  • Aug 31 2022 17:03
    @SethTisue banned @andersonwatts7:matrix.org
  • Jul 19 2022 20:37
    @SethTisue banned @tonyobanon
  • Jan 02 2022 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
Fabio Labella
@SystemFw
I have some hypotheses
first: the initial view was that you should use things like MonadState and MonadReader, as opposed to MyDbAlg and MyHttpAlg
this is an evolution that happened in Haskell as well, although direct use of mtl typeclasses is still common
Ghost
@ghost~5c2a2354d73408ce4fb3431e
because everybody was excited about Freer in Haskell when people were interested in FP in Scala? :laughing:
Fabio Labella
@SystemFw
when you use MonadState and MonadReader, things don't work
remember that this is way before scato
Matthew de Detrich
@mdedetrich
iirc, Free solved some issues when it came to the expression problem
Fabio Labella
@SystemFw
so ambiguous implicits kill you
@mdedetrich not on its own. Final tagless solves that natively. Free needs additional machinery in the form of Coproduct injection (Data types a la carte). It's a way clunkier solution than final tagless for that)
Ghost
@ghost~5c2a2354d73408ce4fb3431e
some monads cannot be expressed as effects / algebras / whatever people call them in scala. Notably, anything with the F[_] in contravariant position
e.g. MonadError cannot be refactored as a final tagless effect
Fabio Labella
@SystemFw
untrue
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) :)