[Haskell-cafe] How to spot Monads, Applicatives ...
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Jun 17 22:16:19 UTC 2016
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 :)
More information about the Haskell-Cafe
mailing list