You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shelly.Lifted is a great idea, however I don't really know how to use it and there is a lack of documentation (related: #135 from 5 years ago! Also ben's comment: #115 (comment)) . My use case is simply a ReaderT over Sh rather than IO. This leads me to something like:
--| our script monad, just a reader of IO in the guise of ShellynewtypeScriptMTrma=ScriptMT{unScriptMT::ReaderTrma}derivingnewtype ( Functor, Applicative, Monad
, MonadIO, MonadReader r, MonadTrans, MonadTransControl
, MonadSh
)
and then we derive MonadBase and MonadBaseControl:
and this is great! We get exception handling functions like try from Control.Exception.Lifted, and we can easily use lots of functions in Shelly.Lifted since we derive a MonadSh instance.
But how do I use functions with a MonadShControl constraint? There are a decent number of these functions that are useful, most notable escaping.
If I try to define it by hand I end up with something like:
but this cannot unify the ReaderT. Normally I would think that liftShWith would have to be a dead simple instance of unlifting and calling liftShWithforReaderT. So all I need to do is unwrap ScriptMT, run the function passed to liftShWith and then re-wrap with the associated type family. But none of that works and so I'm at a loss and am forced to use a type synonym rather than a newtype.
Perhaps there is just missing documentation around this type class showing how to define an instance for a monad transformer? Or perhaps this is just a problem with my definition because I pinned the ReaderT in my newtype.
Thanks for Shelly, any help appreciated.
The text was updated successfully, but these errors were encountered:
Shelly.Lifted
is a great idea, however I don't really know how to use it and there is a lack of documentation (related: #135 from 5 years ago! Also ben's comment: #115 (comment)) . My use case is simply aReaderT
overSh
rather thanIO
. This leads me to something like:and then we derive
MonadBase
andMonadBaseControl
:and this is great! We get exception handling functions like
try
fromControl.Exception.Lifted
, and we can easily use lots of functions inShelly.Lifted
since we derive aMonadSh
instance.But how do I use functions with a
MonadShControl
constraint? There are a decent number of these functions that are useful, most notableescaping
.If I try to define it by hand I end up with something like:
but this cannot unify the
ReaderT
. Normally I would think thatliftShWith
would have to be a dead simple instance of unlifting and callingliftShWith
forReaderT
. So all I need to do is unwrapScriptMT
, run the function passed toliftShWith
and then re-wrap with the associated type family. But none of that works and so I'm at a loss and am forced to use a type synonym rather than a newtype.Perhaps there is just missing documentation around this type class showing how to define an instance for a monad transformer? Or perhaps this is just a problem with my definition because I pinned the
ReaderT
in my newtype.Thanks for Shelly, any help appreciated.
The text was updated successfully, but these errors were encountered: