Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type family Fn (f :: α -> *) (as :: [α]) b where ...
- type Fun = TFun Identity
- newtype TFun f as b = TFun {}
- data Proxy (t :: k) = Proxy
- type family (xs :: [α]) ++ (ys :: [α]) :: [α] where ...
- type family Len (xs :: [α]) :: PeanoNum where ...
- type family HomList (n :: PeanoNum) (a :: α) :: [α] where ...
- class Arity (xs :: [α]) where
- class Arity xs => ArityC c xs where
- class (c1 a, c2 a) => (c1 :&&: c2) a
- class Arity (Elems v) => HVector v where
- tupleSize :: forall v proxy. HVector v => proxy v -> Int
- class Arity (ElemsF v) => HVectorF (v :: (α -> *) -> *) where
- tupleSizeF :: forall v f proxy. HVectorF v => proxy (v f) -> Int
- class ArityPeano n => Index (n :: PeanoNum) (xs :: [*]) where
- type ValueAt n xs :: *
- type NewElems n xs a :: [*]
- getF :: proxy n -> Fun xs (ValueAt n xs)
- putF :: proxy n -> ValueAt n xs -> Fun xs r -> Fun xs r
- lensF :: (Functor f, v ~ ValueAt n xs) => proxy n -> (v -> f v) -> Fun xs r -> Fun xs (f r)
- lensChF :: Functor f => proxy n -> (ValueAt n xs -> f a) -> Fun (NewElems n xs a) r -> Fun xs (f r)
- class Arity xs => TyLookup x xs where
- lookupTFun :: TFun f xs (f x)
- type ContVec xs = ContVecF xs Identity
- newtype ContVecF (xs :: [α]) (f :: α -> *) = ContVecF {
- runContVecF :: forall r. TFun f xs r -> r
- cons :: x -> ContVec xs -> ContVec (x ': xs)
- consF :: f x -> ContVecF xs f -> ContVecF (x ': xs) f
- class (ArityPeano n, Arity (HomList n a)) => HomArity n a where
- toHeterogeneous :: Fun n a r -> Fun (HomList n a) r
- toHomogeneous :: Fun (HomList n a) r -> Fun n a r
- homInspect :: (Vector v a, HomArity (Peano (Dim v)) a) => v a -> Fun (HomList (Peano (Dim v)) a) r -> r
- homConstruct :: forall v a. (Vector v a, HomArity (Peano (Dim v)) a) => Fun (HomList (Peano (Dim v)) a) (v a)
- curryFun :: Fun (x ': xs) r -> x -> Fun xs r
- uncurryFun :: (x -> Fun xs r) -> Fun (x ': xs) r
- uncurryMany :: forall xs ys r. Arity xs => Fun xs (Fun ys r) -> Fun (xs ++ ys) r
- curryMany :: forall xs ys r. Arity xs => Fun (xs ++ ys) r -> Fun xs (Fun ys r)
- constFun :: Fun xs r -> Fun (x ': xs) r
- constTFun :: TFun f xs r -> TFun f (x ': xs) r
- curryTFun :: TFun f (x ': xs) r -> f x -> TFun f xs r
- uncurryTFun :: (f x -> TFun f xs r) -> TFun f (x ': xs) r
- shuffleTF :: forall f x xs r. Arity xs => (x -> TFun f xs r) -> TFun f xs (x -> r)
- stepTFun :: (TFun f xs a -> TFun f ys b) -> TFun f (x ': xs) a -> TFun f (x ': ys) b
- concatF :: (Arity xs, Arity ys) => (a -> b -> c) -> Fun xs a -> Fun ys b -> Fun (xs ++ ys) c
- lensWorkerF :: forall f r x y xs. (Functor f, Arity xs) => (x -> f y) -> Fun (y ': xs) r -> Fun (x ': xs) (f r)
- lensWorkerTF :: forall f g r x y xs. (Functor f, Arity xs) => (g x -> f (g y)) -> TFun g (y ': xs) r -> TFun g (x ': xs) (f r)
- type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
- type Lens' s a = Lens s s a a
Types and type classes
N-ary functions
type family Fn (f :: α -> *) (as :: [α]) b where ... Source #
Type family for N-ary function. Types of function parameters are encoded as the list of types.
type Fun = TFun Identity Source #
Newtype wrapper to work around of type families' lack of injectivity.
Newtype wrapper for function where all type parameters have same type constructor. This type is required for writing function which works with monads, appicatives etc.
Type functions
Proxy
is a type that holds no data, but has a phantom parameter of
arbitrary type (or even kind). Its use is to provide type information, even
though there is no value available of that type (or it may be too costly to
create one).
Historically,
is a safer alternative to the
Proxy
:: Proxy
a
idiom.undefined
:: a
>>>
Proxy :: Proxy (Void, Int -> Int)
Proxy
Proxy can even hold types of higher kinds,
>>>
Proxy :: Proxy Either
Proxy
>>>
Proxy :: Proxy Functor
Proxy
>>>
Proxy :: Proxy complicatedStructure
Proxy
Instances
Generic1 (Proxy :: k -> Type) | Since: base-4.6.0.0 |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Foldable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # | |
Traversable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Eq1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Ord1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Read1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Show1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
NFData1 (Proxy :: Type -> Type) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Vector (Proxy :: Type -> Type) a | |
Bounded (Proxy t) | Since: base-4.7.0.0 |
Enum (Proxy s) | Since: base-4.7.0.0 |
Eq (Proxy s) | Since: base-4.7.0.0 |
Ord (Proxy s) | Since: base-4.7.0.0 |
Read (Proxy t) | Since: base-4.7.0.0 |
Show (Proxy s) | Since: base-4.7.0.0 |
Ix (Proxy s) | Since: base-4.7.0.0 |
Defined in Data.Proxy | |
Generic (Proxy t) | Since: base-4.6.0.0 |
Semigroup (Proxy s) | Since: base-4.9.0.0 |
Monoid (Proxy s) | Since: base-4.7.0.0 |
NFData (Proxy a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
type Rep1 (Proxy :: k -> Type) | |
type Dim (Proxy :: Type -> Type) | |
Defined in Data.Vector.Fixed.Cont | |
type Rep (Proxy t) | |
type family Len (xs :: [α]) :: PeanoNum where ... Source #
Length of type list expressed as type level naturals from
fixed-vector
.
type family HomList (n :: PeanoNum) (a :: α) :: [α] where ... Source #
Homogeneous type list with length n and element of type a. It
uses type level natural defined in fixed-vector
.
Type classes
class Arity (xs :: [α]) where Source #
Type class for dealing with N-ary function in generic way. Both
accum
and apply
work with accumulator data types which are
polymorphic. So it's only possible to write functions which
rearrange elements in vector using plain ADT. It's possible to
get around it by using GADT as accumulator (See ArityC
and
function which use it)
This is also somewhat a kitchen sink module. It contains witnesses which could be used to prove type equalities or to bring instance in scope.
:: (forall a as. t (a ': as) -> f a -> t as) | Step function. Applies element to accumulator. |
-> (t '[] -> b) | Extract value from accumulator. |
-> t xs | Initial state. |
-> TFun f xs b |
Fold over N elements exposed as N-ary function.
:: (forall a as. t (a ': as) -> (f a, t as)) | Extract value to be applied to function. |
-> t xs | Initial state. |
-> ContVecF xs f |
Apply values to N-ary function
Size of type list as integer.
class Arity xs => ArityC c xs where Source #
:: proxy c | |
-> (forall a as. c a => t (a ': as) -> f a -> t as) | Step function. Applies element to accumulator. |
-> (t '[] -> b) | Extract value from accumulator. |
-> t xs | Initial state. |
-> TFun f xs b |
:: proxy c | |
-> (forall a as. c a => t (a ': as) -> (f a, t as)) | Extract value to be applied to function. |
-> t xs | Initial state. |
-> ContVecF xs f |
Apply values to N-ary function
Instances
ArityC (c :: α -> Constraint) ('[] :: [α]) Source # | |
(c x, ArityC c xs) => ArityC (c :: a -> Constraint) (x ': xs :: [a]) Source # | |
Defined in Data.Vector.HFixed.Class |
class (c1 a, c2 a) => (c1 :&&: c2) a Source #
Type class for combining two constraint constructors. Those are
required for ArityC
type class.
Instances
(c1 a, c2 a) => ((c1 :: k -> Constraint) :&&: (c2 :: k -> Constraint)) (a :: k) Source # | |
Defined in Data.Vector.HFixed.Class |
class Arity (Elems v) => HVector v where Source #
Type class for product type. Any product type could have instance of this type. Its methods describe how to construct and deconstruct data type. For example instance for simple data type with two fields could be written as:
data A a = A Int a instance HVector (A a) where type Elems (A a) = '[Int,a] construct = TFun $ \i a -> A i a inspect (A i a) (TFun f) = f i a
Another equivalent description of this type class is descibes
isomorphism between data type and
ContVec
, where constuct
implements
ContVec → a
(see vector
) and inspect
implements a → ContVec
(see cvec
)
Istances should satisfy one law:
inspect v construct = v
Default implementation which uses Generic
is provided.
Nothing
construct :: Fun (Elems v) v Source #
Function for constructing vector
default construct :: (Generic v, GHVector (Rep v), GElems (Rep v) ~ Elems v) => Fun (Elems v) v Source #
inspect :: v -> Fun (Elems v) a -> a Source #
Function for deconstruction of vector. It applies vector's elements to N-ary function.
Instances
HVector () Source # | Unit is empty heterogeneous vector |
HVector (Complex a) Source # | |
Arity xs => HVector (VecList xs) Source # | |
Arity xs => HVector (HVec xs) Source # | |
HVector (a, b) Source # | |
(Unbox n a, HomArity (Peano n) a, KnownNat n, Peano (n + 1) ~ 'S (Peano n)) => HVector (Vec n a) Source # | |
(Storable a, HomArity (Peano n) a, KnownNat n, Peano (n + 1) ~ 'S (Peano n)) => HVector (Vec n a) Source # | |
(Prim a, HomArity (Peano n) a, KnownNat n, Peano (n + 1) ~ 'S (Peano n)) => HVector (Vec n a) Source # | |
(HomArity (Peano n) a, KnownNat n, Peano (n + 1) ~ 'S (Peano n)) => HVector (Vec n a) Source # | |
HVector (a, b, c) Source # | |
Arity xs => HVector (ContVecF xs Identity) Source # | |
HVector (a, b, c, d) Source # | |
HVector (a, b, c, d, e) Source # | |
HVector (a, b, c, d, e, f) Source # | |
HVector (a, b, c, d, e, f, g) Source # | |
HVector (a, b, c, d, e, f, g, h) Source # | |
HVector (a, b, c, d, e, f, g, h, i) Source # | |
HVector (a, b, c, d, e, f, g, h, i, j) Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k) Source # | |
Defined in Data.Vector.HFixed.Class | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l) Source # | |
Defined in Data.Vector.HFixed.Class | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | |
Defined in Data.Vector.HFixed.Class | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | |
Defined in Data.Vector.HFixed.Class | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # | |
Defined in Data.Vector.HFixed.Class | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) Source # | |
Defined in Data.Vector.HFixed.Class | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) Source # | |
Defined in Data.Vector.HFixed.Class | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) Source # | |
Defined in Data.Vector.HFixed.Class | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) Source # | |
Defined in Data.Vector.HFixed.Class construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s)) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s)) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) Source # | |
Defined in Data.Vector.HFixed.Class construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) Source # | |
Defined in Data.Vector.HFixed.Class construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) Source # | |
Defined in Data.Vector.HFixed.Class construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v)) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v)) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) Source # | |
Defined in Data.Vector.HFixed.Class construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w)) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w)) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x)) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x)) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y)) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y)) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a') Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a') :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a')) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a') Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a') -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a')) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b') Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b') :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b')) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b') Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b') -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b')) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c') Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c') :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c')) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c') Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c') -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c')) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d') Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d') :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d')) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d') Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d') -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d')) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e') Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e') :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e')) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e') Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e') -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e')) a0 -> a0 Source # | |
HVector (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e', f') Source # | |
Defined in Data.Vector.HFixed.Class type Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e', f') :: [Type] Source # construct :: Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e', f')) (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e', f') Source # inspect :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e', f') -> Fun (Elems (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a', b', c', d', e', f')) a0 -> a0 Source # |
class Arity (ElemsF v) => HVectorF (v :: (α -> *) -> *) where Source #
Type class for partially homogeneous vector where every element in the vector have same type constructor. Vector itself is parametrized by that constructor
tupleSizeF :: forall v f proxy. HVectorF v => proxy (v f) -> Int Source #
Number of elements in parametrized product type
Lookup in vector
class ArityPeano n => Index (n :: PeanoNum) (xs :: [*]) where Source #
Indexing of vectors
type ValueAt n xs :: * Source #
Type at position n
type NewElems n xs a :: [*] Source #
List of types with n'th element replaced by a.
getF :: proxy n -> Fun xs (ValueAt n xs) Source #
Getter function for vectors
putF :: proxy n -> ValueAt n xs -> Fun xs r -> Fun xs r Source #
Putter function. It applies value x
to n
th parameter of
function.
lensF :: (Functor f, v ~ ValueAt n xs) => proxy n -> (v -> f v) -> Fun xs r -> Fun xs (f r) Source #
Helper for implementation of lens
lensChF :: Functor f => proxy n -> (ValueAt n xs -> f a) -> Fun (NewElems n xs a) r -> Fun xs (f r) Source #
Helper for type-changing lens
Instances
Arity xs => Index 'Z (x ': xs) Source # | |
Defined in Data.Vector.HFixed.Class getF :: proxy 'Z -> Fun (x ': xs) (ValueAt 'Z (x ': xs)) Source # putF :: proxy 'Z -> ValueAt 'Z (x ': xs) -> Fun (x ': xs) r -> Fun (x ': xs) r Source # lensF :: (Functor f, v ~ ValueAt 'Z (x ': xs)) => proxy 'Z -> (v -> f v) -> Fun (x ': xs) r -> Fun (x ': xs) (f r) Source # lensChF :: Functor f => proxy 'Z -> (ValueAt 'Z (x ': xs) -> f a) -> Fun (NewElems 'Z (x ': xs) a) r -> Fun (x ': xs) (f r) Source # | |
Index n xs => Index ('S n) (x ': xs) Source # | |
Defined in Data.Vector.HFixed.Class getF :: proxy ('S n) -> Fun (x ': xs) (ValueAt ('S n) (x ': xs)) Source # putF :: proxy ('S n) -> ValueAt ('S n) (x ': xs) -> Fun (x ': xs) r -> Fun (x ': xs) r Source # lensF :: (Functor f, v ~ ValueAt ('S n) (x ': xs)) => proxy ('S n) -> (v -> f v) -> Fun (x ': xs) r -> Fun (x ': xs) (f r) Source # lensChF :: Functor f => proxy ('S n) -> (ValueAt ('S n) (x ': xs) -> f a) -> Fun (NewElems ('S n) (x ': xs) a) r -> Fun (x ': xs) (f r) Source # |
class Arity xs => TyLookup x xs where Source #
Type class to supporty looking up value in product type by its
type. Latter must not contain two elements of type x
.
lookupTFun :: TFun f xs (f x) Source #
Instances
(TypeError ('Text "Cannot find type: " :$$: 'ShowType a) :: Constraint) => TyLookup (a :: α) ('[] :: [α]) Source # | |
Defined in Data.Vector.HFixed.Class lookupTFun :: TFun f '[] (f a) Source # | |
(Arity xs, TyLookupCase (a2 == x) a2 (x ': xs)) => TyLookup (a2 :: a1) (x ': xs :: [a1]) Source # | |
Defined in Data.Vector.HFixed.Class lookupTFun :: TFun f (x ': xs) (f a2) Source # |
CPS-encoded vector
newtype ContVecF (xs :: [α]) (f :: α -> *) Source #
CPS-encoded partially heterogeneous vector.
ContVecF | |
|
Instances
Interop with homogeneous vectors
class (ArityPeano n, Arity (HomList n a)) => HomArity n a where Source #
Conversion between homogeneous and heterogeneous N-ary functions.
toHeterogeneous :: Fun n a r -> Fun (HomList n a) r Source #
Convert n-ary homogeneous function to heterogeneous.
toHomogeneous :: Fun (HomList n a) r -> Fun n a r Source #
Convert heterogeneous n-ary function to homogeneous.
homInspect :: (Vector v a, HomArity (Peano (Dim v)) a) => v a -> Fun (HomList (Peano (Dim v)) a) r -> r Source #
Default implementation of inspect
for homogeneous vector.
homConstruct :: forall v a. (Vector v a, HomArity (Peano (Dim v)) a) => Fun (HomList (Peano (Dim v)) a) (v a) Source #
Default implementation of construct
for homogeneous vector.
Operations of Fun
Primitives for Fun
uncurryFun :: (x -> Fun xs r) -> Fun (x ': xs) r Source #
Uncurry N-ary function.
uncurryMany :: forall xs ys r. Arity xs => Fun xs (Fun ys r) -> Fun (xs ++ ys) r Source #
Conversion function
curryMany :: forall xs ys r. Arity xs => Fun (xs ++ ys) r -> Fun xs (Fun ys r) Source #
Curry first n arguments of N-ary function.
Primitives for TFun
constTFun :: TFun f xs r -> TFun f (x ': xs) r Source #
Add one parameter to function which is ignored.
uncurryTFun :: (f x -> TFun f xs r) -> TFun f (x ': xs) r Source #
Uncurry single parameter
shuffleTF :: forall f x xs r. Arity xs => (x -> TFun f xs r) -> TFun f xs (x -> r) Source #
Move first argument of function to its result. This function is useful for implementation of lens.
stepTFun :: (TFun f xs a -> TFun f ys b) -> TFun f (x ': xs) a -> TFun f (x ': ys) b Source #
Transform function but leave outermost parameter untouched.
More complicated functions
concatF :: (Arity xs, Arity ys) => (a -> b -> c) -> Fun xs a -> Fun ys b -> Fun (xs ++ ys) c Source #
Concatenate n-ary functions. This function combine results of both N-ary functions and merge their parameters into single list.
lensWorkerF :: forall f r x y xs. (Functor f, Arity xs) => (x -> f y) -> Fun (y ': xs) r -> Fun (x ': xs) (f r) Source #
Helper for lens implementation.
lensWorkerTF :: forall f g r x y xs. (Functor f, Arity xs) => (g x -> f (g y)) -> TFun g (y ': xs) r -> TFun g (x ': xs) (f r) Source #
Helper for lens implementation.