Typeclassopedia presents this exercise:
Implement a Monad instance for ((->) e).
Here's the MyMonad class.
class (MyMonad m) where
    ret     :: a   -> m a
    flatMap :: m a -> (a -> m b) -> m b
Then, I begin to attempt to implement the Monad instance for ((->) e).
instance (MyMonad (-> e)) where
    ret x       = ...
    flatMap m f = ...
But, I don't have intuition for what ((->) e) means. 
Please help me understand it, as well as give me a hint towards solving for ret.
There's something of a syntax trick going on here. It might be easier to think of (->) e as (e ->) or, even more clearly, if we write
type Arr a b = a -> b
then (->) e is about the same as Arr e.
So what is the type of ret? It ends up as
ret :: a -> (e -> a)
which should be more solvable now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With