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

Moduletagged-0.8.9Haskell98

Data.Tagged

  • 1 type
  • 10 values
  • Packagetagged-0.8.9
  • Exports11
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceTagged.hs

Tagged values

7 declarations
newtypenewtype Tagged (s :: k) b
#

A Tagged s b value is a value b with an attached phantom type s. This can be used in place of the more traditional but less safe idiom of passing in an undefined value with the type, because unlike an (s -> b), a Tagged s b can't try to use the argument s as a real value.

Moreover, you don't have to rely on the compiler to inline away the extra argument, because the newtype is "free"

Tagged has kind k -> * -> * if the compiler supports PolyKinds, therefore there is an extra k showing in the instance haddocks that may cause confusion.

Constructors

Instances44Generic1, Bifoldable, Bifoldable1, Bifunctor, Bitraversable, Eq2, …
valueretag :: Tagged s b -> Tagged t b
#

Some times you need to change the tag you have lying around. Idiomatic usage is to make a new combinator for the relationship between the tags that you want to enforce, and define that combinator using retag.

data Succ n
retagSucc :: Tagged n a -> Tagged (Succ n) a
retagSucc = retag
valueasTaggedTypeOf :: s -> tagged s b -> s
#

asTaggedTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the tag of the second.

Conversion

3 declarations
valueproxy :: Tagged s a -> proxy s -> a
#

Convert from a Tagged representation to a representation based on a Proxy.

valuetagWith :: proxy s -> a -> Tagged s a
#

Another way to convert a proxy to a tag.

Proxy methods GHC dropped

1 declaration
valuereproxy :: proxy a -> Proxy b
#

Some times you need to change the proxy you have lying around. Idiomatic usage is to make a new combinator for the relationship between the proxies that you want to enforce, and define that combinator using reproxy.

data Succ n
reproxySucc :: proxy n -> Proxy (Succ n)
reproxySucc = reproxy