Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.NatMap
Synopsis
- data NatMap (f :: Type -> Type) (g :: Type -> Type)
- data Entry (f :: Type -> Type) (g :: Type -> Type)
- getKeyValue :: forall (f :: Type -> Type) g. Entry f g -> (Shape f, g Var)
- makeEntry :: (Traversable f, Traversable g, Ord k) => f k -> g k -> Maybe (Entry f g)
- makeIdEntry :: Traversable f => f k -> Entry f f
- unsafeMakeEntry :: (Traversable f, Functor g, Ord k) => f k -> g k -> Entry f g
- empty :: forall (f :: Type -> Type) (g :: Type -> Type). NatMap f g
- singleton :: forall (f :: Type -> Type) (g :: Type -> Type). Entry f g -> NatMap f g
- partialIdentity :: (WeakOrd f, Traversable f) => [f a] -> NatMap f f
- fromEntries :: forall (f :: Type -> Type) (g :: Type -> Type). WeakOrd f => [Entry f g] -> NatMap f g
- insert :: forall (f :: Type -> Type) (g :: Type -> Type). WeakOrd f => Entry f g -> NatMap f g -> NatMap f g
- delete :: forall f any (g :: Type -> Type). WeakOrd f => f any -> NatMap f g -> NatMap f g
- size :: forall (f :: Type -> Type) (g :: Type -> Type). NatMap f g -> Int
- member :: forall f a (g :: Type -> Type). WeakOrd f => f a -> NatMap f g -> Bool
- notMember :: forall f a (g :: Type -> Type). WeakOrd f => f a -> NatMap f g -> Bool
- lookup :: (WeakOrd f, Foldable f, Functor g) => f a -> NatMap f g -> Maybe (g a)
- lookup_ :: forall (f :: Type -> Type) g. (WeakOrd f, Functor g) => Shape f -> NatMap f g -> Maybe (g Var)
- keys :: forall (f :: Type -> Type) (g :: Type -> Type). NatMap f g -> [Shape f]
- toEntries :: forall (f :: Type -> Type) (g :: Type -> Type). Traversable f => NatMap f g -> [Entry f g]
- map1 :: forall g h (f :: Type -> Type). (forall a. g a -> h a) -> NatMap f g -> NatMap f h
- mapMaybe1 :: forall g h (f :: Type -> Type). (forall a. g a -> Maybe (h a)) -> NatMap f g -> NatMap f h
- traverse1 :: forall m g h (f :: Type -> Type). Applicative m => (forall a. g a -> m (h a)) -> NatMap f g -> m (NatMap f h)
- wither1 :: forall m g h (f :: Type -> Type). Applicative m => (forall a. g a -> m (Maybe (h a))) -> NatMap f g -> m (NatMap f h)
- mapWithKey1 :: Traversable f => (forall a. Ord a => f a -> g a -> h a) -> NatMap f g -> NatMap f h
- mapMaybeWithKey1 :: Traversable f => (forall a. Ord a => f a -> g a -> Maybe (h a)) -> NatMap f g -> NatMap f h
- traverseWithKey1 :: (Traversable f, Applicative m) => (forall a. Ord a => f a -> g a -> m (h a)) -> NatMap f g -> m (NatMap f h)
- witherWithKey1 :: (Traversable f, Applicative m) => (forall a. Ord a => f a -> g a -> m (Maybe (h a))) -> NatMap f g -> m (NatMap f h)
- union :: forall (f :: Type -> Type) (g :: Type -> Type). WeakOrd f => NatMap f g -> NatMap f g -> NatMap f g
- unionWith :: forall (f :: Type -> Type) g. WeakOrd f => (forall a. g a -> g a -> g a) -> NatMap f g -> NatMap f g -> NatMap f g
- consistentUnion :: forall (f :: Type -> Type) (g :: Type -> Type). (WeakOrd f, Eq (g Var)) => NatMap f g -> NatMap f g -> Maybe (NatMap f g)
- identity :: forall (f :: Type -> Type). PTraversable f => NatMap f f
- compose :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type). (WeakOrd f, WeakOrd g, Foldable g, Functor h) => NatMap g h -> NatMap f g -> NatMap f h
- outerNat :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type). (Traversable f, Traversable g, PTraversable h, Ord (f (h Ignored))) => NatMap f g -> NatMap (Compose f h) (Compose g h)
- innerNat :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type). (Traversable f, Traversable g, PTraversable h, WeakOrd f) => NatMap f g -> NatMap (Compose h f) (Compose h g)
- horizontalCompose :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) (j :: Type -> Type). (Traversable f, Functor g, Traversable h, Functor j, Ord (f (h Ignored))) => NatMap f g -> NatMap h j -> NatMap (Compose f h) (Compose g j)
- fullSize :: forall (f :: Type -> Type) (g :: Type -> Type). PTraversable f => NatMap f g -> Int
- isTotal :: forall (f :: Type -> Type) (g :: Type -> Type). PTraversable f => NatMap f g -> Bool
- toTotal :: forall (f :: Type -> Type) (g :: Type -> Type). (PTraversable f, Functor g) => NatMap f g -> Maybe (f :~> g)
- newtype (f :: k -> Type) :~> (g :: k -> Type) = NT {}
- wrapNT :: (forall (a :: k). f a -> g a) -> f :~> g
- unwrapNT :: Transformation f g t => t -> forall (a :: k). f a -> g a
- data Var
- indices :: Traversable f => Shape f -> f Var
Documentation
data NatMap (f :: Type -> Type) (g :: Type -> Type) Source #
Data structure which represents partial natural transformations,
like usual Map
which represents partial functions.
can be seen as a partial function.Map
k v
m :: Map k v (k -> Data.Map.lookup k m) :: k -> Maybe v
Analogically, a
can be seen as a partial natural transformation,
in the same sense NatMap
f gMap
represents a partial function.
nm :: NatMap f g
(fa -> lookup
fa nm) :: forall a. f a -> Maybe (g a)
Instances
(WeakEq f, Eq (g Var)) => Eq (NatMap f g) Source # | |
(WeakOrd f, Ord (g Var)) => Ord (NatMap f g) Source # | |
Entry
data Entry (f :: Type -> Type) (g :: Type -> Type) Source #
Instances
(Show (f Ignored), Show (g Var)) => Show (Entry f g) Source # | |
(WeakEq f, Eq (g Var)) => Eq (Entry f g) Source # | |
(WeakOrd f, Ord (g Var)) => Ord (Entry f g) Source # | |
makeEntry :: (Traversable f, Traversable g, Ord k) => f k -> g k -> Maybe (Entry f g) Source #
makeIdEntry :: Traversable f => f k -> Entry f f Source #
unsafeMakeEntry :: (Traversable f, Functor g, Ord k) => f k -> g k -> Entry f g Source #
Construction
partialIdentity :: (WeakOrd f, Traversable f) => [f a] -> NatMap f f Source #
fromEntries :: forall (f :: Type -> Type) (g :: Type -> Type). WeakOrd f => [Entry f g] -> NatMap f g Source #
insert :: forall (f :: Type -> Type) (g :: Type -> Type). WeakOrd f => Entry f g -> NatMap f g -> NatMap f g Source #
Queries
lookup_ :: forall (f :: Type -> Type) g. (WeakOrd f, Functor g) => Shape f -> NatMap f g -> Maybe (g Var) Source #
toEntries :: forall (f :: Type -> Type) (g :: Type -> Type). Traversable f => NatMap f g -> [Entry f g] Source #
Map, Filter, Traversal
mapMaybe1 :: forall g h (f :: Type -> Type). (forall a. g a -> Maybe (h a)) -> NatMap f g -> NatMap f h Source #
traverse1 :: forall m g h (f :: Type -> Type). Applicative m => (forall a. g a -> m (h a)) -> NatMap f g -> m (NatMap f h) Source #
wither1 :: forall m g h (f :: Type -> Type). Applicative m => (forall a. g a -> m (Maybe (h a))) -> NatMap f g -> m (NatMap f h) Source #
mapWithKey1 :: Traversable f => (forall a. Ord a => f a -> g a -> h a) -> NatMap f g -> NatMap f h Source #
mapMaybeWithKey1 :: Traversable f => (forall a. Ord a => f a -> g a -> Maybe (h a)) -> NatMap f g -> NatMap f h Source #
traverseWithKey1 :: (Traversable f, Applicative m) => (forall a. Ord a => f a -> g a -> m (h a)) -> NatMap f g -> m (NatMap f h) Source #
witherWithKey1 :: (Traversable f, Applicative m) => (forall a. Ord a => f a -> g a -> m (Maybe (h a))) -> NatMap f g -> m (NatMap f h) Source #
Combinators
union :: forall (f :: Type -> Type) (g :: Type -> Type). WeakOrd f => NatMap f g -> NatMap f g -> NatMap f g Source #
unionWith :: forall (f :: Type -> Type) g. WeakOrd f => (forall a. g a -> g a -> g a) -> NatMap f g -> NatMap f g -> NatMap f g Source #
consistentUnion :: forall (f :: Type -> Type) (g :: Type -> Type). (WeakOrd f, Eq (g Var)) => NatMap f g -> NatMap f g -> Maybe (NatMap f g) Source #
As partial natural transformation
compose :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type). (WeakOrd f, WeakOrd g, Foldable g, Functor h) => NatMap g h -> NatMap f g -> NatMap f h Source #
outerNat :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type). (Traversable f, Traversable g, PTraversable h, Ord (f (h Ignored))) => NatMap f g -> NatMap (Compose f h) (Compose g h) Source #
innerNat :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type). (Traversable f, Traversable g, PTraversable h, WeakOrd f) => NatMap f g -> NatMap (Compose h f) (Compose h g) Source #
horizontalCompose :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) (j :: Type -> Type). (Traversable f, Functor g, Traversable h, Functor j, Ord (f (h Ignored))) => NatMap f g -> NatMap h j -> NatMap (Compose f h) (Compose g j) Source #
Totality
fullSize :: forall (f :: Type -> Type) (g :: Type -> Type). PTraversable f => NatMap f g -> Int Source #
isTotal :: forall (f :: Type -> Type) (g :: Type -> Type). PTraversable f => NatMap f g -> Bool Source #
toTotal :: forall (f :: Type -> Type) (g :: Type -> Type). (PTraversable f, Functor g) => NatMap f g -> Maybe (f :~> g) Source #
Re-exports
newtype (f :: k -> Type) :~> (g :: k -> Type) infixr 0 #
A natural transformation suitable for storing in a container.
unwrapNT :: Transformation f g t => t -> forall (a :: k). f a -> g a #
Utility
An opaque type representing syntactic variable.
indices :: Traversable f => Shape f -> f Var Source #