ekmett / free

free monads
http://hackage.haskell.org/package/free
Other
159 stars 65 forks source link

Comonad f => MonadFree f (Tagged f) #202

Open Icelandjack opened 3 years ago

Icelandjack commented 3 years ago

A could of 'trivial' instances, I just wrote them to write them so I have no use for them

instance Comonad f => MonadFree f (Tagged f) where
  wrap :: f (Tagged f a) -> Tagged f a
  wrap = extract

instance MonadFree Identity Identity where
  wrap :: Identity (Identity a) -> Identity a
  wrap = extract
Icelandjack commented 3 years ago

Now I remember, as a consequence we can derive "MonadFree Identity Fresh" for our little friend down there:

type    Fresh :: Type -> Type
newtype Fresh a = Fresh (Integer -> (a, Integer))
 deriving
   (Functor, Applicative, Monad, MonadFix, MonadState Integer, MonadFree Identity)
 via State Integer

I was wondering if State Integer could make sense as a MonadFree instance which lead me to think about Identity ..