Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
DeFun.Core
Description
Defunctorization core primitives.
Synopsis
- data FunKind a b
- type Fun a b = FunKind a b -> Type
- type (~>) a b = Fun a b
- type family App (f :: a ~> b) (x :: a) :: b
- type (@@) (a1 :: a ~> k) (b :: a) = App a1 b
- newtype Lam (a1 :: a -> Type) (b1 :: b -> Type) (f :: a ~> b) = Lam {}
- type (:~>) (a1 :: a -> Type) (b1 :: b -> Type) = Lam a1 b1
- mkLam :: forall {a1} {b1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (f :: a1 ~> b1). LamRep a2 b2 f -> Lam a2 b2 f
- type LamRep (a1 :: a -> Type) (b1 :: b -> Type) (fun :: a ~> b) = forall (x :: a). a1 x -> b1 (fun @@ x)
- (@@) :: forall {a1} {k} a2 b (f :: a1 ~> k) (x :: a1). Lam a2 b f -> a2 x -> b (f @@ x)
- type Lam2 (a2 :: a -> Type) (b1 :: a1 -> Type) (c :: b -> Type) (fun :: a ~> (a1 ~> b)) = Lam a2 (b1 :~> c) fun
- type Lam3 (a3 :: a -> Type) (b1 :: a1 -> Type) (c :: a2 -> Type) (d :: b -> Type) (fun :: a ~> (a1 ~> (a2 ~> b))) = Lam a3 (b1 :~> (c :~> d)) fun
- type LamRep2 (a1 :: a -> Type) (b1 :: b -> Type) (c1 :: c -> Type) (fun :: a ~> (b ~> c)) = forall (x :: a) (y :: b). a1 x -> b1 y -> c1 ((fun @@ x) @@ y)
- type LamRep3 (a1 :: a -> Type) (b1 :: b -> Type) (c1 :: c -> Type) (d1 :: d -> Type) (fun :: a ~> (b ~> (c ~> d))) = forall (x :: a) (y :: b) (z :: c). a1 x -> b1 y -> c1 z -> d1 (((fun @@ x) @@ y) @@ z)
- pattern Lam2 :: LamRep2 a3 b2 c fun -> Lam2 a3 b2 c fun
- pattern Lam3 :: LamRep3 a4 b2 c d fun -> Lam3 a4 b2 c d fun
- mkLam2 :: forall {a1} {a2} {b1} (a3 :: a1 -> Type) (b2 :: a2 -> Type) (c :: b1 -> Type) (fun :: a1 ~> (a2 ~> b1)). LamRep2 a3 b2 c fun -> Lam2 a3 b2 c fun
- appLam2 :: forall {a1} {b1} {c1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (c2 :: c1 -> Type) (fun :: a1 ~> (b1 ~> c1)). Lam2 a2 b2 c2 fun -> LamRep2 a2 b2 c2 fun
- mkLam3 :: forall {a1} {a2} {a3} {b1} (a4 :: a1 -> Type) (b2 :: a2 -> Type) (c :: a3 -> Type) (d :: b1 -> Type) (fun :: a1 ~> (a2 ~> (a3 ~> b1))). LamRep3 a4 b2 c d fun -> Lam3 a4 b2 c d fun
- appLam3 :: forall {a1} {b1} {c1} {d1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (c2 :: c1 -> Type) (d2 :: d1 -> Type) (fun :: a1 ~> (b1 ~> (c1 ~> d1))). Lam3 a2 b2 c2 d2 fun -> LamRep3 a2 b2 c2 d2 fun
- data Con1 (con :: a -> b) (arg :: FunKind a b)
- data Con2 (con :: a -> b -> c) (arg :: FunKind a (b ~> c))
- data Con3 (con :: a -> b -> c -> d) (arg :: FunKind a (b ~> (c ~> d)))
- con1 :: forall {a1} {b1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (con :: a1 -> b1). LamRep a2 b2 (Con1 con) -> Lam a2 b2 (Con1 con)
- con2 :: forall {a1} {b1} {c1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (c2 :: c1 -> Type) (con :: a1 -> b1 -> c1). LamRep2 a2 b2 c2 (Con2 con) -> Lam2 a2 b2 c2 (Con2 con)
- con3 :: forall {a1} {b1} {c1} {d1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (c2 :: c1 -> Type) (d2 :: d1 -> Type) (con :: a1 -> b1 -> c1 -> d1). LamRep3 a2 b2 c2 d2 (Con3 con) -> Lam3 a2 b2 c2 d2 (Con3 con)
Documentation
>>>
import Prelude (Show)
>>>
import Data.SOP.NP (NP (..))
>>>
import DeFun
FunKind
A kind for type-level functions.
Instances
type App LAndSym (x :: Bool) Source # | |
Defined in DeFun.Bool | |
type App LOrSym (x :: Bool) Source # | |
Defined in DeFun.Bool | |
type App (ConstSym :: FunKind a (b ~> a) -> Type) (x :: a) Source # | |
type App (FoldlSym1 f :: FunKind b ([a] ~> b) -> Type) (z :: b) Source # | |
type App (FoldrSym1 f :: FunKind b ([a] ~> b) -> Type) (z :: b) Source # | |
type App (Con2 f :: FunKind a1 (a2 ~> b) -> Type) (arg :: a1) Source # | |
type App (FlipSym1 f :: FunKind b (a ~> c) -> Type) (x :: b) Source # | |
type App (Con3 f :: FunKind a1 (a2 ~> (b ~> c)) -> Type) (arg :: a1) Source # | |
type App (AppendSym :: FunKind [a] ([a] ~> [a]) -> Type) (xs :: [a]) Source # | |
Defined in DeFun.List | |
type App (Map2Sym1 f :: FunKind [a] ([b] ~> [c]) -> Type) (xs :: [a]) Source # | |
type App (ZipWithSym1 f :: FunKind [a] ([b] ~> [c]) -> Type) (xs :: [a]) Source # | |
Defined in DeFun.List | |
type App (FilterSym :: FunKind (a ~> Bool) ([a] ~> [a]) -> Type) (p :: a ~> Bool) Source # | |
type App (JoinSym :: FunKind (a ~> (a ~> b)) (a ~> b) -> Type) (f :: a ~> (a ~> b)) Source # | |
type App (FoldrSym :: FunKind (a ~> (b ~> b)) (b ~> ([a] ~> b)) -> Type) (f :: a ~> (b ~> b)) Source # | |
type App (ConcatMapSym :: FunKind (a ~> [b]) ([a] ~> [b]) -> Type) (f :: a ~> [b]) Source # | |
Defined in DeFun.List type App (ConcatMapSym :: FunKind (a ~> [b]) ([a] ~> [b]) -> Type) (f :: a ~> [b]) = ConcatMapSym1 f | |
type App (MapSym :: FunKind (a ~> b) ([a] ~> [b]) -> Type) (f :: a ~> b) Source # | |
type App (FoldlSym :: FunKind (b ~> (a ~> b)) (b ~> ([a] ~> b)) -> Type) (f :: b ~> (a ~> b)) Source # | |
type App (ApSym :: FunKind (a ~> (b ~> c)) ((a ~> b) ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) Source # | |
type App (Map2Sym :: FunKind (a ~> (b ~> c)) ([a] ~> ([b] ~> [c])) -> Type) (f :: a ~> (b ~> c)) Source # | |
type App (ZipWithSym :: FunKind (a ~> (b ~> c)) ([a] ~> ([b] ~> [c])) -> Type) (f :: a ~> (b ~> c)) Source # | |
Defined in DeFun.List | |
type App (FlipSym :: FunKind (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) Source # | |
type App (CompSym :: FunKind (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) Source # | |
type App (ApSym1 f :: FunKind (a ~> b) (a ~> c) -> Type) (g :: a ~> b) Source # | |
type App (CompSym1 f :: FunKind (a ~> b) (a ~> c) -> Type) (g :: a ~> b) Source # | |
Fun
App
type family App (f :: a ~> b) (x :: a) :: b Source #
Type level function application.
Instances
type App NotSym (x :: Bool) Source # | |
Defined in DeFun.Bool | |
type App (LAndSym1 x :: FunKind Bool Bool -> Type) (y :: Bool) Source # | |
type App (LOrSym1 x :: FunKind Bool Bool -> Type) (y :: Bool) Source # | |
type App (IdSym :: FunKind a a -> Type) (x :: a) Source # | |
type App (Con1 f :: FunKind a b -> Type) (x :: a) Source # | |
Defined in DeFun.Core | |
type App (JoinSym1 f :: FunKind a b -> Type) (x :: a) Source # | |
type App (ConstSym1 x :: FunKind b a -> Type) (y :: b) Source # | |
type App (ApSym2 f g :: FunKind a c -> Type) (x :: a) Source # | |
type App (CompSym2 f g :: FunKind a c -> Type) (x :: a) Source # | |
type App (FlipSym2 f b2 :: FunKind a1 c -> Type) (a2 :: a1) Source # | |
type App LAndSym (x :: Bool) Source # | |
Defined in DeFun.Bool | |
type App LOrSym (x :: Bool) Source # | |
Defined in DeFun.Bool | |
type App (ConstSym :: FunKind a (b ~> a) -> Type) (x :: a) Source # | |
type App (FoldlSym1 f :: FunKind b ([a] ~> b) -> Type) (z :: b) Source # | |
type App (FoldrSym1 f :: FunKind b ([a] ~> b) -> Type) (z :: b) Source # | |
type App (Con2 f :: FunKind a1 (a2 ~> b) -> Type) (arg :: a1) Source # | |
type App (FlipSym1 f :: FunKind b (a ~> c) -> Type) (x :: b) Source # | |
type App (Con3 f :: FunKind a1 (a2 ~> (b ~> c)) -> Type) (arg :: a1) Source # | |
type App (FoldlSym2 f z :: FunKind [a] b -> Type) (xs :: [a]) Source # | |
type App (FoldrSym2 f z :: FunKind [a] b -> Type) (xs :: [a]) Source # | |
type App (SequenceSym :: FunKind [[a]] [[a]] -> Type) (xss :: [[a]]) Source # | |
Defined in DeFun.List | |
type App (ConcatSym :: FunKind [[a]] [a] -> Type) (xss :: [[a]]) Source # | |
type App (ReverseSym :: FunKind [a] [a] -> Type) (xs :: [a]) Source # | |
Defined in DeFun.List | |
type App (AppendSym1 xs :: FunKind [a] [a] -> Type) (ys :: [a]) Source # | |
Defined in DeFun.List | |
type App (FilterSym1 p :: FunKind [a] [a] -> Type) (xs :: [a]) Source # | |
Defined in DeFun.List | |
type App (ConcatMapSym1 f :: FunKind [a] [b] -> Type) (xs :: [a]) Source # | |
Defined in DeFun.List | |
type App (MapSym1 f :: FunKind [a] [b] -> Type) (xs :: [a]) Source # | |
type App (Map2Sym2 f xs :: FunKind [b] [c] -> Type) (ys :: [b]) Source # | |
type App (ZipWithSym2 f xs :: FunKind [b] [c] -> Type) (ys :: [b]) Source # | |
Defined in DeFun.List | |
type App (AppendSym :: FunKind [a] ([a] ~> [a]) -> Type) (xs :: [a]) Source # | |
Defined in DeFun.List | |
type App (Map2Sym1 f :: FunKind [a] ([b] ~> [c]) -> Type) (xs :: [a]) Source # | |
type App (ZipWithSym1 f :: FunKind [a] ([b] ~> [c]) -> Type) (xs :: [a]) Source # | |
Defined in DeFun.List | |
type App (FilterSym :: FunKind (a ~> Bool) ([a] ~> [a]) -> Type) (p :: a ~> Bool) Source # | |
type App (JoinSym :: FunKind (a ~> (a ~> b)) (a ~> b) -> Type) (f :: a ~> (a ~> b)) Source # | |
type App (FoldrSym :: FunKind (a ~> (b ~> b)) (b ~> ([a] ~> b)) -> Type) (f :: a ~> (b ~> b)) Source # | |
type App (ConcatMapSym :: FunKind (a ~> [b]) ([a] ~> [b]) -> Type) (f :: a ~> [b]) Source # | |
Defined in DeFun.List type App (ConcatMapSym :: FunKind (a ~> [b]) ([a] ~> [b]) -> Type) (f :: a ~> [b]) = ConcatMapSym1 f | |
type App (MapSym :: FunKind (a ~> b) ([a] ~> [b]) -> Type) (f :: a ~> b) Source # | |
type App (FoldlSym :: FunKind (b ~> (a ~> b)) (b ~> ([a] ~> b)) -> Type) (f :: b ~> (a ~> b)) Source # | |
type App (ApSym :: FunKind (a ~> (b ~> c)) ((a ~> b) ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) Source # | |
type App (Map2Sym :: FunKind (a ~> (b ~> c)) ([a] ~> ([b] ~> [c])) -> Type) (f :: a ~> (b ~> c)) Source # | |
type App (ZipWithSym :: FunKind (a ~> (b ~> c)) ([a] ~> ([b] ~> [c])) -> Type) (f :: a ~> (b ~> c)) Source # | |
Defined in DeFun.List | |
type App (FlipSym :: FunKind (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) Source # | |
type App (CompSym :: FunKind (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) Source # | |
type App (ApSym1 f :: FunKind (a ~> b) (a ~> c) -> Type) (g :: a ~> b) Source # | |
type App (CompSym1 f :: FunKind (a ~> b) (a ~> c) -> Type) (g :: a ~> b) Source # | |
Lam
newtype Lam (a1 :: a -> Type) (b1 :: b -> Type) (f :: a ~> b) Source #
type (:~>) (a1 :: a -> Type) (b1 :: b -> Type) = Lam a1 b1 infixr 0 Source #
An infix synonym for Lam
mkLam :: forall {a1} {b1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (f :: a1 ~> b1). LamRep a2 b2 f -> Lam a2 b2 f Source #
A constructor of Lam
type LamRep (a1 :: a -> Type) (b1 :: b -> Type) (fun :: a ~> b) = forall (x :: a). a1 x -> b1 (fun @@ x) Source #
Unwrapped representation of defunctionalized type function.
(@@) :: forall {a1} {k} a2 b (f :: a1 ~> k) (x :: a1). Lam a2 b f -> a2 x -> b (f @@ x) infixl 9 Source #
type Lam2 (a2 :: a -> Type) (b1 :: a1 -> Type) (c :: b -> Type) (fun :: a ~> (a1 ~> b)) = Lam a2 (b1 :~> c) fun Source #
A term-level representation of binary defunctionalized type function.
type Lam3 (a3 :: a -> Type) (b1 :: a1 -> Type) (c :: a2 -> Type) (d :: b -> Type) (fun :: a ~> (a1 ~> (a2 ~> b))) = Lam a3 (b1 :~> (c :~> d)) fun Source #
A term-level representation of ternary defunctionalized type function.
type LamRep2 (a1 :: a -> Type) (b1 :: b -> Type) (c1 :: c -> Type) (fun :: a ~> (b ~> c)) = forall (x :: a) (y :: b). a1 x -> b1 y -> c1 ((fun @@ x) @@ y) Source #
Unwrapped representation of binary defunctionalized type function.
type LamRep3 (a1 :: a -> Type) (b1 :: b -> Type) (c1 :: c -> Type) (d1 :: d -> Type) (fun :: a ~> (b ~> (c ~> d))) = forall (x :: a) (y :: b) (z :: c). a1 x -> b1 y -> c1 z -> d1 (((fun @@ x) @@ y) @@ z) Source #
Unwrapped representation of ternary defunctionalized type function.
pattern Lam2 :: LamRep2 a3 b2 c fun -> Lam2 a3 b2 c fun Source #
Lam2
explicitly bidirectional pattern synonyms for binary defunctionalized type function.
pattern Lam3 :: LamRep3 a4 b2 c d fun -> Lam3 a4 b2 c d fun Source #
Lam3
explicitly bidirectional pattern synonyms for ternary defunctionalized type function.
mkLam2 :: forall {a1} {a2} {b1} (a3 :: a1 -> Type) (b2 :: a2 -> Type) (c :: b1 -> Type) (fun :: a1 ~> (a2 ~> b1)). LamRep2 a3 b2 c fun -> Lam2 a3 b2 c fun Source #
Constructor of Lam2
appLam2 :: forall {a1} {b1} {c1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (c2 :: c1 -> Type) (fun :: a1 ~> (b1 ~> c1)). Lam2 a2 b2 c2 fun -> LamRep2 a2 b2 c2 fun Source #
Destructor of Lam2
mkLam3 :: forall {a1} {a2} {a3} {b1} (a4 :: a1 -> Type) (b2 :: a2 -> Type) (c :: a3 -> Type) (d :: b1 -> Type) (fun :: a1 ~> (a2 ~> (a3 ~> b1))). LamRep3 a4 b2 c d fun -> Lam3 a4 b2 c d fun Source #
Constructor of Lam3
appLam3 :: forall {a1} {b1} {c1} {d1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (c2 :: c1 -> Type) (d2 :: d1 -> Type) (fun :: a1 ~> (b1 ~> (c1 ~> d1))). Lam3 a2 b2 c2 d2 fun -> LamRep3 a2 b2 c2 d2 fun Source #
Destructor of Lam3
Con
data Con1 (con :: a -> b) (arg :: FunKind a b) Source #
Wrapper for converting the normal type-level arrow into a ~>
. For example, given
>>>
data Nat = Z | S Nat
we can write
>>>
:kind! Map (Con1 S) '[Z, S Z]
Map (Con1 S) '[Z, S Z] :: [Nat] = [S Z, S (S Z)]
data Con2 (con :: a -> b -> c) (arg :: FunKind a (b ~> c)) Source #
Similar to Con1
, but for two-parameter type constructors.
data Con3 (con :: a -> b -> c -> d) (arg :: FunKind a (b ~> (c ~> d))) Source #
Similar to Con2
, but for three-parameter type constructors.
con1 :: forall {a1} {b1} (a2 :: a1 -> Type) (b2 :: b1 -> Type) (con :: a1 -> b1). LamRep a2 b2 (Con1 con) -> Lam a2 b2 (Con1 con) Source #
A term-level constructor for Lam
of Con1
. For example, given
>>>
data Nat = Z | S Nat
>>>
data SNat (n :: Nat) where { SZ :: SNat Z; SS :: SNat n -> SNat (S n) }
>>>
deriving instance Show (SNat n)
we can define
>>>
let conS = con1 SS -- taking a singleton(-like) constructor.
>>>
:type conS
conS :: Lam SNat SNat (Con1 S)
and use it with term level functions
>>>
map conS (SZ :* SS SZ :* SS (SS SZ) :* Nil)
SS SZ :* SS (SS SZ) :* SS (SS (SS SZ)) :* Nil