Free Monad in Scala

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 พ.ย. 2024

ความคิดเห็น • 23

  • @akemegbebu7807
    @akemegbebu7807 2 ปีที่แล้ว +13

    Just discovered this channel... A real jewel.

  • @temoncher
    @temoncher 2 ปีที่แล้ว +5

    Only wrote about 200 lines of Scala in my life, but this channel is brilliant at explaining tough FP concepts. Great work!

  • @dieduch
    @dieduch 2 ปีที่แล้ว +3

    Fantastic video, great work explaining free monads!

  • @davidcrosson
    @davidcrosson 2 ปีที่แล้ว +3

    thank you very much, I've learned a lot of thing, in particular the ~> trick !

  • @indianbullet
    @indianbullet 2 ปีที่แล้ว +3

    This was great, thanks! I would love to see a comparison of free monads vs tagless final. It seems like they both claim to achieve a similar goal, but it's not clear to me what the advantages of one approach over the other are.

  • @DavidePavan
    @DavidePavan 2 ปีที่แล้ว +2

    Amazing!

  • @eliasavelino6729
    @eliasavelino6729 2 ปีที่แล้ว

    This is so satisfying to watch even though I understand maybe 15% of it, but is this like the Repository Pattern in OOP? Interface the API, and swap with different implementations

    • @rockthejvm
      @rockthejvm  2 ปีที่แล้ว

      Most design patterns are different versions of programming to an interface, then swap implementations.

  • @leorandomnickname
    @leorandomnickname 2 ปีที่แล้ว +1

    so FreeMonads allow you to use natural transformations to change the interpretation, but I still dont get why you cant do that with normal Monads, I guess the fact that the FreeMonad kind of fixes the wrapped type A as a type parameter has to do with it. Thanks for this video, really cool.

  • @fractionstaughttherightway5164
    @fractionstaughttherightway5164 ปีที่แล้ว +1

    I’ll ask one question more. The create/get/create/delete sequence in myLittleProgram has already been executed by the time foldMap is called on myLittleProgram, so a Flatmap’s f must reference lambdas different from those implicit in the myLittleProgram for comprehension. Obviously, this sequence can be executed only once. So what ARE the Flatmap f’s that are called by FoldMap? I’m totally confused!

    • @rockthejvm
      @rockthejvm  ปีที่แล้ว +1

      The CRUD actions are not executed, but merely _described_ by those Free instances. What you get is a "big" data structure, nothing more. When you call foldMap, the natural transformation's functions kick in (those from dbOps2IO).

  • @thegioveZ
    @thegioveZ 2 ปีที่แล้ว

    Very nice video! Tangential question: what theme are you using? :)

  • @Voltra_
    @Voltra_ 2 ปีที่แล้ว +1

    So free monads, given that "programs" are just monadic descriptions of the execution flow, can be used to independently execute and log stuff. Interesting.

  • @fractionstaughttherightway5164
    @fractionstaughttherightway5164 ปีที่แล้ว

    Very elegant code! Some questions: It looks like the execution of myLittleProgram results in a Flatmap(Suspend(ms), f) Free monad for each line, but I don’t see how they are tied together in a single Free monad for the subsequent foldMap to interpret. Further, a Flatmap’s f would encompass all the computations after it in myLittleProgram, so it would seem that a Flatmap’s f would encompass some of the computations of the previous Flatmap f’s, resulting in a repeat of these computations when myLittleProgram is foldMapped. Finally, the get() in myLittleProgram would not produce a result “name”when it’s flatmapped because myLittleProgam has no database to work with when the for comprehension is executed. How does this work?
    Too many questions? They might not even make sense. A Free monad Part 2 that showed the data structures created during execution would do a lot to explain all that’s going on. Thanks!

    • @rockthejvm
      @rockthejvm  ปีที่แล้ว

      unable to untangle the question :(

  • @mouadmuslim
    @mouadmuslim 2 ปีที่แล้ว +2

    kind of advance subject for me, i'll get back later !

  • @Neskeip
    @Neskeip 2 ปีที่แล้ว

    In the for comprehension (15:10), Don't you should return "pure( () ) " instead of ()? I mean, I think that you are getting advantage about Unit type

    • @rockthejvm
      @rockthejvm  2 ปีที่แล้ว

      We're using IO.create, and in the block we need to return a value, not another monad.

  • @scalapie
    @scalapie 2 ปีที่แล้ว

    hi,Daniel. I want to buy your course on your website, but I find that all of the videos do not have subtitles. I am from a country not using English as mother tongue, so it maybe not that easy for me to understand each word you are saying. Is there any way that I can add subtitles to the courses like on youtube? Thanks.

    • @rockthejvm
      @rockthejvm  2 ปีที่แล้ว

      Sadly the Rock the JVM website is not as advanced as TH-cam to add automated captions :(

    • @scalapie
      @scalapie 2 ปีที่แล้ว

      @@rockthejvm OK thanks for your reply. I'd like to buy a bundle on the Black Friday 2022, will be there any promotion? Or maybe I will buy a monthly membership to have a try first. Thank you anyway.