
17 Jun
2016
17 Jun
'16
6:16 p.m.
On Fri, Jun 17, 2016 at 05:44:55PM -0400, Joe Quinn wrote:
newtype MyState a s = Mk {unMk :: s -> (s, a)}
I can't write Functor, Applicative, Monad instances for it. Can you?
A Functor instance is pretty easy, but Applicative is off the table without constraints on what a can be.
instance Functor (MyState a) where fmap (Mk f) g = Mk (\s -> let (s', a') = f s in (g s', a'))
I suggest you try compiling it :)