Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 18:49
    neko-kai edited #9614
  • 04:15
    SethTisue edited #1405
  • 04:15

    SethTisue on 2.12.x

    2.12: new Scala SHA (#1405) (compare)

  • 04:15
    SethTisue closed #1405
  • 02:05
    scala-jenkins milestoned #9618
  • 02:05
    eltociear opened #9618
  • May 07 21:50
    neko-kai commented #9605
  • May 07 21:49
    neko-kai commented #9614
  • May 07 18:00
    smarter commented #9605
  • May 07 17:57
    neko-kai commented #9605
  • May 07 17:56
    neko-kai commented #9605
  • May 07 17:56
    neko-kai commented #9605
  • May 07 17:56
    neko-kai commented #9605
  • May 07 17:50
    smarter commented #9605
  • May 07 17:47
    neko-kai commented #9605
  • May 07 17:47
    neko-kai commented #9605
  • May 07 17:46
    neko-kai commented #9605
  • May 07 17:41
    smarter commented #9605
  • May 07 17:41
    smarter commented #9605
  • May 07 17:30
    SethTisue labeled #12391
Otto Chrons
@ochrons
@SystemFw mind explaining "final tagless" while you're on a roll? :)
Fabio Labella
@SystemFw
yep
so, final tagless is a broader term, which is now getting used in a more specific meaning increasingly often
generally speaking final tagless is a technique for encoding DSLs
these days, often it's used to mean "a final tagless encoding of an effectful algebra", like a DB or something
which one are you interested in?
what the term means precisely (final + tagless)
or a primer in the use of it in server side code?

anyway the general idea is simple

trait KVS[F[_]] {
   def put(k: String, v: String): F[Unit]
   def get(k: String): F[Option[String]]
}

F will be replaced by a concrete type like cats.effect.IO, or Kleisli[IO, DbConnection, ?]

that's the gist of it really
Fabio Labella
@SystemFw
(I can give you lots more detail, if you tell me what you care about :) )
@ochrons
Otto Chrons
@ochrons
I have seen "final tagless" getting thrown around, but I have no clue what it means.. like why tag-less? what's the tag?
what would be tagfull? :)
and what are the alternatives to final tagless
Fabio Labella
@SystemFw
ah, ok
I have a longer explanation of that (if you don't mind reading a scroll back)
maybe I can link it to you and you can ask questions ?
it explains what is final vs initial in this context, and why tag-less in the context of a very simple dsl for adding numbers
the gist:
  • in an initial dsl you write a concrete datatype, then you interpret it
  • in a final dsl you write things directly in terms of the functions that will interpret them (I promise the longer explanation is clearer)
when we apply these two philosophies to effects
the initial approach is the Free monad, we create a concrete datatype (Free, basically a tree), then interpret it
Otto Chrons
@ochrons
ok
Fabio Labella
@SystemFw
try reading that link and let me know
Otto Chrons
@ochrons
I did, but since I'm not even familiar with Free it doesn't give much ;)
Fabio Labella
@SystemFw
mm, the examples shouldn't use Free though
anyway I can give you a more in-depth explanation, would you rather it be here or in DM?
dadepo
@dadepo
@SystemFw what about also in a blog post? (that is, if you keep a blog)
Heikki Vesalainen
@hvesalai
@SystemFw here!
Fabio Labella
@SystemFw
oh, here we are again...yeah, I should keep a blog. I have links to gitter explanations to consolidate. Guess how many I have consolidated in blog posts?
Otto Chrons
@ochrons
well, I'm sure there are other people as much in the dark with regards to final tagless, so going through it here wouldn't hurt :)
trepidacious
@trepidacious
@SystemFw That example is definitely easier to iunderstand because it's just addition rather than pulling in free
Fabio Labella
@SystemFw
yep
I'm going to use the same, and expanding it a bit
hopefully I'm not too boring and people are patient
trepidacious
@trepidacious
@ochrons Are you familiar with say State?
Dominic Egger
@GrafBlutwurst
If I had popcorn...
Otto Chrons
@ochrons
@trepidacious sure, I have something like that in my Diode library even ;)
trepidacious
@trepidacious
@ochrons Ok so @SystemFw will do a MUCH better job of explaining this all, but I think I can give some motivation for it
@ochrons But feel free to ignore because TBH I'm also still trying to work this stuff out :)
Otto Chrons
@ochrons
@trepidacious well you might be better positioned to explain it then ;)
Fabio Labella
@SystemFw
let me know if/when you want the firehose to be opened :P
trepidacious
@trepidacious
@ochrons I'll have a go - this is just some examples not the theory at all. If you just use State, any State transition is legal. So if your "user" gives you a State, they can do anything they want, including things you really don't want to permit.
Dominic Egger
@GrafBlutwurst
@SystemFw just make sure to share the aftermath please :D
trepidacious
@trepidacious
@ochrons Say we had a Map[String, Int] store where we are counting something up, and we only want to be able to increment the ints - if you use State then a user can just clear the map if they want to.
Otto Chrons
@ochrons
so to get this straight, final tagless is purely compile time construct?
trepidacious
@trepidacious
@ochrons Free would let you define an ADT for permitted options, which might just have a Increment(key: String). You can use it as any other monad, and accept it from your user, then later you can transform it into State to actually run it. The user has no way to clear the map.
@ochrons So you define what you want to do as an ADT, then later you can interpret that to run it as say a State.
Otto Chrons
@ochrons
gotcha