
5 Dec
2008
5 Dec
'08
12:56 p.m.
That would be incompatible with the ap of the monad where it exists, but it's worse than that. Which state will you return? If you return one of the states output by one or other of the arguments, you'll break one of the laws:
pure id <*> v = v u <*> pure y = pure ($ y) <*> u
You're forced to return the input state, so the Applicative would just be an obfuscated Reader.
Which reminds me ofc, that there is a valid applicative for states (assuming the monad instance is valid): instance Applicative (StateT s f) where pure = return (<*>) = ap All monads are also applicatives ;) Bob