Haskell For Dilettantes 15: Applicative

Поділитися
Вставка
  • Опубліковано 12 січ 2025

КОМЕНТАРІ • 8

  • @kenchang29
    @kenchang29 2 місяці тому +1

    Appropriate for Halloween! But what really scares me about Haskell isn't the scary syntax, ghastly features, and Lovecraftian cosmic horror terminology; it's that it has somehow become the epitome of functional programming when bash pipelines are the functional mode that people use more than any other and people don't even realize it.

  • @mattshu
    @mattshu 2 місяці тому

    Man you have the perfect voice. Like if you did audiobooks, chef kiss

    • @TeaLeavesProgramming
      @TeaLeavesProgramming  2 місяці тому

      Thank you so much for the compliment! Maybe some day if I need a second career…

  • @amadeus143221
    @amadeus143221 2 місяці тому +2

    ExactlyOne would be called the Identity functor. It is used when you need a functor, but all you want is a trivial one (like a no-op, or a passthrough).

    • @jenreiss3107
      @jenreiss3107 2 місяці тому

      in monad transformer stacks, we use the Identity functor for the base of an otherwise pure stack -- transformers require their inner monad to be a monad in itself, and Identity allows us to lift a pure value into a monadic context without removing its pure semantics.
      An example might be `ExceptT ApplicationError (StateT ApplicationState (Identity a))` for a pure computation, that can throw some Application Error, and has some state ApplicationState. Granted `StateT s (Identity a)` is just a synonym for `State s a`, but the former allows you to abstract over the type of state monad you use (Lazy, Strict, etc.)

    • @Instr
      @Instr 2 місяці тому

      Strictly, it's Solo, not Identity, since Identity is defined as a newtype (which improves performance but changes its laziness behavior).
      Identity is used to provide a dummy monadic type for monad transformers (types that take a monadic type and apply another monadic type over it, combining their characteristics)

  • @amadeus143221
    @amadeus143221 2 місяці тому

    The thing that I think might be missing here is the notion that Applicative is a generalization of fmap from functions of 1 argument to functions of zero (pure) or more (, using currying) arguments. There is a good overview on this perspective from Graham Hutton: ua-cam.com/video/8oVHISjS3wI/v-deo.htmlsi=ovW6JvN5XJ294SY0

    • @TeaLeavesProgramming
      @TeaLeavesProgramming  2 місяці тому

      This is an interesting way to think about it, and one I had not considered.