[Haskell-cafe] AMP - how do you motivate this in teaching?

Oleg Grenrus oleg.grenrus at iki.fi
Fri Nov 20 10:02:13 UTC 2015


> On 20 Nov 2015, at 11:31, Erik Hesselink <hesselink at gmail.com> wrote:
> 
> On 20 November 2015 at 02:30, Manuel Gómez <targen at gmail.com> wrote:
>> I haven’t found a helpful example of an Applicative that is not a Monad
>> that is practical for a lesson.
> 
> There's ZipList [0], which depending on the type of audience might be
> doable. There's also Const [1], but that needs a Monoid constraint,
> and since you said you considered ((,) e) as not having an
> Applicative, which it does have with a Monoid constraint, perhaps
> Const isn't suitable to you for that reason. There are more
> interesting examples here [2].
> 
> Erik
> 
> [0] https://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Applicative.html#t:ZipList
> [1] http://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Applicative.html#v:Const
> [2] http://stackoverflow.com/questions/7220436/good-examples-of-not-a-functor-functor-applicative-monad
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

There are also (which I find actually useful):

-  `Concurrently = Concurrently (IO a)` which is Monad only IO effects are commutative. [3]
    - one can argue that Applicative and Monad instances aren’t compatible
- `Errors` [4], which could be specialised to `Either (NonEmpty err) a` and `ap` would gather all errors!
    - and of course `Lift` using which `Errors` is defined.

[3] https://hackage.haskell.org/package/async-2.0.2/docs/Control-Concurrent-Async.html#t:Concurrently <https://hackage.haskell.org/package/async-2.0.2/docs/Control-Concurrent-Async.html#t:Concurrently>
[4] https://hackage.haskell.org/package/transformers-0.4.3.0/docs/Control-Applicative-Lift.html#t:Errors <https://hackage.haskell.org/package/transformers-0.4.3.0/docs/Control-Applicative-Lift.html#t:Errors>

- Oleg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151120/7814cb65/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151120/7814cb65/attachment.sig>


More information about the Haskell-Cafe mailing list