It would be really great if libraries just used MonadEffect
and MonadAff
so that their functions seamlessly fit into my code.
Thanks everyone lets get started on the transition.
There is a performance overhead to using constraints over the unlifted type, so generally I like to include the operations lifted and unlifted. Effect.Console
and Effect.Console.Class
being a good example of that.
No thank you - I really don’t think writing the occasional liftAff
or liftEffect
is worth the cost of worse type inference and type error messages, and making type signatures more complicated. Additionally, you often can’t use MonadAff or MonadEffect when you’re taking an Aff or Effect action as an argument.
All these reasons seem like orthogonal reasons not to because the compiler isn’t good enough yet.
I am using lift, liftAff, liftEffect on a large number of lines if I’m working in some other monad. Again it seems like the compiler not supporting these well is to blame here.
Not really - the compiler can always improve on error messages, but there’s a limit to what you can do there. MonadEffect is just more complicated than plain Effect, and there’s no way around that.
Yeah, good point. ^ This is referring to the fact plain Effect
can be specially optimized in a way that will never be workable for MonadEffect
as it doesn’t apply to monads in general - it basically turns a sequence of Effect
binds into plain JS statements.
Personally I wasn’t really thinking about generated code, I was more referring to type inference, type checking, and generation of error messages. Having fewer type classes and type variables floating around will usually simplify things. Even with really good error reporting, putting an Aff somewhere an Effect should go (or vice versa) is always going to generate an error which is easier to understand compared to if everything has been lifted.
Have either of you seen any “papers” that address how to merge these disparate monads more easily?