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

Modulecmdargs-0.10.22Haskell2010

System.Console.CmdArgs.Annotate

This module captures annotations on a value, and builds a Capture value. This module has two ways of writing annotations:

Impure: The impure method of writing annotations is susceptible to over-optimisation by GHC - sometimes {-# OPTIONS_GHC -fno-cse #-} will be required.

Pure: The pure method is more verbose, and lacks some type safety.

As an example of the two styles:

data Foo = Foo {foo :: Int, bar :: Int}
 impure = capture $ Foo {foo = 12, bar = many [1 &= "inner", 2]} &= "top"
 pure = capture_ $ record Foo{} [foo := 12, bar :=+ [atom 1 += "inner", atom 2]] += "top"

Both evaluate to:

Capture (Ann "top") (Ctor (Foo 12 1) [Value 12, Many [Ann "inner" (Value 1), Value 2]]
  • 3 types
  • 10 values
  • Packagecmdargs-0.10.22
  • Exports13
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceAnnotate.hs

Capture framework

4 declarations
datadata Capture ann
#

The result of capturing some annotations.

Constructors

Instances2Functor, Show
  • Functor CaptureDefined in cmdargs-0.10.22 · System.Console.CmdArgs.Annotate
  • Show ann => Show (Capture ann)Defined in cmdargs-0.10.22 · System.Console.CmdArgs.Annotate
datadata Any
#

Any value, with a Data dictionary.

Constructors

Instances1Show
  • Show AnyDefined in cmdargs-0.10.22 · Data.Generics.Any

Impure

3 declarations
valuecapture :: (Data val, Data ann) => val -> Capture ann
#

Capture a value. Note that if the value is evaluated more than once the result may be different, i.e.

capture x /= capture x
valuemany :: Data val => [val] -> val
#

Collapse multiple values in to one.

value(&=) :: (Data val, Data ann) => val -> ann -> val
#

Add an annotation to a value.

It is recommended that anyone making use of this function redefine it with a more restrictive type signature to control the type of the annotation (the second argument). Any redefinitions of this function should add an INLINE pragma, to reduce the chance of incorrect optimisations.

Pure

6 declarations
valueatom :: Data val => val -> Annotate ann
#

Lift a pure value to an annotation.

valuerecord :: Data a => a -> [Annotate ann] -> Annotate ann
#

Create a constructor/record. The first argument should be the type of field, the second should be a list of fields constructed originally defined by := or :=+.

This operation is not type safe, and may raise an exception at runtime if any field has the wrong type or label.

datadata Annotate ann
#

This type represents an annotated value. The type of the underlying value is not specified.

Constructors

  • forall c f. (Data c, Data f) => (c -> f) := finfix 3

    Construct a field, fieldname := value.

  • forall c f. (Data c, Data f) => (c -> f) :=+ [Annotate ann]

    Add annotations to a field.