Safe Haskell | None |
---|---|
Language | Haskell2010 |
Kind-level utilities to guide and simplify programming at the type level
- data A :: forall foo. foo -> Type where
- type IsA foo = (A foo -> Type :: Type)
- type IsAn oo = (IsA oo :: Type)
- type Return f = Pure f
- data Pure f :: IsAn o
- type family Eval (t :: A foo -> Type) :: foo
- data foo :-> bar
- data Id :: IsA (foo :-> foo)
- type Apply f x = f $~ x
- type (^*^) f x = f $~ Eval x
- type family (f :: IsA (foo :-> bar)) $~ (x :: foo) :: bar
- data (:>>=:) :: IsA foo -> IsA (foo :-> IsA bar) -> IsA bar
- data (:>>>:) :: IsA (good :-> better) -> IsA (better :-> best) -> IsA (good :-> best)
- data (:^>>>:) :: IsA (good :-> better) -> IsA (better :-> best) -> IsA (IsA good :-> best)
- data (:>>>^:) :: IsA (good :-> better) -> IsA (better :-> best) -> IsA (good :-> IsA best)
- data (:^>>>^:) :: IsA (good :-> better) -> IsA (better :-> best) -> IsA (IsA good :-> IsA best)
- data Extract :: IsA (IsA x :-> x)
- data Optional :: IsA t -> IsA (s :-> IsA t) -> IsA (Maybe s :-> IsA t)
- type family FoldMap (append :: IsA (bar :-> IsA (bar :-> bar))) (zero :: bar) (f :: IsA (foo :-> bar)) (xs :: [(foo :: Type)]) :: (bar :: Type) where ...
- data Fun1 :: (a -> IsA b) -> IsA (a :-> IsA b)
- data Fun2 :: (a -> b -> IsA c) -> IsA (a :-> IsA (b :-> IsA c))
- data Fun3 :: (a -> b -> c -> IsA d) -> IsA (a :-> IsA (b :-> IsA (c :-> IsA d)))
- data Fun4 :: (a -> b -> c -> d -> IsAn e) -> IsA (a :-> IsA (b :-> IsA (c :-> IsA (d :-> IsAn e))))
Documentation
data A :: forall foo. foo -> Type where Source #
A symbolic type, i.e. a wrapper around a (poly kinded) type to be
produced by Eval
instances.
All data types, e.g. data Point2 x y :: Type
can be made into /symbolic
representations of other types, by adding a symbolic/ type parameter:
data Point2 x y :: A Vec2 -> Type
.
Complete example:
data PrettyPrinter c where RenderText :: Symbol -> PrettyPrinter Symbol WithColor :: Color -> PrettyPrinter c -> PrettyPrinter c data Color = Black | White data ColoredText :: Color -> Symbol -> IsA (PrettyPrinter Symbol) type instance Eval (ColoredText c txt) = 'WithColor c ('RenderText txt)
type IsA foo = (A foo -> Type :: Type) Source #
Type alias for A
such that data Point2 x y :: A Vec2 -> Type
becomes
data Point2 x y :: IsA Vec2
type family Eval (t :: A foo -> Type) :: foo Source #
An open type family to turn symbolic type representations created with
A
or IsA
into the actual types.
A symbolic type-level function.
type ($~) foo (IsA * ((:->) Type * a (IsA k b))) (Fun2 k b a foo f) x Source # | |
type ($~) foo (IsA * ((:->) Type * a (IsA * ((:->) Type * b (IsA k c))))) (Fun3 k c b a foo f) x Source # | |
type ($~) foo (IsA * ((:->) Type * a (IsA * ((:->) Type * b (IsA * ((:->) Type * c (IsAn k d))))))) (Fun4 k d c b a foo f) x Source # | |
type family (f :: IsA (foo :-> bar)) $~ (x :: foo) :: bar infixl 0 Source #
An open family of functions from foo
to bar
type ($~) BitRecord BitRecord (BitRecordAppendFun_ l) r Source # | |
type ($~) bar bar (Id * bar) x Source # | |
type ($~) foo bar1 ((:>>>:) * bar1 * foo * bar f g) x Source # | |
type ($~) foo (IsA k b) (Fun1 k b foo f) x Source # | |
type ($~) foo (IsA * ((:->) Type * a (IsA k b))) (Fun2 k b a foo f) x Source # | |
type ($~) foo (IsA * ((:->) Type * a (IsA * ((:->) Type * b (IsA k c))))) (Fun3 k c b a foo f) x Source # | |
type ($~) foo (IsA * ((:->) Type * a (IsA * ((:->) Type * b (IsA * ((:->) Type * c (IsAn k d))))))) (Fun4 k d c b a foo f) x Source # | |
type ($~) foo (IsA * o) ((:>>>^:) * o * foo * bar f g) x Source # | |
type ($~) (Maybe s) (IsA k t) (Optional s k t fallback f) (Nothing s) Source # | |
type ($~) (Maybe foo) (IsA k t) (Optional foo k t fallback f) (Just foo s) Source # | |
type ($~) (IsA * foo) foo (Extract * foo) x Source # | |
type ($~) (Descriptor tagInd tag) BitRecord (BitRecordOfDescriptor tagInd tag) (MkDescriptor tagInd tag body) Source # | |
type ($~) (IsA * foo) bar1 ((:^>>>:) * bar1 * foo * bar f g) x Source # | |
type ($~) (DecoderSpecificInfo ot st) (Descriptor 5 DecSpecificInfo) (DescriptorOfDecoderSpecificInfo ot st) (MkDecoderSpecificInfo ot st body) Source # | |
type ($~) (IsA * foo) (IsA * o) ((:^>>>^:) * o * foo * bar f g) x Source # | |
data (:>>=:) :: IsA foo -> IsA (foo :-> IsA bar) -> IsA bar infixl 1 Source #
Eval and ApplyCompose functions
data (:>>>:) :: IsA (good :-> better) -> IsA (better :-> best) -> IsA (good :-> best) infixl 1 Source #
Compose functions
data (:^>>>:) :: IsA (good :-> better) -> IsA (better :-> best) -> IsA (IsA good :-> best) infixl 1 Source #
Eval Input & Compose
data (:>>>^:) :: IsA (good :-> better) -> IsA (better :-> best) -> IsA (good :-> IsA best) infixl 1 Source #
Compose and Return
data (:^>>>^:) :: IsA (good :-> better) -> IsA (better :-> best) -> IsA (IsA good :-> IsA best) infixl 1 Source #
Eval compose and return
data Optional :: IsA t -> IsA (s :-> IsA t) -> IsA (Maybe s :-> IsA t) Source #
Either use the value from Just
or return a fallback value(types(kinds))
type family FoldMap (append :: IsA (bar :-> IsA (bar :-> bar))) (zero :: bar) (f :: IsA (foo :-> bar)) (xs :: [(foo :: Type)]) :: (bar :: Type) where ... Source #
Map over the elements of a list and fold the result.