Open jacobstanley opened 7 years ago
Is there a way to simplify the Transformer
constraint? I try to avoid constraints like Monad (f (g m))
in order to simplify inferred types. If there were a simpler constraint that didn't need to be stored as an associated type constraint then I wouldn't mind adding this to mmorph
Is there a way to simplify the
Transformer
constraint? I try to avoid constraints likeMonad (f (g m))
in order to simplify inferred types.
That's part of the question I suppose, I don't think it's possible, but I may be thinking about it the wrong way.
If you look at the type for distribute
in pipes
it has the equivalent of the Monad (f (g m))
in the form of Monad (t (Proxy a' a b' b m)))
:
distribute ::
Monad m
=> MonadTrans t
=> MFunctor t
=> Monad (t m)
=> Monad (t (Proxy a' a b' b m)))
=> Proxy a' a b' b (t m) r
-> t (Proxy a' a b' b m) r
I think you can get away without Monad (g m)
for many transformers.
Also it seems like as soon as you have a transformer stack you need the associated type constraint to get all the Monad
instances you need. It's like there needs to be a way to say "this is a monad and so are all the things it's on top of".
I found myself wanting distribute for a number of transformers, including transformer stacks. It seems like this is similar to Distributive but for transformers.
Does this makes sense as a type class?
I found myself having to reach for an associated type to implement it because it seems that a bunch of constraints are needed for every transformer in the stack. Would love to know if anyone can think of a better way as it feels like an enormous and inelegant hammer.
For larger stacks, just an example:
I'm not sure if this is possibly related to / would help with my other question https://github.com/Gabriel439/Haskell-MMorph-Library/issues/34
I'm not tied to the names of anything here, I just wanted to have a discussion about whether this class makes sense and whether it would be useful to add to
mmorph
.