HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulewizards-1.0.3Haskell98

System.Console.Wizard

  • 10 types
  • 1 class
  • 18 values
  • Packagewizards-1.0.3
  • Exports29
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceInternal.hs

Wizards

5 declarations
newtypenewtype Wizard (backend :: Type -> Type) a
#

A Wizard b a is a conversation with the user via back-end b that will result in a data type a, or may fail. A Wizard is made up of one or more "primitives" (see below), composed using the Applicative, Monad and Alternative instances. The Alternative instance is, as you might expect, a maybe-style cascade. If the first wizard fails, the next one is tried. mzero can be used to induce failure directly.

The Wizard constructor is exported here for use when developing backends, but it is better for end-users to simply pretend that Wizard is an opaque data type. Don't depend on this unless you have no other choice.

Wizards are, internally, just a maybe transformer over a free monad built from some coproduct of functors, each of which is a primitive action.

Constructors

Instances6Monad, Functor, Applicative, Alternative, MonadPlus, MonadIO
classclass (Functor sub, Functor sup) => (:<:) (sub :: Type -> Type) (sup :: Type -> Type) where
#

Subsumption of two functors. You shouldn't define any of your own instances of this when writing back-ends, rely only on GeneralizedNewtypeDeriving.

Instances20:<:, …
datadata (:+:) (f :: Type -> Type) (g :: Type -> Type) w
#

Coproduct of two functors

Instances4:<:, Run, Functor

Primitives

13 declarations

Primitives are the basic building blocks for wizards. Use these functions to produce wizards that ask for input from the user, or output information.

datadata Line w
#
Instances7Functor, :<:, Run, …
  • Functor LineDefined in wizards-1.0.3 · System.Console.Wizard.Internal
  • Line :<: BasicIODefined in wizards-1.0.3 · System.Console.Wizard.BasicIO
  • Line :<: HaskelineDefined in wizards-1.0.3 · System.Console.Wizard.Haskeline
  • Line :<: PureDefined in wizards-1.0.3 · System.Console.Wizard.Pure
  • Run IO LineDefined in wizards-1.0.3 · System.Console.Wizard.BasicIO · orphan
  • Run (InputT IO) LineDefined in wizards-1.0.3 · System.Console.Wizard.Haskeline · orphan
  • Run (State PureState) LineDefined in wizards-1.0.3 · System.Console.Wizard.Pure · orphan
datadata Character w
#
Instances7Functor, :<:, Run, …
datadata Output w
#
Instances7Functor, :<:, Run, …
  • Functor OutputDefined in wizards-1.0.3 · System.Console.Wizard.Internal
  • Output :<: BasicIODefined in wizards-1.0.3 · System.Console.Wizard.BasicIO
  • Output :<: HaskelineDefined in wizards-1.0.3 · System.Console.Wizard.Haskeline
  • Output :<: PureDefined in wizards-1.0.3 · System.Console.Wizard.Pure
  • Run IO OutputDefined in wizards-1.0.3 · System.Console.Wizard.BasicIO · orphan
  • Run (InputT IO) OutputDefined in wizards-1.0.3 · System.Console.Wizard.Haskeline · orphan
  • Run (State PureState) OutputDefined in wizards-1.0.3 · System.Console.Wizard.Pure · orphan
datadata OutputLn w
#
Instances7Functor, :<:, Run, …

Modifiers

5 declarations

Modifiers change the behaviour of existing wizards.

valueretry :: Functor b => Wizard b a -> Wizard b a
#

Retry produces a wizard that will retry the entire conversation again if it fails. It is simply retry x = x <|> retry x.

valuevalidator :: Functor b => (a -> Bool) -> Wizard b a -> Wizard b a
#

validator p causes a wizard to fail if the output value does not satisfy the predicate p.

Convenience

3 declarations
valuenonEmpty :: Functor b => Wizard b [a] -> Wizard b [a]
#

Simply validator (not . null), makes a wizard fail if it gets an empty string.

valueinRange :: (Ord a, Functor b) => (a, a) -> Wizard b a -> Wizard b a
#

Makes a wizard fail if it gets an ordered quantity outside of the given range.

Utility

3 declarations
valueensure :: (a -> Bool) -> a -> Maybe a
#

Ensures that a maybe value satisfies a given predicate.

Orphan instances

1 instance