Open Fresheyeball opened 3 years ago
I think this is correct observation except for the fact that I don't see how this could make current implementation unlawful. This can be due to my lack of understanding for sure but I would like if you can explain what leads to you to such conclusion.
The function ap
:
ap mf ma = mf >>= (\f -> ma >>= (\a -> return (f a)))
is correct proof that every monad must be applicative as well. However I'm not aware that ap == (<*>)
is some actual law. It kind of makes sense in languages with hierarchy of typeclasses (Haskell, Purescript...) but I don't think it's a law. If anything because Applicative is preceding Monad I would expect it to be one of monad laws if anything but it's not.
This all being said I think logical thing would be to return NotAsked
when ever one of the constructors is NotAsked
since that would seem the most practical to me. That means even andMap Loading NotAsked == NotAsked
After doing some work porting this to Haskell and I discovered that there is an inconsistency between
andMap
andandThen
.Specifically it breaks the
ap
law:or in an Elm context
But this is not the case, given this counter example:
What you have right now for
andMap
is a valid Applicative, but the specificApplicative
it is does not lead toMonad
. The correctApplicative
to matchandThen
would be as follows:Now the counter example is lawful