-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Operational-based extensible effect library -- -- See README.md @package extensible-skeleton @version 0 -- | Name-based extensible effects module Data.Extensible.Effect -- | A unit of named effects. This is a variant of (:|) -- specialised for 'Type -> Type'. data Instruction (xs :: [Assoc k (Type -> Type)]) a [Instruction] :: !Membership xs kv -> TargetOf kv a -> Instruction xs a -- | The extensible operational monad type Eff xs = Skeleton (Instruction xs) -- | Lift an instruction onto an Eff action. liftEff :: forall s t xs a. Lookup xs s t => Proxy s -> t a -> Eff xs a -- | Lift an instruction onto an Eff action and apply a function to -- the result. liftsEff :: forall s t xs a r. Lookup xs s t => Proxy s -> t a -> (a -> r) -> Eff xs r -- | Censor a specific type of effects in an action. hoistEff :: forall s t xs a. Lookup xs s t => Proxy s -> (forall x. t x -> t x) -> Eff xs a -> Eff xs a -- | Upcast an action. castEff :: IncludeAssoc ys xs => Eff xs a -> Eff ys a -- | Transformation between effects newtype Interpreter f g Interpreter :: (forall a. g a -> f a) -> Interpreter f g [runInterpreter] :: Interpreter f g -> forall a. g a -> f a -- | Process an Eff action using a record of Interpreters. handleEff :: RecordOf (Interpreter m) xs -> Eff xs a -> MonadView m (Eff xs) a -- | Build a relay-style handler from a triple of functions. -- --
--   runStateEff = peelEff1 (a s -> return (a, s))
--     (m k s -> let (a, s') = runState m s in k a s')
--   
peelEff :: forall k t xs a r. Rebinder xs r -> (a -> r) -> (forall x. t x -> (x -> r) -> r) -> Eff ((k >: t) : xs) a -> r -- | A function to bind an Instruction in peelEff. type Rebinder xs r = forall x. Instruction xs x -> (x -> r) -> r -- | A common value for the second argument of peelEff. Binds an -- instruction directly. rebindEff0 :: Rebinder xs (Eff xs r) -- | peelEff specialised for continuations with no argument peelEff0 :: forall k t xs a r. (a -> Eff xs r) -> (forall x. t x -> (x -> Eff xs r) -> Eff xs r) -> Eff ((k >: t) : xs) a -> Eff xs r -- | A pre-defined value for the second argument of peelEff. -- Preserves the argument of the continuation. rebindEff1 :: Rebinder xs (a -> Eff xs r) -- | peelEff specialised for 1-argument continuation peelEff1 :: forall k t xs a b r. (a -> b -> Eff xs r) -> (forall x. t x -> (x -> b -> Eff xs r) -> b -> Eff xs r) -> Eff ((k >: t) : xs) a -> b -> Eff xs r -- | A pre-defined value for the second argument of peelEff. -- Preserves two arguments of the continuation. rebindEff2 :: Rebinder xs (a -> b -> Eff xs r) -- | Reveal the final result of Eff. leaveEff :: Eff '[] a -> a -- | Tear down an action using the Monad instance of the -- instruction. retractEff :: forall k m a. Monad m => Eff '[k >: m] a -> m a -- | Anonymous representation of instructions. data Action (args :: [Type]) a r [AResult] :: Action '[] a a [AArgument] :: x -> Action xs a r -> Action (x : xs) a r -- | Function [a, b, c] r is a -> b -> c -> -- r type family Function args r :: Type -- | Pass the arguments of Action to the supplied function. runAction :: Function xs (f a) -> Action xs a r -> f r -- | Create a Field of a Interpreter for an Action. (@!?) :: FieldName k -> Function xs (f a) -> Field (Interpreter f) (k :> Action xs a) infix 1 @!? -- | Specialised version of peelEff for Actions. You can pass -- a function a -> b -> ... -> (q -> r) -> r as a -- handler for Action '[a, b, ...] q. peelAction :: forall k ps q xs a r. (forall x. Instruction xs x -> (x -> r) -> r) -> (a -> r) -> Function ps ((q -> r) -> r) -> Eff ((k >: Action ps q) : xs) a -> r -- | Non continuation-passing variant of peelAction. peelAction0 :: forall k ps q xs a. Function ps (Eff xs q) -> Eff ((k >: Action ps q) : xs) a -> Eff xs a -- | The reader monad is characterised by a type equality between the -- result type and the enviroment type. type ReaderEff = (:~:) -- | Fetch the environment. askEff :: forall k r xs. Lookup xs k (ReaderEff r) => Proxy k -> Eff xs r -- | Pass the environment to a function. asksEff :: forall k r xs a. Lookup xs k (ReaderEff r) => Proxy k -> (r -> a) -> Eff xs a -- | Modify the enviroment locally. localEff :: forall k r xs a. Lookup xs k (ReaderEff r) => Proxy k -> (r -> r) -> Eff xs a -> Eff xs a -- | Run the frontal reader effect. runReaderEff :: forall k r xs a. Eff ((k >: ReaderEff r) : xs) a -> r -> Eff xs a -- | A state monad parameterized by the type s of the state to -- carry. -- -- The return function leaves the state unchanged, while -- >>= uses the final state of the first computation as -- the initial state of the second. type State s = StateT s Identity -- | Get the current state. getEff :: forall k s xs. Lookup xs k (State s) => Proxy k -> Eff xs s -- | Pass the current state to a function. getsEff :: forall k s a xs. Lookup xs k (State s) => Proxy k -> (s -> a) -> Eff xs a -- | Replace the state with a new value. putEff :: forall k s xs. Lookup xs k (State s) => Proxy k -> s -> Eff xs () -- | Modify the state. modifyEff :: forall k s xs. Lookup xs k (State s) => Proxy k -> (s -> s) -> Eff xs () -- | Lift a state modification function. stateEff :: forall k s xs a. Lookup xs k (State s) => Proxy k -> (s -> (a, s)) -> Eff xs a -- | Run the frontal state effect. runStateEff :: forall k s xs a. Eff ((k >: State s) : xs) a -> s -> Eff xs (a, s) -- | Run the frontal state effect and return the final state. execStateEff :: forall k s xs a. Eff ((k >: State s) : xs) a -> s -> Eff xs s -- | Run the frontal state effect and return the final result. evalStateEff :: forall k s xs a. Eff ((k >: State s) : xs) a -> s -> Eff xs a -- | (,) already is a writer monad. type WriterEff w = (,) w -- | Write the second element and return the first element. writerEff :: forall k w xs a. Lookup xs k (WriterEff w) => Proxy k -> (a, w) -> Eff xs a -- | Write a value. tellEff :: forall k w xs. Lookup xs k (WriterEff w) => Proxy k -> w -> Eff xs () -- | Squash the outputs into one step and return it. listenEff :: forall k w xs a. (Lookup xs k (WriterEff w), Monoid w) => Proxy k -> Eff xs a -> Eff xs (a, w) -- | Modify the output using the function in the result. passEff :: forall k w xs a. (Lookup xs k (WriterEff w), Monoid w) => Proxy k -> Eff xs (a, w -> w) -> Eff xs a -- | Run the frontal writer effect. runWriterEff :: forall k w xs a. Monoid w => Eff ((k >: WriterEff w) : xs) a -> Eff xs (a, w) -- | Run the frontal state effect. execWriterEff :: forall k w xs a. Monoid w => Eff ((k >: WriterEff w) : xs) a -> Eff xs w -- | An effect with no result type MaybeEff = Const () -- | Break out of the computation. Similar to Nothing. nothingEff :: Lookup xs k MaybeEff => Proxy k -> Eff xs a -- | Run an effect which may fail in the name of k. runMaybeEff :: forall k xs a. Eff ((k >: MaybeEff) : xs) a -> Eff xs (Maybe a) -- | Throwing an exception type EitherEff = Const -- | Throw an exception e, throwing the rest of the computation -- away. throwEff :: Lookup xs k (EitherEff e) => Proxy k -> e -> Eff xs a -- | Attach a handler for an exception. catchEff :: forall k e xs a. Lookup xs k (EitherEff e) => Proxy k -> Eff xs a -> (e -> Eff xs a) -> Eff xs a -- | Run an action and abort on throwEff. runEitherEff :: forall k e xs a. Eff ((k >: EitherEff e) : xs) a -> Eff xs (Either e a) -- | Take a function and applies it to an Either effect iff the effect -- takes the form Left _. mapLeftEff :: (e -> e') -> Eff ((k >: EitherEff e) : xs) a -> Eff ((k >: EitherEff e') : xs) a -- | Identity functor and monad. (a non-strict monad) data Identity a -- | Put a milestone on a computation. tickEff :: Lookup xs k Identity => Proxy k -> Eff xs () -- | Run a computation until the first call of tickEff. runIterEff :: Eff ((k >: Identity) : xs) a -> Eff xs (Either a (Eff ((k >: Identity) : xs) a)) -- | The continuation monad transformer. Can be used to add continuation -- handling to any type constructor: the Monad instance and most -- of the operations do not require m to be a monad. -- -- ContT is not a functor on the category of monads, and many -- operations cannot be lifted through it. data ContT (r :: k) (m :: k -> Type) a :: forall k. () => k -> k -> Type -> Type -> Type -- | Place a continuation-passing action. contEff :: Lookup xs k (ContT r m) => Proxy k -> ((a -> m r) -> m r) -> Eff xs a -- | Unwrap a continuation. runContEff :: forall k r xs a. Eff ((k >: ContT r (Eff xs)) : xs) a -> (a -> Eff xs r) -> Eff xs r -- | Call a function with the current continuation as its argument callCCEff :: Proxy k -> ((a -> Eff ((k >: ContT r (Eff xs)) : xs) b) -> Eff ((k >: ContT r (Eff xs)) : xs) a) -> Eff ((k >: ContT r (Eff xs)) : xs) a -- | Default monad runners and MonadIO, MonadReader, -- MonadWriter, MonadState, MonadError instances module Data.Extensible.Effect.Default -- | mtl-compatible reader type ReaderDef r = "Reader" >: ReaderEff r -- | Specialised version of runReaderEff compatible with the -- MonadReader instance. runReaderDef :: Eff (ReaderDef r : xs) a -> r -> Eff xs a -- | mtl-compatible state type StateDef s = "State" >: State s -- | runStateEff specialised for the MonadState instance. runStateDef :: Eff (StateDef s : xs) a -> s -> Eff xs (a, s) -- | evalStateEff specialised for the MonadState instance. evalStateDef :: Eff (StateDef s : xs) a -> s -> Eff xs a -- | execStateEff specialised for the MonadState instance. execStateDef :: Eff (StateDef s : xs) a -> s -> Eff xs s -- | mtl-compatible writer type WriterDef w = "Writer" >: WriterEff w -- | runWriterDef specialised for the MonadWriter instance. runWriterDef :: Monoid w => Eff (WriterDef w : xs) a -> Eff xs (a, w) -- | execWriterDef specialised for the MonadWriter instance. execWriterDef :: Monoid w => Eff (WriterDef w : xs) a -> Eff xs w -- | Same as EitherDef () type MaybeDef = "Either" >: EitherEff () -- | Similar to runMaybeT, but on Eff runMaybeDef :: Eff (MaybeDef : xs) a -> Eff xs (Maybe a) -- | mtl-compatible either effect type EitherDef e = "Either" >: EitherEff e -- | Similar to runExceptT, but on Eff runEitherDef :: Eff (EitherDef e : xs) a -> Eff xs (Either e a) -- | mtl-compatible continuation type ContDef r m = "Cont" >: ContT r m -- | runContEff specialised for the MonadCont instance. runContDef :: Eff (ContDef r (Eff xs) : xs) a -> (a -> Eff xs r) -> Eff xs r instance Control.Monad.Cont.Class.MonadCont (Data.Extensible.Effect.Eff (Data.Extensible.Effect.Default.ContDef r (Data.Extensible.Effect.Eff xs) : xs)) instance (Control.Monad.IO.Class.MonadIO m, Type.Membership.Internal.Lookup xs "IO" m) => Control.Monad.IO.Class.MonadIO (Data.Extensible.Effect.Eff xs) instance (Control.Monad.Trans.Resource.Internal.MonadResource m, Type.Membership.Internal.Lookup xs "IO" m) => Control.Monad.Trans.Resource.Internal.MonadResource (Data.Extensible.Effect.Eff xs) instance (Control.Monad.Catch.MonadThrow m, Type.Membership.Internal.Lookup xs "IO" m) => Control.Monad.Catch.MonadThrow (Data.Extensible.Effect.Eff xs) instance (Control.Monad.Catch.MonadCatch m, Type.Membership.Internal.Lookup xs "IO" m) => Control.Monad.Catch.MonadCatch (Data.Extensible.Effect.Eff xs) instance Type.Membership.Internal.Lookup xs "Reader" ((Data.Type.Equality.:~:) r) => Control.Monad.Reader.Class.MonadReader r (Data.Extensible.Effect.Eff xs) instance Type.Membership.Internal.Lookup xs "State" (Control.Monad.Trans.State.Strict.State s) => Control.Monad.State.Class.MonadState s (Data.Extensible.Effect.Eff xs) instance (GHC.Base.Monoid w, Type.Membership.Internal.Lookup xs "Writer" ((,) w)) => Control.Monad.Writer.Class.MonadWriter w (Data.Extensible.Effect.Eff xs) instance Type.Membership.Internal.Lookup xs "Either" (Data.Functor.Const.Const e) => Control.Monad.Error.Class.MonadError e (Data.Extensible.Effect.Eff xs) instance (GHC.Base.Monoid e, Type.Membership.Internal.Lookup xs "Either" (Data.Functor.Const.Const e)) => GHC.Base.Alternative (Data.Extensible.Effect.Eff xs) instance (GHC.Base.Monoid e, Type.Membership.Internal.Lookup xs "Either" (Data.Functor.Const.Const e)) => GHC.Base.MonadPlus (Data.Extensible.Effect.Eff xs) module Data.Extensible.Effect.TH -- | Generate named effects from a GADT declaration. -- --
--   decEffects [d|
--    data Blah a b x where
--      Blah :: Int -> a -> Blah a b b
--    |]
--   
-- -- generates -- --
--   type Blah a b = "Blah" >: Action '[Int, a] b
--   blah :: forall xs a b
--     . Associate "Blah" (Action '[Int, a] b) xs
--     => Int -> a -> Eff xs b
--   blah a0 a1
--     = liftEff
--       (Data.Proxy.Proxy :: Data.Proxy.Proxy "Blah")
--       (AArgument a0 (AArgument a1 AResult))
--   
decEffects :: DecsQ -> DecsQ -- | Instead of making a type synonym for individual actions, it defines a -- list of actions. decEffectSet :: DecsQ -> DecsQ -- | Generates type synonyms for the set of actions and also individual -- actions. decEffectSuite :: DecsQ -> DecsQ -- | Generate effect suite with custom settings. customDecEffects :: Bool -> Bool -> DecsQ -> DecsQ