Safe Haskell | None |
---|---|
Language | Haskell2010 |
Type-classes mirroring type-classes from Key
, but working with
monomorphic containers.
The motivation is that some commonly used data types (i.e., ByteString
and
Text
) do not allow for instances of type-classes like Keyed
, Indexable
,
and FoldableWithKey
, since they are monomorphic structures. This module
allows both monomorphic and polymorphic data types to be instances of the
same type-classes.
All of the laws for the polymorphic type-classes apply to their monomorphic cousins.
Note that all type-classes have been prefixed with Mono
, and functions have
been prefixed with o
. The mnemonic is inherited from MonoTraversable
.
- type family MonoKey key
- class MonoFunctor mono => MonoKeyed mono where
- class MonoFoldable mono => MonoFoldableWithKey mono where
- class (MonoKeyed mono, MonoFoldableWithKey mono, MonoTraversable mono) => MonoTraversableWithKey mono where
- class MonoFunctor mono => MonoAdjustable mono where
- class MonoFunctor mono => MonoZip mono where
- class (MonoKeyed mono, MonoZip mono) => MonoZipWithKey mono where
- class MonoLookup mono => MonoIndexable mono where
- class MonoLookup mono where
- ofoldlWithKeyUnwrap :: MonoFoldableWithKey mono => (x -> Element mono -> x) -> x -> (x -> b) -> mono -> b
- ofoldWithKeyMUnwrap :: (Monad m, MonoFoldableWithKey mono) => (x -> Element mono -> m x) -> m x -> (x -> m b) -> mono -> m b
Documentation
type family MonoKey key Source #
Type family for getting the type of the key of a monomorphic container.
Keyed Monomorphic Structures
class MonoFunctor mono => MonoKeyed mono where Source #
Monomorphic containers that can be mapped over.
omapWithKey :: (MonoKey mono -> Element mono -> Element mono) -> mono -> mono Source #
Map over a monomorphic container
omapWithKey :: (Keyed f, Element (f a) ~ a, MonoKey (f a) ~ Key f, f a ~ mono) => (MonoKey mono -> Element mono -> Element mono) -> mono -> mono Source #
Map over a monomorphic container
MonoKeyed ByteString Source # | Since: 0.1.0 |
MonoKeyed ByteString Source # | Since: 0.1.0 |
MonoKeyed Text Source # | Since: 0.1.0 |
MonoKeyed Text Source # | Since: 0.1.0 |
MonoKeyed [a] Source # | Since: 0.1.0 |
MonoKeyed (Maybe a) Source # | Since: 0.1.0 |
MonoKeyed (IO a) Source # | Since: 0.1.0 |
MonoKeyed (Option a) Source # | Since: 0.1.0 |
MonoKeyed (NonEmpty a) Source # | Since: 0.1.0 |
MonoKeyed (ZipList a) Source # | Since: 0.1.0 |
MonoKeyed (Identity a) Source # | Since: 0.1.0 |
MonoKeyed (IntMap a) Source # | Since: 0.1.0 |
MonoKeyed (Tree a) Source # | Since: 0.1.0 |
MonoKeyed (Seq a) Source # | Since: 0.1.0 |
MonoKeyed (ViewL a) Source # | Since: 0.1.0 |
MonoKeyed (ViewR a) Source # | Since: 0.1.0 |
Unbox a => MonoKeyed (Vector a) Source # | Since: 0.1.0 |
Storable a => MonoKeyed (Vector a) Source # | Since: 0.1.0 |
MonoKeyed (Vector a) Source # | Since: 0.1.0 |
MonoKeyed (r -> a) Source # | Since: 0.1.0 |
MonoKeyed (Either a b) Source # | Since: 0.1.0 |
MonoKeyed (a, b) Source # | Since: 0.1.0 |
MonoKeyed (Arg a b) Source # | Since: 0.1.0 |
Monad m => MonoKeyed (WrappedMonad m a) Source # | Since: 0.1.0 |
MonoKeyed (Map k v) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (MaybeT m a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (ListT m a) Source # | Since: 0.1.0 |
MonoKeyed (HashMap k v) Source # | Since: 0.1.0 |
Arrow a => MonoKeyed (WrappedArrow a b c) Source # | Since: 0.1.0 |
MonoKeyed (Const * m a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (IdentityT * m a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (StateT s m a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (StateT s m a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (WriterT w m a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (WriterT w m a) Source # | Since: 0.1.0 |
(Keyed f, Keyed g, (~) * (MonoKey (f a)) (Key f), (~) * (MonoKey (g a)) (Key g)) => MonoKeyed (Product * f g a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (ContT * r m a) Source # | Since: 0.1.0 |
Keyed m => MonoKeyed (ReaderT * r m a) Source # | Since: 0.1.0 |
(Keyed f, Keyed g, (~) * (MonoKey (f a)) (Key f), (~) * (MonoKey (g a)) (Key g)) => MonoKeyed (Compose * * f g a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (RWST r w s m a) Source # | Since: 0.1.0 |
Functor m => MonoKeyed (RWST r w s m a) Source # | Since: 0.1.0 |
class MonoFoldable mono => MonoFoldableWithKey mono where Source #
Monomorphic containers that can be folded over thier pairs of elements and corresponding keys.
otoKeyedList :: mono -> [(MonoKey mono, Element mono)] Source #
ofoldMapWithKey :: Monoid m => (MonoKey mono -> Element mono -> m) -> mono -> m Source #
ofoldrWithKey :: (MonoKey mono -> Element mono -> a -> a) -> a -> mono -> a Source #
ofoldlWithKey :: (a -> MonoKey mono -> Element mono -> a) -> a -> mono -> a Source #
class (MonoKeyed mono, MonoFoldableWithKey mono, MonoTraversable mono) => MonoTraversableWithKey mono where Source #
Monomorphic containers that can be traversed from left to right over thier pairs of elements and corresponding keys.
otraverseWithKey :: Applicative f => (MonoKey mono -> Element mono -> f (Element mono)) -> mono -> f mono Source #
Map each key-element pair of a monomorphic container to an action, evaluate these actions from left to right, and collect the results. {--}
otraverseWithKey :: (Applicative f, TraversableWithKey t, Element (t a) ~ a, MonoKey (t a) ~ Key t, t a ~ mono) => (MonoKey mono -> Element mono -> f (Element mono)) -> mono -> f mono Source #
Map each key-element pair of a monomorphic container to an action, evaluate these actions from left to right, and collect the results. {--}
omapWithKeyM :: Monad m => (MonoKey mono -> Element mono -> m (Element mono)) -> mono -> m mono Source #
Like otraverse
but with a Monad constraint.
Adjustable Monomorphic Structures
class MonoFunctor mono => MonoAdjustable mono where Source #
Monomorphic container that can adjust elements "in place."
oadjust :: (Element mono -> Element mono) -> MonoKey mono -> mono -> mono Source #
oadjust :: (Adjustable f, Element (f a) ~ a, MonoKey (f a) ~ Key f, f a ~ mono) => (Element mono -> Element mono) -> MonoKey mono -> mono -> mono Source #
oreplace :: MonoKey mono -> Element mono -> mono -> mono Source #
Zippable Monomorphic Structures
class MonoFunctor mono => MonoZip mono where Source #
Monomorphic container that can be zipped together, merging thier elements.
Laws:
ozipWith
const u u ===ozipWith
(flip const) u u === uozipWith
(flip
f) x y ===ozipWith
f y xozipWith
(a b -> f (g a) (h b)) x y ===ozipWith
f (omap
g x) (omap
h y)
MonoZip ByteString Source # | Since: 0.1.0 |
MonoZip ByteString Source # | Since: 0.1.0 |
MonoZip Text Source # | Since: 0.1.0 |
MonoZip Text Source # | Since: 0.1.0 |
MonoZip [a] Source # | Since: 0.1.0 |
MonoZip (Maybe a) Source # | Since: 0.1.0 |
MonoZip (IO a) Source # | Since: 0.1.0 |
MonoZip (Option a) Source # | Since: 0.1.0 |
MonoZip (NonEmpty a) Source # | Since: 0.1.0 |
MonoZip (ZipList a) Source # | Since: 0.1.0 |
MonoZip (Identity a) Source # | Since: 0.1.0 |
MonoZip (IntMap a) Source # | Since: 0.1.0 |
MonoZip (Tree a) Source # | Since: 0.1.0 |
MonoZip (Seq a) Source # | Since: 0.1.0 |
MonoZip (ViewL a) Source # | Since: 0.1.0 |
MonoZip (ViewR a) Source # | Since: 0.1.0 |
Unbox a => MonoZip (Vector a) Source # | Since: 0.1.0 |
Storable a => MonoZip (Vector a) Source # | Since: 0.1.0 |
MonoZip (Vector a) Source # | Since: 0.1.0 |
MonoZip (r -> a) Source # | Since: 0.1.0 |
MonoZip (Either a b) Source # | Since: 0.1.0 |
MonoZip (a, b) Source # | Since: 0.1.0 |
MonoZip (Arg a b) Source # | Since: 0.1.0 |
Monad m => MonoZip (WrappedMonad m a) Source # | Since: 0.1.0 |
Ord k => MonoZip (Map k v) Source # | Since: 0.1.0 |
Applicative m => MonoZip (MaybeT m a) Source # | Since: 0.1.0 |
Applicative m => MonoZip (ListT m a) Source # | Since: 0.1.0 |
(Eq k, Hashable k) => MonoZip (HashMap k v) Source # | Since: 0.1.0 |
Arrow a => MonoZip (WrappedArrow a b c) Source # | Since: 0.1.0 |
MonoZip (Const * m a) Source # | Since: 0.1.0 |
Applicative m => MonoZip (IdentityT * m a) Source # | Since: 0.1.0 |
Applicative m => MonoZip (StateT s m a) Source # | Since: 0.1.0 |
Applicative m => MonoZip (StateT s m a) Source # | Since: 0.1.0 |
(Applicative m, Monoid w) => MonoZip (WriterT w m a) Source # | Since: 0.1.0 |
(Applicative m, Monoid w) => MonoZip (WriterT w m a) Source # | Since: 0.1.0 |
(Zip f, Zip g, (~) * (MonoKey (f a)) (Key f), (~) * (MonoKey (g a)) (Key g)) => MonoZip (Product * f g a) Source # | Since: 0.1.0 |
Functor m => MonoZip (ContT * r m a) Source # | Since: 0.1.0 |
Applicative m => MonoZip (ReaderT * r m a) Source # | Since: 0.1.0 |
(Zip f, Zip g, (~) * (MonoKey (f a)) (Key f), (~) * (MonoKey (g a)) (Key g)) => MonoZip (Compose * * f g a) Source # | Since: 0.1.0 |
(Applicative m, Semigroup w) => MonoZip (RWST r w s m a) Source # | Since: 0.1.0 |
(Applicative m, Semigroup w) => MonoZip (RWST r w s m a) Source # | Since: 0.1.0 |
class (MonoKeyed mono, MonoZip mono) => MonoZipWithKey mono where Source #
Monomorphic container that can be zipped together, merging thier pairs of elements and corresponding keys.
ozipWithKey :: (MonoKey mono -> Element mono -> Element mono -> Element mono) -> mono -> mono -> mono Source #
Monomorphic Indexing / Querries
class MonoLookup mono => MonoIndexable mono where Source #
Monomorphic container that can be indexed by a key for an element.
oindex :: mono -> MonoKey mono -> Element mono Source #
oindex :: (Indexable f, Element (f a) ~ a, MonoKey (f a) ~ Key f, f a ~ mono) => mono -> MonoKey mono -> Element mono Source #
class MonoLookup mono where Source #
Monomorphic container that can be querried by a key for an element.
olookup :: MonoKey mono -> mono -> Maybe (Element mono) Source #
olookup :: (Lookup f, Element (f a) ~ a, MonoKey (f a) ~ Key f, f a ~ mono) => MonoKey mono -> mono -> Maybe (Element mono) Source #
Monomorphic unwrapping with key
ofoldlWithKeyUnwrap :: MonoFoldableWithKey mono => (x -> Element mono -> x) -> x -> (x -> b) -> mono -> b Source #
ofoldWithKeyMUnwrap :: (Monad m, MonoFoldableWithKey mono) => (x -> Element mono -> m x) -> m x -> (x -> m b) -> mono -> m b Source #