fused-effects-readline-0.1.0.1: A readline-like effect and carrier for fused-effects
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Readline

Synopsis

Readline effect

data Readline (m :: Type -> Type) (k :: Type) where Source #

Constructors

Prompt :: String -> Readline m (Int, Maybe String) 
Print :: Doc AnsiStyle -> Readline m () 

Instances

Instances details
(MonadIO m, MonadMask m) => Algebra Readline (ReadlineC m) Source # 
Instance details

Defined in Control.Carrier.Readline.Haskeline

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (ReadlineC m) -> Readline n a -> ctx () -> ReadlineC m (ctx a) #

print :: Has Readline sig m => Doc AnsiStyle -> m () Source #

Re-exports

class Monad m => Algebra (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) | m -> sig #

The class of carriers (results) for algebras (effect handlers) over signatures (effects), whose actions are given by the alg method.

Since: fused-effects-1.0.0.0

Minimal complete definition

alg

Instances

Instances details
Algebra NonDet [] 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n [] -> NonDet n a -> ctx () -> [ctx a] #

Algebra Empty Maybe 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n Maybe -> Empty n a -> ctx () -> Maybe (ctx a) #

Algebra Choose NonEmpty 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n NonEmpty -> Choose n a -> ctx () -> NonEmpty (ctx a) #

(MonadIO m, MonadMask m) => Algebra Readline (ReadlineC m) Source # 
Instance details

Defined in Control.Carrier.Readline.Haskeline

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (ReadlineC m) -> Readline n a -> ctx () -> ReadlineC m (ctx a) #

Algebra sig m => Algebra sig (IdentityT m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (IdentityT m) -> sig n a -> ctx () -> IdentityT m (ctx a) #

Algebra sig m => Algebra sig (Ap m)

This instance permits effectful actions to be lifted into the Ap monad given a monoidal return type, which can provide clarity when chaining calls to mappend.

mappend <$> act1 <*> (mappend <$> act2 <*> act3)

is equivalent to

getAp (act1 <> act2 <> act3)

Since: fused-effects-1.0.1.0

Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (Ap m) -> sig n a -> ctx () -> Ap m (ctx a) #

Algebra sig m => Algebra sig (Alt m)

This instance permits effectful actions to be lifted into the Alt monad, which eases the invocation of repeated alternation with <|>:

a <|> b <|> c <|> d

is equivalent to

getAlt (mconcat [a, b, c, d])

Since: fused-effects-1.0.1.0

Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (Alt m) -> sig n a -> ctx () -> Alt m (ctx a) #

Algebra (Lift IO) IO 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n IO -> Lift IO n a -> ctx () -> IO (ctx a) #

Algebra (Lift Identity) Identity 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n Identity -> Lift Identity n a -> ctx () -> Identity (ctx a) #

Monoid w => Algebra (Writer w) ((,) w) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n ((,) w) -> Writer w n a -> ctx () -> (w, ctx a) #

Algebra (Error e) (Either e) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (Either e) -> Error e n a -> ctx () -> Either e (ctx a) #

Monad m => Algebra (Lift m) (LiftC m) 
Instance details

Defined in Control.Carrier.Lift

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (LiftC m) -> Lift m n a -> ctx () -> LiftC m (ctx a) #

Algebra (Reader r) ((->) r :: Type -> Type) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n ((->) r) -> Reader r n a -> ctx () -> r -> ctx a #

Algebra sig m => Algebra (Empty :+: sig) (MaybeT m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (MaybeT m) -> (Empty :+: sig) n a -> ctx () -> MaybeT m (ctx a) #

(Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (WriterT w m) -> (Writer w :+: sig) n a -> ctx () -> WriterT w m (ctx a) #

(Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (WriterT w m) -> (Writer w :+: sig) n a -> ctx () -> WriterT w m (ctx a) #

(Algebra sig m, Monoid w) => Algebra (Writer w :+: sig) (WriterT w m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (WriterT w m) -> (Writer w :+: sig) n a -> ctx () -> WriterT w m (ctx a) #

Algebra sig m => Algebra (Error e :+: sig) (ExceptT e m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (ExceptT e m) -> (Error e :+: sig) n a -> ctx () -> ExceptT e m (ctx a) #

Algebra sig m => Algebra (State s :+: sig) (StateT s m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (StateT s m) -> (State s :+: sig) n a -> ctx () -> StateT s m (ctx a) #

Algebra sig m => Algebra (State s :+: sig) (StateT s m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (StateT s m) -> (State s :+: sig) n a -> ctx () -> StateT s m (ctx a) #

Algebra sig m => Algebra (Reader r :+: sig) (ReaderT r m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (ReaderT r m) -> (Reader r :+: sig) n a -> ctx () -> ReaderT r m (ctx a) #

Algebra sig m => Algebra (Reader r :+: sig) (ReaderC r m) 
Instance details

Defined in Control.Carrier.Reader

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (ReaderC r m) -> (Reader r :+: sig) n a -> ctx () -> ReaderC r m (ctx a) #

(Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (RWST r w s m) -> (Reader r :+: (Writer w :+: (State s :+: sig))) n a -> ctx () -> RWST r w s m (ctx a) #

(Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (RWST r w s m) -> (Reader r :+: (Writer w :+: (State s :+: sig))) n a -> ctx () -> RWST r w s m (ctx a) #

(Algebra sig m, Monoid w) => Algebra (Reader r :+: (Writer w :+: (State s :+: sig))) (RWST r w s m) 
Instance details

Defined in Control.Algebra

Methods

alg :: forall ctx (n :: Type -> Type) a. Functor ctx => Handler ctx n (RWST r w s m) -> (Reader r :+: (Writer w :+: (State s :+: sig))) n a -> ctx () -> RWST r w s m (ctx a) #

type Has (eff :: (Type -> Type) -> Type -> Type) (sig :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) = (Members eff sig, Algebra sig m) #

m is a carrier for sig containing eff.

Note that if eff is a sum, it will be decomposed into multiple Member constraints. While this technically allows one to combine multiple unrelated effects into a single Has constraint, doing so has two significant drawbacks:

  1. Due to a problem with recursive type families, this can lead to significantly slower compiles.
  2. It defeats ghc’s warnings for redundant constraints, and thus can lead to a proliferation of redundant constraints as code is changed.

Since: fused-effects-1.0.0.0

run :: Identity a -> a #

Run an action exhausted of effects to produce its final result value.

Since: fused-effects-1.0.0.0