type-map-0.1.6.0: Type-indexed maps

Safe Haskell None Haskell2010

Data.TypeMap.Internal.Unsafe

Synopsis

# Documentation

type family Init (d :: [k]) where ... Source #

All elements except the last one.

Equations

 Init (_ ': '[]) = '[] Init (x ': d) = x ': Init d

type family Last (d :: [k]) where ... Source #

Last element of a list.

Equations

 Last (x ': '[]) = x Last (_ ': d) = Last d

type family Snoc (d :: [k]) (a :: k) where ... Source #

Append a type to a list.

Equations

 Snoc '[] a = '[a] Snoc (x ': d) a = x ': Snoc d a

type family Lookup (a :: k) (d :: [(k, *)]) where ... Source #

Type associated with a in d. If the key a occurs multiple times, the first one is used.

Equations

 Lookup a ('(a, b) ': _) = b Lookup a (_ ': d) = Lookup a d

type family Index (a :: k) (d :: [(k, *)]) where ... Source #

Index of type key a in association list d.

Equations

 Index a ('(a, _) ': _) = 0 Index a (_ ': d) = 1 + Index a d

unsafeIndex :: forall a d f m. (KnownNat (Index a d), Coercible (f Any) (m d)) => (forall c. f c -> Int -> c) -> m d -> Lookup a d Source #

Helper to define index functions.

unsafeCons :: forall a d b f m. (Coercible (f Any) (m d), Coercible (f Any) (m ('(a, b) ': d))) => (forall c. c -> f c -> f c) -> b -> m d -> m ('(a, b) ': d) Source #

Helper to define cons functions.

unsafeSnoc :: forall a d b f m. (Last d ~ '(a, b), Coercible (f Any) (m (Init d)), Coercible (f Any) (m d)) => (forall c. f c -> c -> f c) -> m (Init d) -> b -> m d Source #

Helper to define snoc functions.

class KnownNat (n :: Nat) #

This class gives the integer associated with a type-level natural. There are instances of the class for every concrete literal: 0, 1, 2, etc.

Since: base-4.7.0.0

Minimal complete definition

natSing

type family Any :: k0 where ... #

The type constructor Any is type to which you can unsafely coerce any lifted type, and back. More concretely, for a lifted type t and value x :: t, -- unsafeCoerce (unsafeCoerce x :: Any) :: t is equivalent to x.

unsafeCoerce :: a -> b #

data Proxy (t :: k) :: forall k. k -> Type #

Proxy is a type that holds no data, but has a phantom parameter of arbitrary type (or even kind). Its use is to provide type information, even though there is no value available of that type (or it may be too costly to create one).

Historically, Proxy :: Proxy a is a safer alternative to the 'undefined :: a' idiom.

>>> Proxy :: Proxy (Void, Int -> Int)
Proxy


Proxy can even hold types of higher kinds,

>>> Proxy :: Proxy Either
Proxy

>>> Proxy :: Proxy Functor
Proxy

>>> Proxy :: Proxy complicatedStructure
Proxy


Constructors

 Proxy
Instances
 Monad (Proxy :: Type -> Type) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methods(>>=) :: Proxy a -> (a -> Proxy b) -> Proxy b #(>>) :: Proxy a -> Proxy b -> Proxy b #return :: a -> Proxy a #fail :: String -> Proxy a # Functor (Proxy :: Type -> Type) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodsfmap :: (a -> b) -> Proxy a -> Proxy b #(<\$) :: a -> Proxy b -> Proxy a # Applicative (Proxy :: Type -> Type) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodspure :: a -> Proxy a #(<*>) :: Proxy (a -> b) -> Proxy a -> Proxy b #liftA2 :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c #(*>) :: Proxy a -> Proxy b -> Proxy b #(<*) :: Proxy a -> Proxy b -> Proxy a # Foldable (Proxy :: Type -> Type) Since: base-4.7.0.0 Instance detailsDefined in Data.Foldable Methodsfold :: Monoid m => Proxy m -> m #foldMap :: Monoid m => (a -> m) -> Proxy a -> m #foldr :: (a -> b -> b) -> b -> Proxy a -> b #foldr' :: (a -> b -> b) -> b -> Proxy a -> b #foldl :: (b -> a -> b) -> b -> Proxy a -> b #foldl' :: (b -> a -> b) -> b -> Proxy a -> b #foldr1 :: (a -> a -> a) -> Proxy a -> a #foldl1 :: (a -> a -> a) -> Proxy a -> a #toList :: Proxy a -> [a] #null :: Proxy a -> Bool #length :: Proxy a -> Int #elem :: Eq a => a -> Proxy a -> Bool #maximum :: Ord a => Proxy a -> a #minimum :: Ord a => Proxy a -> a #sum :: Num a => Proxy a -> a #product :: Num a => Proxy a -> a # Traversable (Proxy :: Type -> Type) Since: base-4.7.0.0 Instance detailsDefined in Data.Traversable Methodstraverse :: Applicative f => (a -> f b) -> Proxy a -> f (Proxy b) #sequenceA :: Applicative f => Proxy (f a) -> f (Proxy a) #mapM :: Monad m => (a -> m b) -> Proxy a -> m (Proxy b) #sequence :: Monad m => Proxy (m a) -> m (Proxy a) # Alternative (Proxy :: Type -> Type) Since: base-4.9.0.0 Instance detailsDefined in Data.Proxy Methodsempty :: Proxy a #(<|>) :: Proxy a -> Proxy a -> Proxy a #some :: Proxy a -> Proxy [a] #many :: Proxy a -> Proxy [a] # MonadPlus (Proxy :: Type -> Type) Since: base-4.9.0.0 Instance detailsDefined in Data.Proxy Methodsmzero :: Proxy a #mplus :: Proxy a -> Proxy a -> Proxy a # Bounded (Proxy t) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methods Enum (Proxy s) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodssucc :: Proxy s -> Proxy s #pred :: Proxy s -> Proxy s #toEnum :: Int -> Proxy s #fromEnum :: Proxy s -> Int #enumFrom :: Proxy s -> [Proxy s] #enumFromThen :: Proxy s -> Proxy s -> [Proxy s] #enumFromTo :: Proxy s -> Proxy s -> [Proxy s] #enumFromThenTo :: Proxy s -> Proxy s -> Proxy s -> [Proxy s] # Eq (Proxy s) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methods(==) :: Proxy s -> Proxy s -> Bool #(/=) :: Proxy s -> Proxy s -> Bool # Ord (Proxy s) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodscompare :: Proxy s -> Proxy s -> Ordering #(<) :: Proxy s -> Proxy s -> Bool #(<=) :: Proxy s -> Proxy s -> Bool #(>) :: Proxy s -> Proxy s -> Bool #(>=) :: Proxy s -> Proxy s -> Bool #max :: Proxy s -> Proxy s -> Proxy s #min :: Proxy s -> Proxy s -> Proxy s # Read (Proxy t) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy MethodsreadsPrec :: Int -> ReadS (Proxy t) #readList :: ReadS [Proxy t] # Show (Proxy s) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy MethodsshowsPrec :: Int -> Proxy s -> ShowS #show :: Proxy s -> String #showList :: [Proxy s] -> ShowS # Ix (Proxy s) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodsrange :: (Proxy s, Proxy s) -> [Proxy s] #index :: (Proxy s, Proxy s) -> Proxy s -> Int #unsafeIndex :: (Proxy s, Proxy s) -> Proxy s -> IntinRange :: (Proxy s, Proxy s) -> Proxy s -> Bool #rangeSize :: (Proxy s, Proxy s) -> Int #unsafeRangeSize :: (Proxy s, Proxy s) -> Int Since: base-4.9.0.0 Instance detailsDefined in Data.Proxy Methods(<>) :: Proxy s -> Proxy s -> Proxy s #sconcat :: NonEmpty (Proxy s) -> Proxy s #stimes :: Integral b => b -> Proxy s -> Proxy s # Monoid (Proxy s) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methodsmempty :: Proxy s #mappend :: Proxy s -> Proxy s -> Proxy s #mconcat :: [Proxy s] -> Proxy s #