tagged-0.6: Haskell 98 phantom types to avoid unsafely passing dummy arguments

Portabilityportable
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellNone

Data.Proxy

Contents

Description

 

Synopsis

Tagged values

data Proxy s Source

Constructors

Proxy 

Instances

Monad (Proxy *) 
Functor (Proxy *) 
Typeable1 (Proxy *) 
Applicative (Proxy *) 
Foldable (Proxy *) 
Traversable (Proxy *) 
Bounded (Proxy k s) 
Enum (Proxy k s) 
Eq (Proxy k s) 
Data s => Data (Proxy * s) 
Ord (Proxy k s) 
Read (Proxy k s) 
Show (Proxy k s) 
Ix (Proxy k s) 
Monoid (Proxy k s) 

reproxy :: Proxy s -> Proxy tSource

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

asProxyTypeOf :: a -> Proxy a -> aSource

asProxyTypeOf 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 :: Tagged s a -> Proxy s -> aSource

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

unproxy :: (Proxy s -> a) -> Tagged s aSource

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