We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Something like this, perhaps:
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes #-} import Control.Monad.Freer (Eff, Member) import Control.Monad.Freer.State (State, get, put) import Control.Monad.State (MonadState) import qualified Control.Monad.State (MonadState(get, put)) newtype StateEff s effs a = StateEff { runStateEff :: Eff effs a } deriving (Functor, Applicative, Monad) instance (Member (State s) effs) => MonadState s (StateEff s effs) where get = StateEff get {-# INLINE get #-} put = StateEff . put {-# INLINE put #-} wrapState :: Member (State s) effs => (forall m. MonadState s m => m a) -> Eff effs a wrapState m = runStateEff m {-# INLINE wrapState #-}
The text was updated successfully, but these errors were encountered:
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} import Control.Monad.Freer (Eff, Member) import Control.Monad.Freer.State (State, get, put) import Control.Monad.State (MonadState) import qualified Control.Monad.State (MonadState(get, put)) import Data.Coerce (coerce) newtype StateEff s effs a = StateEff { runStateEff :: Eff effs a } deriving (Functor, Applicative, Monad) instance (Member (State s) effs) => MonadState s (StateEff s effs) where get = coerce (get :: Eff effs s) {-# INLINE get #-} put = coerce (put :: s -> Eff effs ()) {-# INLINE put #-} wrapState :: forall s effs a. Member (State s) effs => (forall m. MonadState s m => m a) -> Eff effs a wrapState m = coerce (m :: StateEff s effs a) {-# INLINE wrapState #-}
Sorry, something went wrong.
No branches or pull requests
Something like this, perhaps:
The text was updated successfully, but these errors were encountered: