Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
DeFun.Core
Description
Defunctorization core primitives.
Synopsis
- data FunKind :: Type -> Type -> Type
- type Fun a b = FunKind a b -> Type
- type (~>) a b = Fun a b
- type family App (f :: a ~> b) (x :: a) :: b
- type (@@) a b = App a b
- newtype Lam a b f = Lam {}
- type (:~>) a b = Lam a b
- mkLam :: LamRep a b f -> Lam a b f
- type LamRep a b fun = forall x. a x -> b (fun @@ x)
- (@@) :: Lam a b f -> a x -> b (f @@ x)
- type Lam2 a b c fun = Lam a (b :~> c) fun
- type Lam3 a b c d fun = Lam a (b :~> (c :~> d)) fun
- type LamRep2 a b c fun = forall x y. a x -> b y -> c ((fun @@ x) @@ y)
- type LamRep3 a b c d fun = forall x y z. a x -> b y -> c z -> d (((fun @@ x) @@ y) @@ z)
- pattern Lam2 :: LamRep2 a b c fun -> Lam2 a b c fun
- pattern Lam3 :: LamRep3 a b c d fun -> Lam3 a b c d fun
- mkLam2 :: LamRep2 a b c fun -> Lam2 a b c fun
- appLam2 :: Lam2 a b c fun -> LamRep2 a b c fun
- mkLam3 :: LamRep3 a b c d fun -> Lam3 a b c d fun
- appLam3 :: Lam3 a b c d fun -> LamRep3 a b c d fun
- data Con1 con arg
- data Con2 con arg
- data Con3 con arg
- con1 :: LamRep a b (Con1 con) -> Lam a b (Con1 con)
- con2 :: LamRep2 a b c (Con2 con) -> Lam2 a b c (Con2 con)
- con3 :: LamRep3 a b c d (Con3 con) -> Lam3 a b c d (Con3 con)
Documentation
>>>
import Prelude (Show)
>>>
import Data.SOP.NP (NP (..))
>>>
import DeFun
FunKind
data FunKind :: Type -> Type -> Type Source #
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
type LamRep a b fun = forall x. a x -> b (fun @@ x) Source #
Unwrapped representation of defunctionalized type function.
type Lam2 a b c fun = Lam a (b :~> c) fun Source #
A term-level representation of binary defunctionalized type function.
type Lam3 a b c d fun = Lam a (b :~> (c :~> d)) fun Source #
A term-level representation of ternary defunctionalized type function.
type LamRep2 a b c fun = forall x y. a x -> b y -> c ((fun @@ x) @@ y) Source #
Unwrapped representation of binary defunctionalized type function.
type LamRep3 a b c d fun = forall x y z. a x -> b y -> c z -> d (((fun @@ x) @@ y) @@ z) Source #
Unwrapped representation of ternary defunctionalized type function.
pattern Lam2 :: LamRep2 a b c fun -> Lam2 a b c fun Source #
Lam2
explicitly bidirectional pattern synonyms for binary defunctionalized type function.
pattern Lam3 :: LamRep3 a b c d fun -> Lam3 a b c d fun Source #
Lam3
explicitly bidirectional pattern synonyms for ternary defunctionalized type function.
Con
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)]
Similar to Con1
, but for two-parameter type constructors.
Similar to Con2
, but for three-parameter type constructors.
con1 :: LamRep a b (Con1 con) -> Lam a b (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