Maintainer | gatlin@niltag.net |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Re-implementation of a library by Kenneth Foner. Upgrades were made to make this compile and functional dependencies have been replaced by type families.
This is used in Sheet
especially in order to automatically build and inspect
multi-dimensional containers out of nested functors.
Synopsis
- data Nested fs a
- data F (x :: Type -> Type)
- data N (o :: Type) (i :: Type -> Type)
- type family UnNest x where ...
- unNest :: Nested fs a -> UnNest (Nested fs a)
- class NestedCountable (x :: k) where
- type NestedCount x :: Type
- nestedCount :: Nested fs a -> Natural (NestedCount fs)
- type family NestedNTimes (n :: Type) (f :: Type -> Type) where ...
Nested functors
A Nested fs a
is the composition of all the layers mentioned in fs
,
applied to an a
. Specifically, the fs
parameter is a sort of snoc-list
holding type constructors of kind (* -> *)
. The outermost layer appears as
the parameter to Flat
; the innermost layer appears as the rightmost
argument to the outermost Nest
.
Instances
Go Nil (Nested ts :: Type -> Type) Source # | |
(Take Nil (Nested ts), Functor (Nested ts)) => Take Nil (Nested (N ts Tape)) Source # | |
View Nil (Nested (F Tape)) Source # | |
(View Nil (Nested ts), Functor (Nested ts)) => View Nil (Nested (N ts Tape)) Source # | |
InsertBase l => InsertNested (Nested (F l) :: Type -> Type) (Nested (F Tape)) Source # | |
(InsertBase l, InsertNested (Nested ls) (Nested ts), Functor (Nested ls), Applicative (Nested ts)) => InsertNested (Nested (N ls l) :: Type -> Type) (Nested (N ts Tape) :: Type -> Type) Source # | |
(NestedAs x (Nested ts y), AsDimensionalAs x (Nested ts y) ~ AsNestedAs x (Nested ts y)) => DimensionalAs x (Nested ts y) Source # | |
Defined in Sheet type AsDimensionalAs x (Nested ts y) Source # asDimensionalAs :: x -> Nested ts y -> AsDimensionalAs x (Nested ts y) Source # | |
Go ('Relative :-: Nil) (Nested (F Tape)) Source # | |
(Go rs (Nested ts), Functor (Nested ts)) => Go ('Relative :-: rs) (Nested (N ts Tape) :: Type -> Type) Source # | |
Representable f => Representable (Nested (F f)) Source # | |
(Representable f, fs ~ NestedNTimes (NestedCount fs) f, Representable (Nested fs), Rep (Nested fs) ~ Counted (NestedCount fs) (Rep f)) => Representable (Nested (N fs f)) Source # | |
Foldable f => Foldable (Nested (F f)) Source # | |
Defined in Nested fold :: Monoid m => Nested (F f) m -> m Source # foldMap :: Monoid m => (a -> m) -> Nested (F f) a -> m Source # foldMap' :: Monoid m => (a -> m) -> Nested (F f) a -> m Source # foldr :: (a -> b -> b) -> b -> Nested (F f) a -> b Source # foldr' :: (a -> b -> b) -> b -> Nested (F f) a -> b Source # foldl :: (b -> a -> b) -> b -> Nested (F f) a -> b Source # foldl' :: (b -> a -> b) -> b -> Nested (F f) a -> b Source # foldr1 :: (a -> a -> a) -> Nested (F f) a -> a Source # foldl1 :: (a -> a -> a) -> Nested (F f) a -> a Source # toList :: Nested (F f) a -> [a] Source # null :: Nested (F f) a -> Bool Source # length :: Nested (F f) a -> Int Source # elem :: Eq a => a -> Nested (F f) a -> Bool Source # maximum :: Ord a => Nested (F f) a -> a Source # minimum :: Ord a => Nested (F f) a -> a Source # | |
(Foldable f, Foldable (Nested fs)) => Foldable (Nested (N fs f)) Source # | |
Defined in Nested fold :: Monoid m => Nested (N fs f) m -> m Source # foldMap :: Monoid m => (a -> m) -> Nested (N fs f) a -> m Source # foldMap' :: Monoid m => (a -> m) -> Nested (N fs f) a -> m Source # foldr :: (a -> b -> b) -> b -> Nested (N fs f) a -> b Source # foldr' :: (a -> b -> b) -> b -> Nested (N fs f) a -> b Source # foldl :: (b -> a -> b) -> b -> Nested (N fs f) a -> b Source # foldl' :: (b -> a -> b) -> b -> Nested (N fs f) a -> b Source # foldr1 :: (a -> a -> a) -> Nested (N fs f) a -> a Source # foldl1 :: (a -> a -> a) -> Nested (N fs f) a -> a Source # toList :: Nested (N fs f) a -> [a] Source # null :: Nested (N fs f) a -> Bool Source # length :: Nested (N fs f) a -> Int Source # elem :: Eq a => a -> Nested (N fs f) a -> Bool Source # maximum :: Ord a => Nested (N fs f) a -> a Source # minimum :: Ord a => Nested (N fs f) a -> a Source # | |
Traversable f => Traversable (Nested (F f)) Source # | |
Defined in Nested traverse :: Applicative f0 => (a -> f0 b) -> Nested (F f) a -> f0 (Nested (F f) b) Source # sequenceA :: Applicative f0 => Nested (F f) (f0 a) -> f0 (Nested (F f) a) Source # mapM :: Monad m => (a -> m b) -> Nested (F f) a -> m (Nested (F f) b) Source # sequence :: Monad m => Nested (F f) (m a) -> m (Nested (F f) a) Source # | |
(Traversable f, Traversable (Nested fs)) => Traversable (Nested (N fs f)) Source # | |
Defined in Nested traverse :: Applicative f0 => (a -> f0 b) -> Nested (N fs f) a -> f0 (Nested (N fs f) b) Source # sequenceA :: Applicative f0 => Nested (N fs f) (f0 a) -> f0 (Nested (N fs f) a) Source # mapM :: Monad m => (a -> m b) -> Nested (N fs f) a -> m (Nested (N fs f) b) Source # sequence :: Monad m => Nested (N fs f) (m a) -> m (Nested (N fs f) a) Source # | |
Alternative f => Alternative (Nested (F f)) Source # | |
(Applicative f, Alternative (Nested fs)) => Alternative (Nested (N fs f)) Source # | |
Applicative f => Applicative (Nested (F f)) Source # | |
Defined in Nested pure :: a -> Nested (F f) a Source # (<*>) :: Nested (F f) (a -> b) -> Nested (F f) a -> Nested (F f) b Source # liftA2 :: (a -> b -> c) -> Nested (F f) a -> Nested (F f) b -> Nested (F f) c Source # (*>) :: Nested (F f) a -> Nested (F f) b -> Nested (F f) b Source # (<*) :: Nested (F f) a -> Nested (F f) b -> Nested (F f) a Source # | |
(Applicative f, Applicative (Nested fs)) => Applicative (Nested (N fs f)) Source # | |
Defined in Nested pure :: a -> Nested (N fs f) a Source # (<*>) :: Nested (N fs f) (a -> b) -> Nested (N fs f) a -> Nested (N fs f) b Source # liftA2 :: (a -> b -> c) -> Nested (N fs f) a -> Nested (N fs f) b -> Nested (N fs f) c Source # (*>) :: Nested (N fs f) a -> Nested (N fs f) b -> Nested (N fs f) b Source # (<*) :: Nested (N fs f) a -> Nested (N fs f) b -> Nested (N fs f) a Source # | |
Functor f => Functor (Nested (F f)) Source # | |
(Functor f, Functor (Nested fs)) => Functor (Nested (N fs f)) Source # | |
Comonad f => Comonad (Nested (F f)) Source # | |
(Comonad f, Comonad (Nested fs), Functor (Nested (N fs f)), Distributive f) => Comonad (Nested (N fs f)) Source # | |
ComonadApply f => ComonadApply (Nested (F f)) Source # | |
(ComonadApply f, Distributive f, ComonadApply (Nested fs)) => ComonadApply (Nested (N fs f)) Source # | |
Distributive f => Distributive (Nested (F f)) Source # | |
Defined in Nested | |
(Distributive f, Distributive (Nested fs)) => Distributive (Nested (N fs f)) Source # | |
Defined in Nested distribute :: Functor f0 => f0 (Nested (N fs f) a) -> Nested (N fs f) (f0 a) collect :: Functor f0 => (a -> Nested (N fs f) b) -> f0 a -> Nested (N fs f) (f0 b) distributeM :: Monad m => m (Nested (N fs f) a) -> Nested (N fs f) (m a) collectM :: Monad m => (a -> Nested (N fs f) b) -> m a -> Nested (N fs f) (m b) | |
Take ('Relative :-: Nil) (Nested (F Tape)) Source # | |
(Functor (Nested ts), Take rs (Nested ts)) => Take ('Relative :-: rs) (Nested (N ts Tape)) Source # | |
View ('Relative :-: Nil) (Nested (F Tape)) Source # | |
(Functor (Nested ts), View rs (Nested ts)) => View ('Relative :-: rs) (Nested (N ts Tape)) Source # | |
type AsDimensionalAs x (Nested ts y) Source # | |
Defined in Sheet | |
type Rep (Nested (F f)) Source # | |
type Rep (Nested (N fs f)) Source # | |
type ListFrom (Nested (F Tape)) a Source # | |
type ListFrom (Nested (N ts Tape)) a Source # | |
type ListFrom (Nested (N ts Tape)) a Source # | |
type StreamFrom (Nested (F Tape)) a Source # | |
type StreamFrom (Nested (F Tape)) a Source # | |
type StreamFrom (Nested (N ts Tape)) a Source # | |
Defined in Sheet | |
type StreamFrom (Nested (N ts Tape)) a Source # | |
Defined in Sheet |
data F (x :: Type -> Type) Source #
Instances
NestedCountable (F f :: Type) Source # | |
Defined in Nested type NestedCount (F f) Source # | |
View Nil (Nested (F Tape)) Source # | |
InsertBase l => InsertNested (Nested (F l) :: Type -> Type) (Nested (F Tape)) Source # | |
Go ('Relative :-: Nil) (Nested (F Tape)) Source # | |
Representable f => Representable (Nested (F f)) Source # | |
Foldable f => Foldable (Nested (F f)) Source # | |
Defined in Nested fold :: Monoid m => Nested (F f) m -> m Source # foldMap :: Monoid m => (a -> m) -> Nested (F f) a -> m Source # foldMap' :: Monoid m => (a -> m) -> Nested (F f) a -> m Source # foldr :: (a -> b -> b) -> b -> Nested (F f) a -> b Source # foldr' :: (a -> b -> b) -> b -> Nested (F f) a -> b Source # foldl :: (b -> a -> b) -> b -> Nested (F f) a -> b Source # foldl' :: (b -> a -> b) -> b -> Nested (F f) a -> b Source # foldr1 :: (a -> a -> a) -> Nested (F f) a -> a Source # foldl1 :: (a -> a -> a) -> Nested (F f) a -> a Source # toList :: Nested (F f) a -> [a] Source # null :: Nested (F f) a -> Bool Source # length :: Nested (F f) a -> Int Source # elem :: Eq a => a -> Nested (F f) a -> Bool Source # maximum :: Ord a => Nested (F f) a -> a Source # minimum :: Ord a => Nested (F f) a -> a Source # | |
Traversable f => Traversable (Nested (F f)) Source # | |
Defined in Nested traverse :: Applicative f0 => (a -> f0 b) -> Nested (F f) a -> f0 (Nested (F f) b) Source # sequenceA :: Applicative f0 => Nested (F f) (f0 a) -> f0 (Nested (F f) a) Source # mapM :: Monad m => (a -> m b) -> Nested (F f) a -> m (Nested (F f) b) Source # sequence :: Monad m => Nested (F f) (m a) -> m (Nested (F f) a) Source # | |
Alternative f => Alternative (Nested (F f)) Source # | |
Applicative f => Applicative (Nested (F f)) Source # | |
Defined in Nested pure :: a -> Nested (F f) a Source # (<*>) :: Nested (F f) (a -> b) -> Nested (F f) a -> Nested (F f) b Source # liftA2 :: (a -> b -> c) -> Nested (F f) a -> Nested (F f) b -> Nested (F f) c Source # (*>) :: Nested (F f) a -> Nested (F f) b -> Nested (F f) b Source # (<*) :: Nested (F f) a -> Nested (F f) b -> Nested (F f) a Source # | |
Functor f => Functor (Nested (F f)) Source # | |
Comonad f => Comonad (Nested (F f)) Source # | |
ComonadApply f => ComonadApply (Nested (F f)) Source # | |
Distributive f => Distributive (Nested (F f)) Source # | |
Defined in Nested | |
Take ('Relative :-: Nil) (Nested (F Tape)) Source # | |
View ('Relative :-: Nil) (Nested (F Tape)) Source # | |
type NestedCount (F f :: Type) Source # | |
type Rep (Nested (F f)) Source # | |
type ListFrom (Nested (F Tape)) a Source # | |
type StreamFrom (Nested (F Tape)) a Source # | |
type StreamFrom (Nested (F Tape)) a Source # | |
data N (o :: Type) (i :: Type -> Type) Source #
Instances
(Take Nil (Nested ts), Functor (Nested ts)) => Take Nil (Nested (N ts Tape)) Source # | |
(View Nil (Nested ts), Functor (Nested ts)) => View Nil (Nested (N ts Tape)) Source # | |
(InsertBase l, InsertNested (Nested ls) (Nested ts), Functor (Nested ls), Applicative (Nested ts)) => InsertNested (Nested (N ls l) :: Type -> Type) (Nested (N ts Tape) :: Type -> Type) Source # | |
NestedCountable (N fs f :: Type) Source # | |
Defined in Nested type NestedCount (N fs f) Source # | |
(Go rs (Nested ts), Functor (Nested ts)) => Go ('Relative :-: rs) (Nested (N ts Tape) :: Type -> Type) Source # | |
(Representable f, fs ~ NestedNTimes (NestedCount fs) f, Representable (Nested fs), Rep (Nested fs) ~ Counted (NestedCount fs) (Rep f)) => Representable (Nested (N fs f)) Source # | |
(Foldable f, Foldable (Nested fs)) => Foldable (Nested (N fs f)) Source # | |
Defined in Nested fold :: Monoid m => Nested (N fs f) m -> m Source # foldMap :: Monoid m => (a -> m) -> Nested (N fs f) a -> m Source # foldMap' :: Monoid m => (a -> m) -> Nested (N fs f) a -> m Source # foldr :: (a -> b -> b) -> b -> Nested (N fs f) a -> b Source # foldr' :: (a -> b -> b) -> b -> Nested (N fs f) a -> b Source # foldl :: (b -> a -> b) -> b -> Nested (N fs f) a -> b Source # foldl' :: (b -> a -> b) -> b -> Nested (N fs f) a -> b Source # foldr1 :: (a -> a -> a) -> Nested (N fs f) a -> a Source # foldl1 :: (a -> a -> a) -> Nested (N fs f) a -> a Source # toList :: Nested (N fs f) a -> [a] Source # null :: Nested (N fs f) a -> Bool Source # length :: Nested (N fs f) a -> Int Source # elem :: Eq a => a -> Nested (N fs f) a -> Bool Source # maximum :: Ord a => Nested (N fs f) a -> a Source # minimum :: Ord a => Nested (N fs f) a -> a Source # | |
(Traversable f, Traversable (Nested fs)) => Traversable (Nested (N fs f)) Source # | |
Defined in Nested traverse :: Applicative f0 => (a -> f0 b) -> Nested (N fs f) a -> f0 (Nested (N fs f) b) Source # sequenceA :: Applicative f0 => Nested (N fs f) (f0 a) -> f0 (Nested (N fs f) a) Source # mapM :: Monad m => (a -> m b) -> Nested (N fs f) a -> m (Nested (N fs f) b) Source # sequence :: Monad m => Nested (N fs f) (m a) -> m (Nested (N fs f) a) Source # | |
(Applicative f, Alternative (Nested fs)) => Alternative (Nested (N fs f)) Source # | |
(Applicative f, Applicative (Nested fs)) => Applicative (Nested (N fs f)) Source # | |
Defined in Nested pure :: a -> Nested (N fs f) a Source # (<*>) :: Nested (N fs f) (a -> b) -> Nested (N fs f) a -> Nested (N fs f) b Source # liftA2 :: (a -> b -> c) -> Nested (N fs f) a -> Nested (N fs f) b -> Nested (N fs f) c Source # (*>) :: Nested (N fs f) a -> Nested (N fs f) b -> Nested (N fs f) b Source # (<*) :: Nested (N fs f) a -> Nested (N fs f) b -> Nested (N fs f) a Source # | |
(Functor f, Functor (Nested fs)) => Functor (Nested (N fs f)) Source # | |
(Comonad f, Comonad (Nested fs), Functor (Nested (N fs f)), Distributive f) => Comonad (Nested (N fs f)) Source # | |
(ComonadApply f, Distributive f, ComonadApply (Nested fs)) => ComonadApply (Nested (N fs f)) Source # | |
(Distributive f, Distributive (Nested fs)) => Distributive (Nested (N fs f)) Source # | |
Defined in Nested distribute :: Functor f0 => f0 (Nested (N fs f) a) -> Nested (N fs f) (f0 a) collect :: Functor f0 => (a -> Nested (N fs f) b) -> f0 a -> Nested (N fs f) (f0 b) distributeM :: Monad m => m (Nested (N fs f) a) -> Nested (N fs f) (m a) collectM :: Monad m => (a -> Nested (N fs f) b) -> m a -> Nested (N fs f) (m b) | |
(Functor (Nested ts), Take rs (Nested ts)) => Take ('Relative :-: rs) (Nested (N ts Tape)) Source # | |
(Functor (Nested ts), View rs (Nested ts)) => View ('Relative :-: rs) (Nested (N ts Tape)) Source # | |
type NestedCount (N fs f :: Type) Source # | |
Defined in Nested | |
type Rep (Nested (N fs f)) Source # | |
type ListFrom (Nested (N ts Tape)) a Source # | |
type ListFrom (Nested (N ts Tape)) a Source # | |
type StreamFrom (Nested (N ts Tape)) a Source # | |
Defined in Sheet | |
type StreamFrom (Nested (N ts Tape)) a Source # | |
Defined in Sheet |
Deconstructing nested functors
Manipulating nested functors
class NestedCountable (x :: k) Source #
type NestedCount x :: Type Source #
Instances
NestedCountable (F f :: Type) Source # | |
Defined in Nested type NestedCount (F f) Source # | |
NestedCountable (N fs f :: Type) Source # | |
Defined in Nested type NestedCount (N fs f) Source # |
nestedCount :: Nested fs a -> Natural (NestedCount fs) Source #
type family NestedNTimes (n :: Type) (f :: Type -> Type) where ... Source #
NestedNTimes (S Z) f = F f | |
NestedNTimes (S n) f = N (NestedNTimes n f) f |