
On Tue, Jan 20, 2015 at 12:09 AM, Cody Goodman
I understand the error below, but I'm not really sure what an instance of liftIO would look like for the Identity functor. I guess I'm not all to clear on what an identity functor is.
I'm a little fuzzy on what an identity monad is. I understand that id gives the identity of something back pretty well though. Can anyone help?
The identity functor/monad is this: newtype Identity a = Identity { runIdentity :: a } That is, the type constructor `Identity` works like the function `id`, but on the type level. It doesn't add any sort of special effects, it just gives us a type constructor that we can use whenever we need something of kind * -> *, like when working with monad transformer stacks. Identity is trivially a monad: instance Functor Identity where fmap f (Identity x) = Identity (f x) instance Applicative Identity where pure x = Identity x Identity f <*> Identity x = Identity (f x) instance Monad Identity where return x = Identity x Identity x >>= f = f x If we erase all the newtype un/wrapping, then we can see that all these functions are just variations on ($) and `id`. That's why we say it's trivial. -- Live well, ~wren