type-spec-0.4.0.0: Type Level Specification by Example

Safe HaskellNone
LanguageHaskell2010

Test.TypeSpec.Internal.Apply

Contents

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 :: a ~> (monad b :: Type)) :: monad b Source #

Bind to actions.

Instances
type (Left b2 :: Either a2 a1) >>= (f :: a1 ~> Either a2 b1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Either

type (Left b2 :: Either a2 a1) >>= (f :: a1 ~> Either a2 b1) = (Left b2 :: Either a2 b1)
type (Right a3 :: Either a2 a1) >>= (f :: a1 ~> Either a2 b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Either

type (Right a3 :: Either a2 a1) >>= (f :: a1 ~> Either a2 b) = Apply f a3

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 

Tuple construction

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

Instances
type Apply (Pair'' :: TyFun a (b ~> (a, b)) -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Pair'' :: TyFun a (b ~> (a, b)) -> Type) (x :: a) = (Pair' x :: TyFun b (a, b) -> Type)

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

Instances
type Apply (Pair' x :: TyFun k1 (k2, k1) -> Type) (y :: k1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Pair' x :: TyFun k1 (k2, k1) -> Type) (y :: k1) = (,) x y

List construction

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

Instances
type Apply (Cons'' :: TyFun a ([a] ~> [a]) -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Cons'' :: TyFun a ([a] ~> [a]) -> Type) (x :: a) = Cons' x

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

Instances
type Apply (Cons' x :: TyFun [a] [a] -> Type) (xs :: [a]) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Cons' x :: TyFun [a] [a] -> Type) (xs :: [a]) = x ': xs

Convert data types to Partially applicable type functions

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

Instances
type Apply (TyCon1 f :: TyFun a b -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (TyCon1 f :: TyFun a b -> Type) (x :: a) = f x

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

Instances
type Apply (TyCon2 f :: TyFun a1 (a2 ~> b) -> Type) (x :: a1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (TyCon2 f :: TyFun a1 (a2 ~> b) -> Type) (x :: a1) = TyCon1 (f x)

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

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

Instances
type Apply ((<$>$$) :: TyFun (a ~> b) (m a ~> m b) -> Type) (f :: a ~> b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply ((<$>$$) :: TyFun (a ~> b) (m a ~> m b) -> Type) (f :: a ~> b) = ((<$>$) f :: TyFun (m a) (m b) -> Type)

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

Instances
type Apply ((<$>$) f :: TyFun (m a) (m b) -> Type) (x :: m a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply ((<$>$) f :: TyFun (m a) (m b) -> Type) (x :: m a) = f <$> x

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

Instances
type (f :: a1 ~> b) <$> (Left a3 :: Either a2 a1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Either

type (f :: a1 ~> b) <$> (Left a3 :: Either a2 a1) = (Left a3 :: Either a2 b)
type (f :: a1 ~> b) <$> (Right a3 :: Either a2 a1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Either

type (f :: a1 ~> b) <$> (Right a3 :: Either a2 a1) = (Right (Apply f a3) :: Either a2 b)

Flip Type Functions

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

Instances
type Apply (Flip' :: TyFun (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Flip' :: TyFun (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) = Flip f

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

Instances
type Apply (Flip f :: TyFun b (a ~> c) -> Type) (y :: b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Flip f :: TyFun b (a ~> c) -> Type) (y :: b) = Flip_ f y

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

Instances
type Apply (Flip_ f y :: TyFun a c -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Flip_ f y :: TyFun a c -> Type) (x :: a) = Flip__ 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 

Type Function composition

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

Instances
type Apply (Compose'' :: TyFun (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Compose'' :: TyFun (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) = (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type)

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

Instances
type Apply (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type) (g :: a ~> b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type) (g :: a ~> b) = Compose f g

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

Instances
type Apply (Compose f g :: TyFun a c -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Compose f g :: TyFun a c -> Type) (x :: a) = Compose_ 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) 

Type-Level const

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

Equations

Const a b = a 

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

Instances
type Apply (Const' a :: TyFun t' t -> Type) (b :: t') Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Const' a :: TyFun t' t -> Type) (b :: t') = Const a b

data Const'' :: a ~> (b ~> a) Source #

Instances
type Apply (Const'' :: TyFun a1 (b ~> a1) -> Type) (a2 :: a1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Const'' :: TyFun a1 (b ~> a1) -> Type) (a2 :: a1) = (Const' a2 :: TyFun b a1 -> Type)

Defunctionalization

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

Instances
type Apply (Cons'' :: TyFun a ([a] ~> [a]) -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Cons'' :: TyFun a ([a] ~> [a]) -> Type) (x :: a) = Cons' x
type Apply (Const'' :: TyFun a1 (b ~> a1) -> Type) (a2 :: a1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Const'' :: TyFun a1 (b ~> a1) -> Type) (a2 :: a1) = (Const' a2 :: TyFun b a1 -> Type)
type Apply (Pair'' :: TyFun a (b ~> (a, b)) -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Pair'' :: TyFun a (b ~> (a, b)) -> Type) (x :: a) = (Pair' x :: TyFun b (a, b) -> Type)
type Apply (Flip f :: TyFun b (a ~> c) -> Type) (y :: b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Flip f :: TyFun b (a ~> c) -> Type) (y :: b) = Flip_ f y
type Apply (TyCon2 f :: TyFun a1 (a2 ~> b) -> Type) (x :: a1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (TyCon2 f :: TyFun a1 (a2 ~> b) -> Type) (x :: a1) = TyCon1 (f x)
type Apply (Flip' :: TyFun (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Flip' :: TyFun (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) = Flip f
type Apply ((<$>$$) :: TyFun (a ~> b) (m a ~> m b) -> Type) (f :: a ~> b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply ((<$>$$) :: TyFun (a ~> b) (m a ~> m b) -> Type) (f :: a ~> b) = ((<$>$) f :: TyFun (m a) (m b) -> Type)
type Apply (Compose'' :: TyFun (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Compose'' :: TyFun (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) = (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type)
type Apply (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type) (g :: a ~> b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type) (g :: a ~> b) = Compose f g

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

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

Instances
type Apply (Const' a :: TyFun t' t -> Type) (b :: t') Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Const' a :: TyFun t' t -> Type) (b :: t') = Const a b
type Apply (TyCon1 f :: TyFun a b -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (TyCon1 f :: TyFun a b -> Type) (x :: a) = f x
type Apply (Compose f g :: TyFun a c -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Compose f g :: TyFun a c -> Type) (x :: a) = Compose_ f g x
type Apply (Flip_ f y :: TyFun a c -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Flip_ f y :: TyFun a c -> Type) (x :: a) = Flip__ f y x
type Apply (Cons' x :: TyFun [a] [a] -> Type) (xs :: [a]) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Cons' x :: TyFun [a] [a] -> Type) (xs :: [a]) = x ': xs
type Apply ((<$>$) f :: TyFun (m a) (m b) -> Type) (x :: m a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply ((<$>$) f :: TyFun (m a) (m b) -> Type) (x :: m a) = f <$> x
type Apply (Cons'' :: TyFun a ([a] ~> [a]) -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Cons'' :: TyFun a ([a] ~> [a]) -> Type) (x :: a) = Cons' x
type Apply (Const'' :: TyFun a1 (b ~> a1) -> Type) (a2 :: a1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Const'' :: TyFun a1 (b ~> a1) -> Type) (a2 :: a1) = (Const' a2 :: TyFun b a1 -> Type)
type Apply (Pair'' :: TyFun a (b ~> (a, b)) -> Type) (x :: a) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Pair'' :: TyFun a (b ~> (a, b)) -> Type) (x :: a) = (Pair' x :: TyFun b (a, b) -> Type)
type Apply (Pair' x :: TyFun k1 (k2, k1) -> Type) (y :: k1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Pair' x :: TyFun k1 (k2, k1) -> Type) (y :: k1) = (,) x y
type Apply (Flip f :: TyFun b (a ~> c) -> Type) (y :: b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Flip f :: TyFun b (a ~> c) -> Type) (y :: b) = Flip_ f y
type Apply (TyCon2 f :: TyFun a1 (a2 ~> b) -> Type) (x :: a1) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (TyCon2 f :: TyFun a1 (a2 ~> b) -> Type) (x :: a1) = TyCon1 (f x)
type Apply (Flip' :: TyFun (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Flip' :: TyFun (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) = Flip f
type Apply ((<$>$$) :: TyFun (a ~> b) (m a ~> m b) -> Type) (f :: a ~> b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply ((<$>$$) :: TyFun (a ~> b) (m a ~> m b) -> Type) (f :: a ~> b) = ((<$>$) f :: TyFun (m a) (m b) -> Type)
type Apply (Compose'' :: TyFun (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Compose'' :: TyFun (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) = (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type)
type Apply (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type) (g :: a ~> b) Source # 
Instance details

Defined in Test.TypeSpec.Internal.Apply

type Apply (Compose' f :: TyFun (a ~> b) (a ~> c) -> Type) (g :: a ~> b) = Compose f g