in-other-words-0.2.0.0: A higher-order effect system where the sky's the limit
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Newtype

Synopsis

Wrapping

wrapWith :: (Member e (Derivs m), Carrier m, Coercible unwrappedE e) => (unwrappedE z x -> e z x) -> WrapC unwrappedE e m a -> m a Source #

Wrap uses of an effect, injecting them into a newtype of that effect. The first argument is ignored.

This is useful for creating actions of effect newtypes. For example:

newtype Counter m a = Counter (State Int m)

probe :: Eff Counter m => m Int
probe = wrapWith Counter $ state' @Int (\s -> (s + 1, s))

Unwrapping

class EffNewtype (e :: Effect) where Source #

Minimal complete definition

Nothing

Associated Types

type UnwrappedEff e :: Effect Source #

Methods

unwrapped :: e z x -> UnwrappedEff e z x Source #

default unwrapped :: Coercible e (UnwrappedEff e) => e z x -> UnwrappedEff e z x Source #

Instances

Instances details
EffNewtype Conc Source # 
Instance details

Defined in Control.Effect.Internal.Conc

Associated Types

type UnwrappedEff Conc :: Effect Source #

Methods

unwrapped :: forall (z :: Type -> Type) x. Conc z x -> UnwrappedEff Conc z x Source #

Coercible e e' => EffNewtype (WrapperOf e e') Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type UnwrappedEff (WrapperOf e e') :: Effect Source #

Methods

unwrapped :: forall (z :: Type -> Type) x. WrapperOf e e' z x -> UnwrappedEff (WrapperOf e e') z x Source #

newtype WrapperOf (e :: Effect) (e' :: Effect) m a Source #

Useful for deriving instances of EffNewtype.

newtype SomeWrapper m a = SomeWrapper (SomeEffect m a)
  deriving EffNewtype via SomeWrapper `WrapperOf` SomeEffect

Constructors

WrapperOf (e m a) 

Instances

Instances details
Coercible e e' => EffNewtype (WrapperOf e e') Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type UnwrappedEff (WrapperOf e e') :: Effect Source #

Methods

unwrapped :: forall (z :: Type -> Type) x. WrapperOf e e' z x -> UnwrappedEff (WrapperOf e e') z x Source #

type UnwrappedEff (WrapperOf e e') Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type UnwrappedEff (WrapperOf e e') = e'

unwrap :: forall e m a. (Carrier m, Member (UnwrappedEff e) (Derivs m), EffNewtype e) => UnwrapC e m a -> m a Source #

Unwrap uses of an effect

unwrapTop :: forall e m a. (HeadEff (UnwrappedEff e) m, EffNewtype e, Carrier m) => UnwrapTopC e m a -> m a Source #

Unwrap uses of an effect, placing its unwrapped version on top of the effect stack.

Carriers

data WrapC (e :: Effect) (e' :: Effect) m (a :: *) Source #

Instances

Instances details
MonadBase b m => MonadBase b (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

liftBase :: b α -> WrapC e e' m α #

MonadBaseControl b m => MonadBaseControl b (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StM (WrapC e e' m) a #

Methods

liftBaseWith :: (RunInBase (WrapC e e' m) b -> b a) -> WrapC e e' m a #

restoreM :: StM (WrapC e e' m) a -> WrapC e e' m a #

MonadTrans (WrapC e e') Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

lift :: Monad m => m a -> WrapC e e' m a #

MonadTransControl (WrapC e e') Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StT (WrapC e e') a #

Methods

liftWith :: Monad m => (Run (WrapC e e') -> m a) -> WrapC e e' m a #

restoreT :: Monad m => m (StT (WrapC e e') a) -> WrapC e e' m a #

Monad m => Monad (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

(>>=) :: WrapC e e' m a -> (a -> WrapC e e' m b) -> WrapC e e' m b #

(>>) :: WrapC e e' m a -> WrapC e e' m b -> WrapC e e' m b #

return :: a -> WrapC e e' m a #

Functor m => Functor (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

fmap :: (a -> b) -> WrapC e e' m a -> WrapC e e' m b #

(<$) :: a -> WrapC e e' m b -> WrapC e e' m a #

MonadFix m => MonadFix (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mfix :: (a -> WrapC e e' m a) -> WrapC e e' m a #

MonadFail m => MonadFail (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

fail :: String -> WrapC e e' m a #

Applicative m => Applicative (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

pure :: a -> WrapC e e' m a #

(<*>) :: WrapC e e' m (a -> b) -> WrapC e e' m a -> WrapC e e' m b #

liftA2 :: (a -> b -> c) -> WrapC e e' m a -> WrapC e e' m b -> WrapC e e' m c #

(*>) :: WrapC e e' m a -> WrapC e e' m b -> WrapC e e' m b #

(<*) :: WrapC e e' m a -> WrapC e e' m b -> WrapC e e' m a #

MonadIO m => MonadIO (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

liftIO :: IO a -> WrapC e e' m a #

Alternative m => Alternative (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

empty :: WrapC e e' m a #

(<|>) :: WrapC e e' m a -> WrapC e e' m a -> WrapC e e' m a #

some :: WrapC e e' m a -> WrapC e e' m [a] #

many :: WrapC e e' m a -> WrapC e e' m [a] #

MonadPlus m => MonadPlus (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mzero :: WrapC e e' m a #

mplus :: WrapC e e' m a -> WrapC e e' m a -> WrapC e e' m a #

MonadThrow m => MonadThrow (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

throwM :: Exception e0 => e0 -> WrapC e e' m a #

MonadCatch m => MonadCatch (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

catch :: Exception e0 => WrapC e e' m a -> (e0 -> WrapC e e' m a) -> WrapC e e' m a #

MonadMask m => MonadMask (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mask :: ((forall a. WrapC e e' m a -> WrapC e e' m a) -> WrapC e e' m b) -> WrapC e e' m b #

uninterruptibleMask :: ((forall a. WrapC e e' m a -> WrapC e e' m a) -> WrapC e e' m b) -> WrapC e e' m b #

generalBracket :: WrapC e e' m a -> (a -> ExitCase b -> WrapC e e' m c) -> (a -> WrapC e e' m b) -> WrapC e e' m (b, c) #

(Member e' (Derivs m), Coercible e e', Carrier m) => Carrier (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type Derivs (WrapC e e' m) :: [Effect] Source #

type Prims (WrapC e e' m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (WrapC e e' m)) (WrapC e e' m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (WrapC e e' m)) (Prims (WrapC e e' m)) (WrapC e e' m) z a Source #

algDerivs :: Algebra' (Derivs (WrapC e e' m)) (WrapC e e' m) a Source #

type StT (WrapC e e') a Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type StT (WrapC e e') a = StT (IdentityT :: (Type -> Type) -> Type -> Type) a
type Derivs (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type Derivs (WrapC e e' m) = e ': Derivs m
type Prims (WrapC e e' m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type Prims (WrapC e e' m) = Prims m
type StM (WrapC e e' m) a Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type StM (WrapC e e' m) a = StM m a

data UnwrapC (e :: Effect) m (a :: *) Source #

Instances

Instances details
MonadBase b m => MonadBase b (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

liftBase :: b α -> UnwrapC e m α #

MonadBaseControl b m => MonadBaseControl b (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StM (UnwrapC e m) a #

Methods

liftBaseWith :: (RunInBase (UnwrapC e m) b -> b a) -> UnwrapC e m a #

restoreM :: StM (UnwrapC e m) a -> UnwrapC e m a #

MonadTrans (UnwrapC e) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

lift :: Monad m => m a -> UnwrapC e m a #

MonadTransControl (UnwrapC e) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StT (UnwrapC e) a #

Methods

liftWith :: Monad m => (Run (UnwrapC e) -> m a) -> UnwrapC e m a #

restoreT :: Monad m => m (StT (UnwrapC e) a) -> UnwrapC e m a #

Monad m => Monad (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

(>>=) :: UnwrapC e m a -> (a -> UnwrapC e m b) -> UnwrapC e m b #

(>>) :: UnwrapC e m a -> UnwrapC e m b -> UnwrapC e m b #

return :: a -> UnwrapC e m a #

Functor m => Functor (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

fmap :: (a -> b) -> UnwrapC e m a -> UnwrapC e m b #

(<$) :: a -> UnwrapC e m b -> UnwrapC e m a #

MonadFix m => MonadFix (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mfix :: (a -> UnwrapC e m a) -> UnwrapC e m a #

MonadFail m => MonadFail (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

fail :: String -> UnwrapC e m a #

Applicative m => Applicative (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

pure :: a -> UnwrapC e m a #

(<*>) :: UnwrapC e m (a -> b) -> UnwrapC e m a -> UnwrapC e m b #

liftA2 :: (a -> b -> c) -> UnwrapC e m a -> UnwrapC e m b -> UnwrapC e m c #

(*>) :: UnwrapC e m a -> UnwrapC e m b -> UnwrapC e m b #

(<*) :: UnwrapC e m a -> UnwrapC e m b -> UnwrapC e m a #

MonadIO m => MonadIO (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

liftIO :: IO a -> UnwrapC e m a #

Alternative m => Alternative (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

empty :: UnwrapC e m a #

(<|>) :: UnwrapC e m a -> UnwrapC e m a -> UnwrapC e m a #

some :: UnwrapC e m a -> UnwrapC e m [a] #

many :: UnwrapC e m a -> UnwrapC e m [a] #

MonadPlus m => MonadPlus (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mzero :: UnwrapC e m a #

mplus :: UnwrapC e m a -> UnwrapC e m a -> UnwrapC e m a #

MonadThrow m => MonadThrow (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

throwM :: Exception e0 => e0 -> UnwrapC e m a #

MonadCatch m => MonadCatch (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

catch :: Exception e0 => UnwrapC e m a -> (e0 -> UnwrapC e m a) -> UnwrapC e m a #

MonadMask m => MonadMask (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mask :: ((forall a. UnwrapC e m a -> UnwrapC e m a) -> UnwrapC e m b) -> UnwrapC e m b #

uninterruptibleMask :: ((forall a. UnwrapC e m a -> UnwrapC e m a) -> UnwrapC e m b) -> UnwrapC e m b #

generalBracket :: UnwrapC e m a -> (a -> ExitCase b -> UnwrapC e m c) -> (a -> UnwrapC e m b) -> UnwrapC e m (b, c) #

(Carrier m, Member (UnwrappedEff e) (Derivs m), EffNewtype e) => Carrier (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type Derivs (UnwrapC e m) :: [Effect] Source #

type Prims (UnwrapC e m) :: [Effect] Source #

type StT (UnwrapC e) a Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type StT (UnwrapC e) a = StT (IdentityT :: (Type -> Type) -> Type -> Type) a
type Derivs (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type Derivs (UnwrapC e m) = e ': Derivs m
type Prims (UnwrapC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type Prims (UnwrapC e m) = Prims m
type StM (UnwrapC e m) a Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type StM (UnwrapC e m) a = StM m a

data UnwrapTopC (e :: Effect) m (a :: *) Source #

Instances

Instances details
MonadBase b m => MonadBase b (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

liftBase :: b α -> UnwrapTopC e m α #

MonadBaseControl b m => MonadBaseControl b (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StM (UnwrapTopC e m) a #

Methods

liftBaseWith :: (RunInBase (UnwrapTopC e m) b -> b a) -> UnwrapTopC e m a #

restoreM :: StM (UnwrapTopC e m) a -> UnwrapTopC e m a #

MonadTrans (UnwrapTopC e) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

lift :: Monad m => m a -> UnwrapTopC e m a #

MonadTransControl (UnwrapTopC e) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type StT (UnwrapTopC e) a #

Methods

liftWith :: Monad m => (Run (UnwrapTopC e) -> m a) -> UnwrapTopC e m a #

restoreT :: Monad m => m (StT (UnwrapTopC e) a) -> UnwrapTopC e m a #

Monad m => Monad (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

(>>=) :: UnwrapTopC e m a -> (a -> UnwrapTopC e m b) -> UnwrapTopC e m b #

(>>) :: UnwrapTopC e m a -> UnwrapTopC e m b -> UnwrapTopC e m b #

return :: a -> UnwrapTopC e m a #

Functor m => Functor (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

fmap :: (a -> b) -> UnwrapTopC e m a -> UnwrapTopC e m b #

(<$) :: a -> UnwrapTopC e m b -> UnwrapTopC e m a #

MonadFix m => MonadFix (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mfix :: (a -> UnwrapTopC e m a) -> UnwrapTopC e m a #

MonadFail m => MonadFail (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

fail :: String -> UnwrapTopC e m a #

Applicative m => Applicative (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

pure :: a -> UnwrapTopC e m a #

(<*>) :: UnwrapTopC e m (a -> b) -> UnwrapTopC e m a -> UnwrapTopC e m b #

liftA2 :: (a -> b -> c) -> UnwrapTopC e m a -> UnwrapTopC e m b -> UnwrapTopC e m c #

(*>) :: UnwrapTopC e m a -> UnwrapTopC e m b -> UnwrapTopC e m b #

(<*) :: UnwrapTopC e m a -> UnwrapTopC e m b -> UnwrapTopC e m a #

MonadIO m => MonadIO (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

liftIO :: IO a -> UnwrapTopC e m a #

Alternative m => Alternative (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

empty :: UnwrapTopC e m a #

(<|>) :: UnwrapTopC e m a -> UnwrapTopC e m a -> UnwrapTopC e m a #

some :: UnwrapTopC e m a -> UnwrapTopC e m [a] #

many :: UnwrapTopC e m a -> UnwrapTopC e m [a] #

MonadPlus m => MonadPlus (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mzero :: UnwrapTopC e m a #

mplus :: UnwrapTopC e m a -> UnwrapTopC e m a -> UnwrapTopC e m a #

MonadThrow m => MonadThrow (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

throwM :: Exception e0 => e0 -> UnwrapTopC e m a #

MonadCatch m => MonadCatch (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

catch :: Exception e0 => UnwrapTopC e m a -> (e0 -> UnwrapTopC e m a) -> UnwrapTopC e m a #

MonadMask m => MonadMask (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Methods

mask :: ((forall a. UnwrapTopC e m a -> UnwrapTopC e m a) -> UnwrapTopC e m b) -> UnwrapTopC e m b #

uninterruptibleMask :: ((forall a. UnwrapTopC e m a -> UnwrapTopC e m a) -> UnwrapTopC e m b) -> UnwrapTopC e m b #

generalBracket :: UnwrapTopC e m a -> (a -> ExitCase b -> UnwrapTopC e m c) -> (a -> UnwrapTopC e m b) -> UnwrapTopC e m (b, c) #

(IntroConsistent ('[] :: [Effect]) '[UnwrappedEff e] m, EffNewtype e, Carrier m) => Carrier (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

Associated Types

type Derivs (UnwrapTopC e m) :: [Effect] Source #

type Prims (UnwrapTopC e m) :: [Effect] Source #

type StT (UnwrapTopC e) a Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type StT (UnwrapTopC e) a = StT (IdentityT :: (Type -> Type) -> Type -> Type) a
type Derivs (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type Derivs (UnwrapTopC e m) = e ': StripPrefix '[UnwrappedEff e] (Derivs m)
type Prims (UnwrapTopC e m) Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type Prims (UnwrapTopC e m) = Prims m
type StM (UnwrapTopC e m) a Source # 
Instance details

Defined in Control.Effect.Internal.Newtype

type StM (UnwrapTopC e m) a = StM m a