HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduletagged-0.8.11Haskell98

Data.Tagged

Contents
  1. Tagged values
  2. Conversion
  3. Proxy methods GHC dropped
Synopsis
  • Packagetagged-0.8.11
  • Exports11
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceTagged.hs

Tagged values

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

Proxy methods GHC dropped

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