Open bollu opened 7 years ago
Does GeneralizedNewtypeDeriving not work here?
Wow,
GeneralizedNewtypeDeriving
had enough power to do that. It requires you to define what the Element
of the type family is, which the TH code does automatically.GeneralizedNewtypeDeriving
does not help with (nor does DeriveAnyClass
)OK, then this addition sounds good. Could you put it in a separate module though in case we need to conditionally exclude it for platforms lacking TH support?
Sure thing. I'll start by branching off and gradually adding instances.
On Sun, 23 Oct 2016 at 14:25 Michael Snoyman notifications@github.com wrote:
OK, then this addition sounds good. Could you put it in a separate module though in case we need to conditionally exclude it for platforms lacking TH support?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/snoyberg/mono-traversable/issues/113#issuecomment-255576841, or mute the thread https://github.com/notifications/unsubscribe-auth/ABncjQcV0uKHvgbfniq9oR6luIBOEnq-ks5q2yD4gaJpZM4KeDla .
Sending this from my phone, please excuse any typos!
Hey,
It would be nice to be able to automatically generate
mono-*
instances for anewtype
wrapper or adata
declaration that simply monomorphises a polymorphic type.For example, we could easy do
for which we can clearly write a
MonoFunctor
instance.I've done this for my
cellular-automata-diagrams
library. I'm using template haskell, but I'd be interested in trying this out with theDeriveGeneric
functionality as well.Example use: it automatically instantiates the type family
Element
, derivesMonoFunctor
andMonoComonad
here inCyclic2d.hs
I'd be happy to add this facility and send a PR for all typeclasses in the library, since it was something I sorely wanted. Do you think this would be useful?