0

I understand applicative vs monad style of programming, but most articles discuss this distinction with "simple" monads like Maybe.

But what about monads like Reader, Writer and State. Are there pracrical examples of using them in applicative way?

dmzkrsk
  • 2,011
  • 2
  • 20
  • 30
  • 1
    Arbitrary example: the applicative instance of `State` can be used to [implement `mapAccumL`](http://stackoverflow.com/a/41523456/2751851). – duplode Jan 18 '17 at 17:10

1 Answers1

3

Every time you use the foo <$> bar <*> baz idom with monadic functions bar and baz, you are using a Monad in an applicative way. This is not a very deep use of Applicative, but rather a convenient way of writing a bit of code, and independent of the Monad – and hence you will find this style also for Reader, Writer and State.

Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139