Copyright | (c) Artem Chirkin |
---|---|
License | BSD3 |
Maintainer | chirkin@arch.ethz.ch |
Safe Haskell | None |
Language | Haskell2010 |
- newtype Id a = Id {
- runId :: a
- type Tuple (xs :: [Type]) = TypedList Id xs
- data TypedList (f :: k -> Type) (xs :: [k]) where
- pattern (:$) :: forall (xs :: [Type]). forall (y :: Type) (ys :: [Type]). xs ~ (y ': ys) => y -> Tuple ys -> Tuple xs
- pattern (:!) :: forall (xs :: [Type]). forall (y :: Type) (ys :: [Type]). xs ~ (y ': ys) => y -> Tuple ys -> Tuple xs
- pattern U :: forall (f :: k -> Type) (xs :: [k]). xs ~ '[] => TypedList f xs
- pattern (:*) :: forall (f :: k -> Type) (xs :: [k]). forall (y :: k) (ys :: [k]). xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs
- pattern Empty :: forall (f :: k -> Type) (xs :: [k]). xs ~ '[] => TypedList f xs
- pattern TypeList :: forall (xs :: [k]). RepresentableList xs => TypeList xs
- pattern Cons :: forall (f :: k -> Type) (xs :: [k]). forall (y :: k) (ys :: [k]). xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs
- pattern Snoc :: forall (f :: k -> Type) (xs :: [k]). forall (sy :: [k]) (y :: k). xs ~ (sy +: y) => TypedList f sy -> f y -> TypedList f xs
- pattern Reverse :: forall (f :: k -> Type) (xs :: [k]). forall (sx :: [k]). (xs ~ Reverse sx, sx ~ Reverse xs) => TypedList f sx -> TypedList f xs
- (*$) :: x -> Tuple xs -> Tuple (x :+ xs)
- ($*) :: Tuple xs -> x -> Tuple (xs +: x)
- (*!) :: x -> Tuple xs -> Tuple (x :+ xs)
- (!*) :: Tuple xs -> x -> Tuple (xs +: x)
Documentation
This is an almost complete copy of Identity
by (c) Andy Gill 2001.
data TypedList (f :: k -> Type) (xs :: [k]) where Source #
Type-indexed list
pattern (:$) :: forall (xs :: [Type]). forall (y :: Type) (ys :: [Type]). xs ~ (y ': ys) => y -> Tuple ys -> Tuple xs infixr 5 | Constructing a type-indexed list |
pattern (:!) :: forall (xs :: [Type]). forall (y :: Type) (ys :: [Type]). xs ~ (y ': ys) => y -> Tuple ys -> Tuple xs infixr 5 | Constructing a type-indexed list |
pattern U :: forall (f :: k -> Type) (xs :: [k]). xs ~ '[] => TypedList f xs | Zero-length type list |
pattern (:*) :: forall (f :: k -> Type) (xs :: [k]). forall (y :: k) (ys :: [k]). xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs infixr 5 | Constructing a type-indexed list |
pattern Empty :: forall (f :: k -> Type) (xs :: [k]). xs ~ '[] => TypedList f xs | Zero-length type list; synonym to |
pattern TypeList :: forall (xs :: [k]). RepresentableList xs => TypeList xs | Pattern matching against this causes |
pattern Cons :: forall (f :: k -> Type) (xs :: [k]). forall (y :: k) (ys :: [k]). xs ~ (y ': ys) => f y -> TypedList f ys -> TypedList f xs | Constructing a type-indexed list in the canonical way |
pattern Snoc :: forall (f :: k -> Type) (xs :: [k]). forall (sy :: [k]) (y :: k). xs ~ (sy +: y) => TypedList f sy -> f y -> TypedList f xs | Constructing a type-indexed list from the other end |
pattern Reverse :: forall (f :: k -> Type) (xs :: [k]). forall (sx :: [k]). (xs ~ Reverse sx, sx ~ Reverse xs) => TypedList f sx -> TypedList f xs | Reverse a typed list |
(RepresentableList * xs, All * Bounded xs) => Bounded (Tuple xs) # | |
(RepresentableList * xs, All * Bounded xs) => Bounded (Tuple xs) # | |
All * Eq xs => Eq (Tuple xs) # | |
All * Eq xs => Eq (Tuple xs) # | |
(All * Eq xs, All * Ord xs) => Ord (Tuple xs) # | Ord instance of the Tuple implements inverse lexicorgaphic ordering. That is, the last element in the tuple is the most significant one. Note, this will never work on infinite-dimensional tuples! |
(All * Eq xs, All * Ord xs) => Ord (Tuple xs) # | Ord instance of the Tuple implements inverse lexicorgaphic ordering. That is, the last element in the tuple is the most significant one. Note, this will never work on infinite-dimensional tuples! |
(RepresentableList * xs, All * Read xs) => Read (Tuple xs) # | |
(RepresentableList * xs, All * Read xs) => Read (Tuple xs) # | |
All * Show xs => Show (Tuple xs) # | |
All * Show xs => Show (Tuple xs) # | |
All * Semigroup xs => Semigroup (Tuple xs) # | |
All * Semigroup xs => Semigroup (Tuple xs) # | |
(Semigroup (Tuple xs), RepresentableList Type xs, All * Monoid xs) => Monoid (Tuple xs) # | |
(Semigroup (Tuple xs), RepresentableList Type xs, All * Monoid xs) => Monoid (Tuple xs) # | |
Dimensions k ds => Bounded (Idxs k ds) # | |
Dimensions k ds => Enum (Idxs k ds) # | |
Eq (Idxs k xs) # | |
KnownDim k n => Num (Idxs k ((:) k n ([] k))) # | With this instance we can slightly reduce indexing expressions, e.g. x ! (1 :* 2 :* 4) == x ! (1 :* 2 :* 4 :* U) |
Ord (Idxs k xs) # | Compare indices by their importance in lexicorgaphic order
from the last dimension to the first dimension
(the last dimension is the most significant one) Literally, compare a b = compare (reverse $ listIdxs a) (reverse $ listIdxs b) This is the same sort == sortOn fromEnum |
Show (Idxs k xs) # | |
($*) :: Tuple xs -> x -> Tuple (xs +: x) infixl 5 Source #
Grow a tuple on the right. Note, it traverses an element list inside O(n).