Provide the ability to use the Alternative and MonadPlus instance for Eff.
Instances1DispatchOf
type DispatchOf NonDet = 'DynamicDefined in effectful-core-2.3.0.1 · Effectful.Internal.Monad
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Moduleeffectful-core-2.3.0.1Haskell2010
Provider of the Alternative and MonadPlus instance for Eff.
Provide the ability to use the Alternative and MonadPlus instance for Eff.
type DispatchOf NonDet = 'DynamicDefined in effectful-core-2.3.0.1 · Effectful.Internal.MonadPolicy of dealing with modifications to thread local state in the environment in branches that end up calling the Empty operation.
Note: OnEmptyKeep is significantly faster as there is no need to back up the environment on each call to :<|>:.
OnEmptyKeepKeep modifications on Empty.
OnEmptyRollbackRollback modifications on Empty.
Eq OnEmptyPolicyDefined in effectful-core-2.3.0.1 · Effectful.NonDetOrd OnEmptyPolicyDefined in effectful-core-2.3.0.1 · Effectful.NonDetShow OnEmptyPolicyDefined in effectful-core-2.3.0.1 · Effectful.NonDetGeneric OnEmptyPolicyDefined in effectful-core-2.3.0.1 · Effectful.NonDettype Rep OnEmptyPolicy = D1 ('MetaData "OnEmptyPolicy"
"Effectful.NonDet"
"effectful-core-2.3.0.1-IucZ9sUkkbkINh7e4sx1Ot"
'False) (C1 ('MetaCons "OnEmptyKeep"
'PrefixI 'False) U1 :+: C1 ('MetaCons "OnEmptyRollback"
'PrefixI 'False) U1)Defined in effectful-core-2.3.0.1 · Effectful.NonDetRun the NonDet effect with a given OnEmptyPolicy.
Note: :<|>: executes the second computation if (and only if) the first computation calls Empty.
Specialized version of empty with the HasCallStack constraint for tracking purposes.
Specialized version of asum with the HasCallStack constraint for tracking purposes.
A monoid on applicative functors.
If defined, some and many should be the least solutions of the equations:
Nothing <|> Just 42Just 42
[1, 2] <|> [3, 4][1,2,3,4]
empty <|> print (2^15)32768
empty :: f aThe identity of <|>
empty <|> a == a
a <|> empty == a(<|>) :: f a -> f a -> f ainfixl 3An associative binary operation
some :: f a -> f [a]One or more.
some (putStr "la")lalalalalalalalala... * goes on forever *
some Nothingnothing
take 5 <$> some (Just 1)* hangs forever *
Note that this function can be used with Parsers based on
Applicatives. In that case some parser will attempt to
parse parser one or more times until it fails.
many :: f a -> f [a]Zero or more.
many (putStr "la")lalalalalalalalala... * goes on forever *
many NothingJust []
take 5 <$> many (Just 1)* hangs forever *
Note that this function can be used with Parsers based on
Applicatives. In that case many parser will attempt to
parse parser zero or more times until it fails.
Alternative SeqDefined in containers-0.7 · Data.Sequence.InternalAlternative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.SyncAlternative ZipListDefined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListAlternative MaybeDefined in ghc-internal-9.1003.0 · GHC.Internal.BaseAlternative PDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPAlternative ReadPDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPAlternative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecAlternative IODefined in ghc-internal-9.1003.0 · GHC.Internal.BaseAlternative ArrayDefined in primitive-0.9.1.0 · Data.Primitive.ArrayAlternative SmallArrayDefined in primitive-0.9.1.0 · Data.Primitive.SmallArrayAlternative []Defined in ghc-internal-9.1003.0 · GHC.Internal.BaseCombines lists by concatenation, starting from the empty list.
NonDet :> es => Alternative (Eff es)Defined in effectful-core-2.3.0.1 · Effectful.Internal.MonadAlternative ProxyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyAlternative U1Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative f => Alternative (Lift f)Defined in transformers-0.6.1.1 · Control.Applicative.LiftA combination is Pure only either part is.
Monad m => Alternative (CatchT m)Defined in exceptions-0.10.9 · Control.Monad.Catch.PureMonadPlus m => Alternative (WrappedMonad m)Defined in base-4.20.2.0 · Control.ApplicativeArrowPlus a => Alternative (ArrowMonad a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.Arrow(Functor m, Monad m) => Alternative (MaybeT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.MaybeAlternative f => Alternative (Ap f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidAlternative f => Alternative (Alt f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalAlternative f => Alternative (Rec1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative f => Alternative (Backwards f)Defined in transformers-0.6.1.1 · Control.Applicative.BackwardsTry alternatives in the same order as f.
Alternative f => Alternative (Reverse f)Defined in transformers-0.6.1.1 · Data.Functor.ReverseDerived instance.
Alternative m => Alternative (Kleisli m a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.ArrowAlternative m => Alternative (IdentityT m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.IdentityAlternative m => Alternative (ReaderT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Reader(Functor m, Monad m, Monoid e) => Alternative (ExceptT e m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except(Functor m, MonadPlus m) => Alternative (SelectT r m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Select(Functor m, MonadPlus m) => Alternative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Lazy(Functor m, MonadPlus m) => Alternative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict(Functor m, MonadPlus m) => Alternative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.CPS(Monoid w, Alternative m) => Alternative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy(Monoid w, Alternative m) => Alternative (WriterT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict(Monoid w, Functor m, MonadPlus m) => Alternative (AccumT w m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Accum(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b)Defined in base-4.20.2.0 · Control.Applicative(Generic1 f, Alternative (Rep1 f)) => Alternative (Generically1 f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Alternative f, Alternative g) => Alternative (Product f g)Defined in base-4.20.2.0 · Data.Functor.Product(Alternative f, Alternative g) => Alternative (f :*: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsAlternative f => Alternative (M1 i c f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Alternative f, Applicative g) => Alternative (Compose f g)Defined in base-4.20.2.0 · Data.Functor.Compose(Alternative f, Applicative g) => Alternative (f :.: g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Functor m, MonadPlus m) => Alternative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.CPS(Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.Lazy(Monoid w, Functor m, MonadPlus m) => Alternative (RWST r w s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.RWS.StrictRequest a CallStack.
NOTE: The implicit parameter ?callStack :: CallStack is an
implementation detail and should not be considered part of the
CallStack API, we may decide to change the implementation in the
future.
CallStacks are a lightweight method of obtaining a partial call-stack at any point in the program.
A function can request its call-site with the HasCallStack constraint. For example, we can define
putStrLnWithCallStack :: HasCallStack => String -> IO ()
as a variant of putStrLn that will get its call-site and print it,
along with the string given as argument. We can access the
call-stack inside putStrLnWithCallStack with callStack.
:{putStrLnWithCallStack :: HasCallStack => String -> IO ()putStrLnWithCallStack msg = do putStrLn msg putStrLn (prettyCallStack callStack):}
Thus, if we call putStrLnWithCallStack we will get a formatted call-stack
alongside our string.
putStrLnWithCallStack "hello"helloCallStack (from HasCallStack): putStrLnWithCallStack, called at <interactive>:... in interactive:Ghci...
GHC solves HasCallStack constraints in three steps:
If there is a CallStack in scope -- i.e. the enclosing function has a HasCallStack constraint -- GHC will append the new call-site to the existing CallStack.
If there is no CallStack in scope -- e.g. in the GHCi session above -- and the enclosing definition does not have an explicit type signature, GHC will infer a HasCallStack constraint for the enclosing definition (subject to the monomorphism restriction).
If there is no CallStack in scope and the enclosing definition has an explicit type signature, GHC will solve the HasCallStack constraint for the singleton CallStack containing just the current call-site.
CallStacks do not interact with the RTS and do not require compilation
with -prof. On the other hand, as they are built up explicitly via the
HasCallStack constraints, they will generally not contain as much
information as the simulated call-stacks maintained by the RTS.
A CallStack is a [(String, SrcLoc)]. The String is the name of
function that was called, the SrcLoc is the call-site. The list is
ordered with the most recently called function at the head.
NOTE: The intrepid user may notice that HasCallStack is just an
alias for an implicit parameter ?callStack :: CallStack. This is an
implementation detail and should not be considered part of the
CallStack API, we may decide to change the implementation in the
future.
Extract a list of call-sites from the CallStack.
The list is ordered by most recent call.
Pretty print a CallStack.