ekmett / free

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

deriving (Applicative, Monad) via GenericFreeMonad "Pure" (Free f) #214

Open Icelandjack opened 2 years ago

Icelandjack commented 2 years ago

Li-yao implemented a way to derive Free functors, I will link the gist:

I am wondering where it belongs, I could add it to my idiomatic package which is for deriving Applicative for sums but this package may be a better fit. It allows us to derive Applicative and Monad for Free f and other instantiations of it:

data Free f a = Pure a | Free (f (Free f a))
  deriving (Functor, Applicative, Monad)
  via GenericFreeMonad "Pure" (Free f)

At least I wanted to make it known :) I am not proposing that Monad (Free f) should be derived, but that is possible