type-spec-0.1.0.0: Type Level Specification by Example

Safe HaskellNone
LanguageHaskell2010

Test.TypeSpec.Internal.Apply

Description

Useful abstractions for type level programming using. This reimplements parts of the singletons library, which is just too heavy of a dependency to carry around, when only three small types are used of it.

Synopsis

Documentation

type family (ma :: monad a) >>= (f :: TyFunData (a :: Type) (monad b :: Type)) :: monad b Source #

Bind to actions.

Instances

type (>>=) b (Either a1) a (Left a1 a b1) f Source # 
type (>>=) b (Either a1) a (Left a1 a b1) f = Left a1 b b1
type (>>=) b (Either a) a1 (Right a a1 a2) f Source # 
type (>>=) b (Either a) a1 (Right a a1 a2) f = Apply a1 (Either a b) f a2

type (>>) ma mb = ma >>= Const' mb Source #

Execute one action and then the next, ignore the result of the first.

type family (f :: m (a ~> b)) <*> (ma :: m a) :: m b where ... Source #

Execute an action that returns a function than map function over the result of the next action.

Equations

mf <*> mx = mf >>= Apply (Flip (<$>$$)) mx 

data (<$>$$) :: (a ~> b) ~> (m a ~> m b) Source #

Execute an action and map a pure function over the result.

Instances

type Apply ((~>) a b) ((~>) (m a) (m b)) ((<$>$$) a b m) f Source # 
type Apply ((~>) a b) ((~>) (m a) (m b)) ((<$>$$) a b m) f = (<$>$) a b m f

data (<$>$) :: (a ~> b) -> m a ~> m b Source #

Instances

type Apply (m a) (m b) ((<$>$) a b m f) x Source # 
type Apply (m a) (m b) ((<$>$) a b m f) x = (<$>) m a b f x

type family (f :: a ~> b) <$> (ma :: m a) :: m b Source #

Instances

type (<$>) (Either a1) a b f (Left a1 a a2) Source # 
type (<$>) (Either a1) a b f (Left a1 a a2) = Left a1 b a2
type (<$>) (Either a) a1 b f (Right a a1 a2) Source # 
type (<$>) (Either a) a1 b f (Right a a1 a2) = Right a b (Apply a1 b f a2)

data TyCon1 :: (a -> b) -> a ~> b Source #

Convert data types to Partially applicable type functions

Instances

type Apply a b (TyCon1 a b f) x Source # 
type Apply a b (TyCon1 a b f) x = f x

data TyCon2 :: (a -> b -> c) -> a ~> (b ~> c) Source #

Instances

type Apply a ((~>) a1 b) (TyCon2 a a1 b f) x Source # 
type Apply a ((~>) a1 b) (TyCon2 a a1 b f) x = TyCon1 a1 b (f x)

type family Apply (f :: a ~> b) (x :: a) :: b Source #

Instances

type Apply t' t (Const' t t' a) b Source # 
type Apply t' t (Const' t t' a) b = Const t' t a b
type Apply a b (TyCon1 a b f) x Source # 
type Apply a b (TyCon1 a b f) x = f x
type Apply a c (Compose b c a f g) x Source # 
type Apply a c (Compose b c a f g) x = Compose_ a b c f g x
type Apply a c (Flip_ a b c f y) x Source # 
type Apply a c (Flip_ a b c f y) x = Flip__ a b c f y x
type Apply a ((~>) [a] [a]) (Cons'' a) x Source # 
type Apply a ((~>) [a] [a]) (Cons'' a) x = Cons' a x
type Apply a (TyFunData b a) (Const'' a b) a1 Source # 
type Apply a (TyFunData b a) (Const'' a b) a1 = Const' a b a1
type Apply a ((~>) b (a, b)) (Pair'' a b) x Source # 
type Apply a ((~>) b (a, b)) (Pair'' a b) x = Pair' a b x
type Apply k1 (k, k1) (Pair' k k1 x) y Source # 
type Apply k1 (k, k1) (Pair' k k1 x) y = (,) k k1 x y
type Apply b ((~>) a c) (Flip a b c f) y Source # 
type Apply b ((~>) a c) (Flip a b c f) y = Flip_ a b c f y
type Apply a ((~>) a1 b) (TyCon2 a a1 b f) x Source # 
type Apply a ((~>) a1 b) (TyCon2 a a1 b f) x = TyCon1 a1 b (f x)
type Apply [a] [a] (Cons' a x) xs Source # 
type Apply [a] [a] (Cons' a x) xs = (:) a x xs
type Apply (m a) (m b) ((<$>$) a b m f) x Source # 
type Apply (m a) (m b) ((<$>$) a b m f) x = (<$>) m a b f x
type Apply ((~>) b c) ((~>) ((~>) a b) ((~>) a c)) (Compose'' b c a) f Source # 
type Apply ((~>) b c) ((~>) ((~>) a b) ((~>) a c)) (Compose'' b c a) f = Compose' b c a f
type Apply ((~>) a ((~>) b c)) ((~>) b ((~>) a c)) (Flip' a b c) f Source # 
type Apply ((~>) a ((~>) b c)) ((~>) b ((~>) a c)) (Flip' a b c) f = Flip a b c f
type Apply ((~>) a b) ((~>) (m a) (m b)) ((<$>$$) a b m) f Source # 
type Apply ((~>) a b) ((~>) (m a) (m b)) ((<$>$$) a b m) f = (<$>$) a b m f
type Apply ((~>) a b) ((~>) a c) (Compose' b c a f) g Source # 
type Apply ((~>) a b) ((~>) a c) (Compose' b c a f) g = Compose b c a f g

data TyFun :: Type -> Type -> Type Source #

Instances

type Apply a ((~>) [a] [a]) (Cons'' a) x Source # 
type Apply a ((~>) [a] [a]) (Cons'' a) x = Cons' a x
type Apply a (TyFunData b a) (Const'' a b) a1 Source # 
type Apply a (TyFunData b a) (Const'' a b) a1 = Const' a b a1
type Apply a ((~>) b (a, b)) (Pair'' a b) x Source # 
type Apply a ((~>) b (a, b)) (Pair'' a b) x = Pair' a b x
type Apply b ((~>) a c) (Flip a b c f) y Source # 
type Apply b ((~>) a c) (Flip a b c f) y = Flip_ a b c f y
type Apply a ((~>) a1 b) (TyCon2 a a1 b f) x Source # 
type Apply a ((~>) a1 b) (TyCon2 a a1 b f) x = TyCon1 a1 b (f x)
type Apply ((~>) b c) ((~>) ((~>) a b) ((~>) a c)) (Compose'' b c a) f Source # 
type Apply ((~>) b c) ((~>) ((~>) a b) ((~>) a c)) (Compose'' b c a) f = Compose' b c a f
type Apply ((~>) a ((~>) b c)) ((~>) b ((~>) a c)) (Flip' a b c) f Source # 
type Apply ((~>) a ((~>) b c)) ((~>) b ((~>) a c)) (Flip' a b c) f = Flip a b c f
type Apply ((~>) a b) ((~>) (m a) (m b)) ((<$>$$) a b m) f Source # 
type Apply ((~>) a b) ((~>) (m a) (m b)) ((<$>$$) a b m) f = (<$>$) a b m f
type Apply ((~>) a b) ((~>) a c) (Compose' b c a f) g Source # 
type Apply ((~>) a b) ((~>) a c) (Compose' b c a f) g = Compose b c a f g

type TyFunData a b = TyFun a b -> Type Source #

type (~>) a b = TyFun a b -> Type infixr 0 Source #

data Cons'' :: a ~> ([a] ~> [a]) Source #

List construction

Instances

type Apply a ((~>) [a] [a]) (Cons'' a) x Source # 
type Apply a ((~>) [a] [a]) (Cons'' a) x = Cons' a x

data Cons' :: a -> [a] ~> [a] Source #

Instances

type Apply [a] [a] (Cons' a x) xs Source # 
type Apply [a] [a] (Cons' a x) xs = (:) a x xs

data Pair'' :: a ~> (b ~> (a, b)) Source #

Tuple construction

Instances

type Apply a ((~>) b (a, b)) (Pair'' a b) x Source # 
type Apply a ((~>) b (a, b)) (Pair'' a b) x = Pair' a b x

data Pair' :: a -> b ~> (a, b) Source #

Instances

type Apply k1 (k, k1) (Pair' k k1 x) y Source # 
type Apply k1 (k, k1) (Pair' k k1 x) y = (,) k k1 x y

type family Const (a :: t) (b :: t') :: t where ... Source #

Equations

Const a b = a 

data Const' :: a -> TyFunData b a Source #

Instances

type Apply t' t (Const' t t' a) b Source # 
type Apply t' t (Const' t t' a) b = Const t' t a b

data Const'' :: TyFunData a (TyFunData b a) Source #

Instances

type Apply a (TyFunData b a) (Const'' a b) a1 Source # 
type Apply a (TyFunData b a) (Const'' a b) a1 = Const' a b a1

data Flip' :: (a ~> (b ~> c)) ~> (b ~> (a ~> c)) Source #

Instances

type Apply ((~>) a ((~>) b c)) ((~>) b ((~>) a c)) (Flip' a b c) f Source # 
type Apply ((~>) a ((~>) b c)) ((~>) b ((~>) a c)) (Flip' a b c) f = Flip a b c f

data Flip :: (a ~> (b ~> c)) -> b ~> (a ~> c) Source #

Instances

type Apply b ((~>) a c) (Flip a b c f) y Source # 
type Apply b ((~>) a c) (Flip a b c f) y = Flip_ a b c f y

data Flip_ :: (a ~> (b ~> c)) -> b -> a ~> c Source #

Instances

type Apply a c (Flip_ a b c f y) x Source # 
type Apply a c (Flip_ a b c f y) x = Flip__ a b c f y x

type family Flip__ (f :: a ~> (b ~> c)) (y :: b) (x :: a) :: c where ... Source #

Equations

Flip__ f y x = Apply (Apply f x) y 

data Compose'' :: (b ~> c) ~> ((a ~> b) ~> (a ~> c)) Source #

Instances

type Apply ((~>) b c) ((~>) ((~>) a b) ((~>) a c)) (Compose'' b c a) f Source # 
type Apply ((~>) b c) ((~>) ((~>) a b) ((~>) a c)) (Compose'' b c a) f = Compose' b c a f

data Compose' :: (b ~> c) -> (a ~> b) ~> (a ~> c) Source #

Instances

type Apply ((~>) a b) ((~>) a c) (Compose' b c a f) g Source # 
type Apply ((~>) a b) ((~>) a c) (Compose' b c a f) g = Compose b c a f g

data Compose :: (b ~> c) -> (a ~> b) -> a ~> c Source #

Instances

type Apply a c (Compose b c a f g) x Source # 
type Apply a c (Compose b c a f g) x = Compose_ a b c f g x

type family Compose_ (f :: b ~> c) (g :: a ~> b) (x :: a) :: c where ... Source #

Equations

Compose_ f g x = Apply f (Apply g x)