You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm under the impression that these are both valid applicative instances (I think the second one is essentially the ZipList applicative instance, but I'm not actually sure).
If so, it might be useful to somehow alert the students that, while the second instance is valid, they should search for an entirely different instance (and not stare at that one and try to get it to work).
The text was updated successfully, but these errors were encountered:
You are correct that the second instance is the ZipList Applicative. When a type has both a Monad and an Applicative instance, it's necessary for them to agree. That is, given ap,
ap::Monadm=>m (a->b) ->ma->mb
ap mf ma =do
f <- mf
a <- ma
pure (f a)
then for any values, f `ap` a == f <*> a. Since ZipList does not have a Monad, we give the "cross-product-y" one to List itself.
Adding a comment to indicate two possible instances is a good idea :) Thanks
The test suite for Applicative.hs accepts the following code:
and rejects the following code:
I'm under the impression that these are both valid applicative instances (I think the second one is essentially the ZipList applicative instance, but I'm not actually sure).
If so, it might be useful to somehow alert the students that, while the second instance is valid, they should search for an entirely different instance (and not stare at that one and try to get it to work).
The text was updated successfully, but these errors were encountered: