Copyright | 2009-2015 Edward Kmett |
---|---|
License | BSD3 |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
- newtype Tagged s b = Tagged {
- unTagged :: b
- retag :: Tagged s b -> Tagged t b
- untag :: Tagged s b -> b
- tagSelf :: a -> Tagged a a
- untagSelf :: Tagged a a -> a
- asTaggedTypeOf :: s -> tagged s b -> s
- witness :: Tagged a b -> a -> b
- proxy :: Tagged s a -> proxy s -> a
- unproxy :: (Proxy s -> a) -> Tagged s a
- tagWith :: proxy s -> a -> Tagged s a
- reproxy :: proxy a -> Proxy b
Tagged values
A
value is a value Tagged
s bb
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
can't try to use the argument Tagged
s bs
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.
Bifunctor (Tagged *) Source | |
Monad (Tagged k s) Source | |
Functor (Tagged k s) Source | |
Applicative (Tagged k s) Source | |
Foldable (Tagged k s) Source | |
Traversable (Tagged k s) Source | |
Generic1 (Tagged k s) Source | |
Bounded b => Bounded (Tagged k s b) Source | |
Enum a => Enum (Tagged k s a) Source | |
Eq b => Eq (Tagged k s b) Source | |
Floating a => Floating (Tagged k s a) Source | |
Fractional a => Fractional (Tagged k s a) Source | |
Integral a => Integral (Tagged k s a) Source | |
(Data s, Data b) => Data (Tagged * s b) Source | |
Num a => Num (Tagged k s a) Source | |
Ord b => Ord (Tagged k s b) Source | |
Read b => Read (Tagged k s b) Source | |
Real a => Real (Tagged k s a) Source | |
RealFloat a => RealFloat (Tagged k s a) Source | |
RealFrac a => RealFrac (Tagged k s a) Source | |
Show b => Show (Tagged k s b) Source | |
Ix b => Ix (Tagged k s b) Source | |
Generic (Tagged k s b) Source | |
Monoid a => Monoid (Tagged k s a) Source | |
NFData b => NFData (Tagged k s b) Source | |
type Rep1 (Tagged k s) Source | |
type Rep (Tagged k s b) Source |
asTaggedTypeOf :: s -> tagged s b -> s Source
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.