
17 Jun
2016
17 Jun
'16
10:14 p.m.
On 6/17/2016 6:16 PM, Tom Ellis wrote:
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 :)
Doh, you're right. s is in both positive and negative positions there.