Data.MonoTraversable

mono-traversable-0.10.2: Type classes for mapping, folding, and traversing monomorphic containers

Safe Haskell | None
Language | Haskell2010

Data.MonoTraversable

Description

Type classes mirroring standard typeclasses, 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 typeclasses like `Functor` and `Foldable`, since they are monomorphic structures. This module allows both monomorphic and polymorphic data types to be instances of the same typeclasses.

All of the laws for the polymorphic typeclasses apply to their monomorphic cousins. Thus, even though a `MonoFunctor` instance for `Set` could theoretically be defined, it is omitted since it could violate the functor law of ``omap` f . `omap` g = `omap` (f . g)`.

Note that all typeclasses have been prefixed with `Mono`, and functions have been prefixed with `o`. The mnemonic for `o` is "only one", or alternatively "it's mono, but m is overused in Haskell, so we'll use the second letter instead." (Agreed, it's not a great mangling scheme, input is welcome!)

Synopsis

- type family Element mono
- class MonoFunctor mono where
  - omap :: (Element mono -> Element mono) -> mono -> mono
- class MonoFoldable mono where
  - ofoldMap :: Monoid m => (Element mono -> m) -> mono -> m
  - ofoldr :: (Element mono -> b -> b) -> b -> mono -> b
  - ofoldl' :: (a -> Element mono -> a) -> a -> mono -> a
  - otoList :: mono -> [Element mono]
  - oall :: (Element mono -> Bool) -> mono -> Bool
  - oany :: (Element mono -> Bool) -> mono -> Bool
  - onull :: mono -> Bool
  - olength :: mono -> Int
  - olength64 :: mono -> Int64
  - ocompareLength :: Integral i => mono -> i -> Ordering
  - otraverse_ :: (MonoFoldable mono, Applicative f) => (Element mono -> f b) -> mono -> f ()
  - ofor_ :: (MonoFoldable mono, Applicative f) => mono -> (Element mono -> f b) -> f ()
  - omapM_ :: (MonoFoldable mono, Monad m) => (Element mono -> m ()) -> mono -> m ()
  - oforM_ :: (MonoFoldable mono, Monad m) => mono -> (Element mono -> m ()) -> m ()
  - ofoldlM :: (MonoFoldable mono, Monad m) => (a -> Element mono -> m a) -> a -> mono -> m a
  - ofoldMap1Ex :: Semigroup m => (Element mono -> m) -> mono -> m
  - ofoldr1Ex :: (Element mono -> Element mono -> Element mono) -> mono -> Element mono
  - ofoldl1Ex' :: (Element mono -> Element mono -> Element mono) -> mono -> Element mono
  - headEx :: mono -> Element mono
  - lastEx :: mono -> Element mono
  - unsafeHead :: mono -> Element mono
  - unsafeLast :: mono -> Element mono
  - maximumByEx :: (Element mono -> Element mono -> Ordering) -> mono -> Element mono
  - minimumByEx :: (Element mono -> Element mono -> Ordering) -> mono -> Element mono
- headMay :: MonoFoldable mono => mono -> Maybe (Element mono)
- lastMay :: MonoFoldable mono => mono -> Maybe (Element mono)
- osum :: (MonoFoldable mono, Num (Element mono)) => mono -> Element mono
- oproduct :: (MonoFoldable mono, Num (Element mono)) => mono -> Element mono
- oand :: (Element mono ~ Bool, MonoFoldable mono) => mono -> Bool
- oor :: (Element mono ~ Bool, MonoFoldable mono) => mono -> Bool
- class (MonoFoldable mono, Monoid mono) => MonoFoldableMonoid mono where
  - oconcatMap :: (Element mono -> mono) -> mono -> mono
- class (MonoFoldable mono, Eq (Element mono)) => MonoFoldableEq mono where
  - oelem :: Element mono -> mono -> Bool
  - onotElem :: Element mono -> mono -> Bool
- class (MonoFoldable mono, Ord (Element mono)) => MonoFoldableOrd mono where
  - maximumEx :: mono -> Element mono
  - minimumEx :: mono -> Element mono
- maximumMay :: MonoFoldableOrd mono => mono -> Maybe (Element mono)
- maximumByMay :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> mono -> Maybe (Element mono)
- minimumMay :: MonoFoldableOrd mono => mono -> Maybe (Element mono)
- minimumByMay :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> mono -> Maybe (Element mono)
- class (MonoFunctor mono, MonoFoldable mono) => MonoTraversable mono where
  - otraverse :: Applicative f => (Element mono -> f (Element mono)) -> mono -> f mono
  - omapM :: Monad m => (Element mono -> m (Element mono)) -> mono -> m mono
- ofor :: (MonoTraversable mono, Applicative f) => mono -> (Element mono -> f (Element mono)) -> f mono
- oforM :: (MonoTraversable mono, Monad f) => mono -> (Element mono -> f (Element mono)) -> f mono
- ofoldlUnwrap :: MonoFoldable mono => (x -> Element mono -> x) -> x -> (x -> b) -> mono -> b
- ofoldMUnwrap :: (Monad m, MonoFoldable mono) => (x -> Element mono -> m x) -> m x -> (x -> m b) -> mono -> m b
- class MonoPointed mono where
  - opoint :: Element mono -> mono
- class MonoFunctor mono => MonoComonad mono where
  - oextract :: mono -> Element mono
  - oextend :: (mono -> Element mono) -> mono -> mono

# Documentation

type family Element mono

Type family for getting the type of the elements of a monomorphic container.

Instances

type Element ByteString = Word8 |
type Element ByteString = Word8 |
type Element IntSet = Int |
type Element Text = Char |
type Element Text = Char |
type Element [a] = a |
type Element (IO a) = a |
type Element (Identity a) = a |
type Element (ZipList a) = a |
type Element (Maybe a) = a |
type Element (IntMap a) = a |
type Element (Set e) = e |
type Element (Tree a) = a |
type Element (Seq a) = a |
type Element (ViewL a) = a |
type Element (ViewR a) = a |
type Element (DList a) = a |
type Element (Option a) = a |
type Element (NonEmpty a) = a |
type Element (HashSet e) = e |
type Element (Vector a) = a |
type Element (Vector a) = a |
type Element (Vector a) = a |
type Element (r -> a) = a |
type Element (Either a b) = b |
type Element (a, b) = b |
type Element (Const m a) = a |
type Element (WrappedMonad m a) = a |
type Element (IdentityT m a) = a |
type Element (Map k v) = v |
type Element (ListT m a) = a |
type Element (WrappedApplicative f a) = a |
type Element (MaybeApply f a) = a |
type Element (Arg a b) = b |
type Element (MaybeT m a) = a |
type Element (HashMap k v) = v |
type Element (MinLen nat mono) = Element mono |
type Element (WrappedArrow a b c) = c |
type Element (TracedT m w a) = a |
type Element (StoreT s w a) = a |
type Element (EnvT e w a) = a |
type Element (Cokleisli w a b) = b |
type Element (ContT r m a) = a |
type Element (ReaderT r m a) = a |
type Element (StateT s m a) = a |
type Element (StateT s m a) = a |
type Element (ErrorT e m a) = a |
type Element (WriterT w m a) = a |
type Element (WriterT w m a) = a |
type Element (Compose f g a) = a |
type Element (Static f a b) = b |
type Element (Product f g a) = a |
type Element (RWST r w s m a) = a |
type Element (RWST r w s m a) = a |

class MonoFunctor mono where

Monomorphic containers that can be mapped over.

Minimal complete definition

Nothing

Methods

omap :: (Element mono -> Element mono) -> mono -> mono

Map over a monomorphic container

Instances

MonoFunctor ByteString |
MonoFunctor ByteString |
MonoFunctor Text |
MonoFunctor Text |
MonoFunctor [a] |
MonoFunctor (IO a) |
MonoFunctor (Identity a) |
MonoFunctor (ZipList a) |
MonoFunctor (Maybe a) |
MonoFunctor (IntMap a) |
MonoFunctor (Tree a) |
MonoFunctor (Seq a) |
MonoFunctor (ViewL a) |
MonoFunctor (ViewR a) |
MonoFunctor (DList a) |
MonoFunctor (Option a) |
MonoFunctor (NonEmpty a) |
MonoFunctor (Vector a) |
Unbox a => MonoFunctor (Vector a) |
Storable a => MonoFunctor (Vector a) |
MonoFunctor (r -> a) |
MonoFunctor (Either a b) |
MonoFunctor (a, b) |
MonoFunctor (Const m a) |
Monad m => MonoFunctor (WrappedMonad m a) |
Functor m => MonoFunctor (IdentityT m a) |
MonoFunctor (Map k v) |
Functor m => MonoFunctor (ListT m a) |
Functor f => MonoFunctor (WrappedApplicative f a) |
Functor f => MonoFunctor (MaybeApply f a) |
MonoFunctor (Arg a b) |
Functor m => MonoFunctor (MaybeT m a) |
MonoFunctor (HashMap k v) |
MonoFunctor mono => MonoFunctor (MinLen nat mono) |
Arrow a => MonoFunctor (WrappedArrow a b c) |
Functor w => MonoFunctor (TracedT m w a) |
Functor w => MonoFunctor (StoreT s w a) |
Functor w => MonoFunctor (EnvT e w a) |
MonoFunctor (Cokleisli w a b) |
Functor m => MonoFunctor (ContT r m a) |
Functor m => MonoFunctor (ReaderT r m a) |
Functor m => MonoFunctor (StateT s m a) |
Functor m => MonoFunctor (StateT s m a) |
Functor m => MonoFunctor (ErrorT e m a) |
Functor m => MonoFunctor (WriterT w m a) |
Functor m => MonoFunctor (WriterT w m a) |
(Functor f, Functor g) => MonoFunctor (Compose f g a) |
Functor f => MonoFunctor (Static f a b) |
(Functor f, Functor g) => MonoFunctor (Product f g a) |
Functor m => MonoFunctor (RWST r w s m a) |
Functor m => MonoFunctor (RWST r w s m a) |

class MonoFoldable mono where

Monomorphic containers that can be folded.

Minimal complete definition

Nothing

Methods

ofoldMap :: Monoid m => (Element mono -> m) -> mono -> m

Map each element of a monomorphic container to a `Monoid` and combine the results.

ofoldr :: (Element mono -> b -> b) -> b -> mono -> b

Right-associative fold of a monomorphic container.

ofoldl' :: (a -> Element mono -> a) -> a -> mono -> a

Strict left-associative fold of a monomorphic container.

otoList :: mono -> [Element mono]

Convert a monomorphic container to a list.

oall :: (Element mono -> Bool) -> mono -> Bool

Are all of the elements in a monomorphic container converted to booleans `True`?

oany :: (Element mono -> Bool) -> mono -> Bool

Are any of the elements in a monomorphic container converted to booleans `True`?

onull :: mono -> Bool

Is the monomorphic container empty?

olength :: mono -> Int

Length of a monomorphic container, returns a `Int`.

olength64 :: mono -> Int64

Length of a monomorphic container, returns a `Int64`.

ocompareLength :: Integral i => mono -> i -> Ordering

Compare the length of a monomorphic container and a given number.

otraverse_ :: (MonoFoldable mono, Applicative f) => (Element mono -> f b) -> mono -> f ()

Map each element of a monomorphic container to an action, evaluate these actions from left to right, and ignore the results.

ofor_ :: (MonoFoldable mono, Applicative f) => mono -> (Element mono -> f b) -> f ()

`ofor_` is `otraverse_` with its arguments flipped.

omapM_ :: (MonoFoldable mono, Monad m) => (Element mono -> m ()) -> mono -> m ()

Map each element of a monomorphic container to a monadic action, evaluate these actions from left to right, and ignore the results.

oforM_ :: (MonoFoldable mono, Monad m) => mono -> (Element mono -> m ()) -> m ()

`oforM_` is `omapM_` with its arguments flipped.

ofoldlM :: (MonoFoldable mono, Monad m) => (a -> Element mono -> m a) -> a -> mono -> m a

Monadic fold over the elements of a monomorphic container, associating to the left.

ofoldMap1Ex :: Semigroup m => (Element mono -> m) -> mono -> m

Map each element of a monomorphic container to a semigroup, and combine the results.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See `ofoldMap1` from Data.MinLen for a total version of this function.

ofoldr1Ex :: (Element mono -> Element mono -> Element mono) -> mono -> Element mono

Right-associative fold of a monomorphic container with no base element.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See `ofoldr1Ex` from Data.MinLen for a total version of this function.

ofoldl1Ex' :: (Element mono -> Element mono -> Element mono) -> mono -> Element mono

Strict left-associative fold of a monomorphic container with no base element.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See `ofoldl1Ex'` from Data.MinLen for a total version of this function.

headEx :: mono -> Element mono

Get the first element of a monomorphic container.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See `head` from Data.MinLen for a total version of this function.

lastEx :: mono -> Element mono

Get the last element of a monomorphic container.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See 'Data.MinLen.last from Data.MinLen for a total version of this function.

unsafeHead :: mono -> Element mono

Equivalent to `headEx`.

unsafeLast :: mono -> Element mono

Equivalent to `lastEx`.

maximumByEx :: (Element mono -> Element mono -> Ordering) -> mono -> Element mono

Get the maximum element of a monomorphic container, using a supplied element ordering function.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See `maximiumBy` from Data.MinLen for a total version of this function.

minimumByEx :: (Element mono -> Element mono -> Ordering) -> mono -> Element mono

Get the minimum element of a monomorphic container, using a supplied element ordering function.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See `minimumBy` from Data.MinLen for a total version of this function.

Instances

MonoFoldable ByteString |
MonoFoldable ByteString |
MonoFoldable IntSet |
MonoFoldable Text |
MonoFoldable Text |
MonoFoldable [a] |
MonoFoldable (Identity a) |
MonoFoldable (Maybe a) |
MonoFoldable (IntMap a) |
MonoFoldable (Set e) |
MonoFoldable (Tree a) |
MonoFoldable (Seq a) |
MonoFoldable (ViewL a) |
MonoFoldable (ViewR a) |
MonoFoldable (DList a) |
MonoFoldable (Option a) |
MonoFoldable (NonEmpty a) |
MonoFoldable (HashSet e) |
MonoFoldable (Vector a) |
Unbox a => MonoFoldable (Vector a) |
Storable a => MonoFoldable (Vector a) |
MonoFoldable (Either a b) |
MonoFoldable (a, b) |
MonoFoldable (Const m a) |
Foldable f => MonoFoldable (IdentityT f a) |
MonoFoldable (Map k v) |
Foldable f => MonoFoldable (ListT f a) |
Foldable f => MonoFoldable (MaybeT f a) |
MonoFoldable (HashMap k v) |
MonoFoldable mono => MonoFoldable (MinLen nat mono) |
Foldable f => MonoFoldable (ErrorT e f a) |
Foldable f => MonoFoldable (WriterT w f a) |
Foldable f => MonoFoldable (WriterT w f a) |
(Foldable f, Foldable g) => MonoFoldable (Compose f g a) |
(Foldable f, Foldable g) => MonoFoldable (Product f g a) |

headMay :: MonoFoldable mono => mono -> Maybe (Element mono)

Safe version of `headEx`.

Returns `Nothing` instead of throwing an exception when encountering an empty monomorphic container.

lastMay :: MonoFoldable mono => mono -> Maybe (Element mono)

Safe version of `lastEx`.

Returns `Nothing` instead of throwing an exception when encountering an empty monomorphic container.

osum :: (MonoFoldable mono, Num (Element mono)) => mono -> Element mono

`osum` computes the sum of the numbers of a monomorphic container.

oproduct :: (MonoFoldable mono, Num (Element mono)) => mono -> Element mono

`oproduct` computes the product of the numbers of a monomorphic container.

oand :: (Element mono ~ Bool, MonoFoldable mono) => mono -> Bool

Are all of the elements `True`?

Since 0.6.0

oor :: (Element mono ~ Bool, MonoFoldable mono) => mono -> Bool

Are any of the elements `True`?

Since 0.6.0

class (MonoFoldable mono, Monoid mono) => MonoFoldableMonoid mono where

A typeclass for monomorphic containers that are `Monoid`s.

Minimal complete definition

Nothing

Methods

oconcatMap :: (Element mono -> mono) -> mono -> mono

Map a function over a monomorphic container and combine the results.

Instances

MonoFoldableMonoid ByteString |
MonoFoldableMonoid ByteString |
MonoFoldableMonoid Text |
MonoFoldableMonoid Text |
(MonoFoldable (t a), Monoid (t a)) => MonoFoldableMonoid (t a) |

class (MonoFoldable mono, Eq (Element mono)) => MonoFoldableEq mono where

A typeclass for monomorphic containers whose elements are an instance of `Eq`.

Minimal complete definition

Nothing

Methods

oelem :: Element mono -> mono -> Bool

Checks if the monomorphic container includes the supplied element.

onotElem :: Element mono -> mono -> Bool

Checks if the monomorphic container does not include the supplied element.

Instances

MonoFoldableEq ByteString |
MonoFoldableEq ByteString |
MonoFoldableEq IntSet |
MonoFoldableEq Text |
MonoFoldableEq Text |
Eq a => MonoFoldableEq [a] |
Eq a => MonoFoldableEq (Identity a) |
Eq a => MonoFoldableEq (Maybe a) |
Eq a => MonoFoldableEq (IntMap a) |
(Eq a, Ord a) => MonoFoldableEq (Set a) |
Eq a => MonoFoldableEq (Tree a) |
Eq a => MonoFoldableEq (Seq a) |
Eq a => MonoFoldableEq (ViewL a) |
Eq a => MonoFoldableEq (ViewR a) |
Eq a => MonoFoldableEq (DList a) |
Eq a => MonoFoldableEq (Option a) |
Eq a => MonoFoldableEq (NonEmpty a) |
Eq a => MonoFoldableEq (HashSet a) |
Eq a => MonoFoldableEq (Vector a) |
(Eq a, Unbox a) => MonoFoldableEq (Vector a) |
(Eq a, Storable a) => MonoFoldableEq (Vector a) |
Eq b => MonoFoldableEq (Either a b) |
Eq b => MonoFoldableEq (a, b) |
Eq a => MonoFoldableEq (Const m a) |
(Eq a, Foldable f) => MonoFoldableEq (IdentityT f a) |
Eq v => MonoFoldableEq (Map k v) |
(Eq a, Foldable f) => MonoFoldableEq (ListT f a) |
(Eq a, Foldable f) => MonoFoldableEq (MaybeT f a) |
Eq v => MonoFoldableEq (HashMap k v) |
MonoFoldableEq mono => MonoFoldableEq (MinLen nat mono) |
(Eq a, Foldable f) => MonoFoldableEq (ErrorT e f a) |
(Eq a, Foldable f) => MonoFoldableEq (WriterT w f a) |
(Eq a, Foldable f) => MonoFoldableEq (WriterT w f a) |
(Eq a, Foldable f, Foldable g) => MonoFoldableEq (Compose f g a) |
(Eq a, Foldable f, Foldable g) => MonoFoldableEq (Product f g a) |

class (MonoFoldable mono, Ord (Element mono)) => MonoFoldableOrd mono where

A typeclass for monomorphic containers whose elements are an instance of `Ord`.

Minimal complete definition

Nothing

Methods

maximumEx :: mono -> Element mono

Get the minimum element of a monomorphic container.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See `maximum` from Data.MinLen for a total version of this function.

minimumEx :: mono -> Element mono

Get the maximum element of a monomorphic container.

Note: this is a partial function. On an empty `MonoFoldable`, it will throw an exception.

See `minimum` from Data.MinLen for a total version of this function.

Instances

MonoFoldableOrd ByteString |
MonoFoldableOrd ByteString |
MonoFoldableOrd IntSet |
MonoFoldableOrd Text |
MonoFoldableOrd Text |
Ord a => MonoFoldableOrd [a] |
Ord a => MonoFoldableOrd (Identity a) |
Ord a => MonoFoldableOrd (Maybe a) |
Ord a => MonoFoldableOrd (IntMap a) |
Ord e => MonoFoldableOrd (Set e) |
Ord a => MonoFoldableOrd (Tree a) |
Ord a => MonoFoldableOrd (Seq a) |
Ord a => MonoFoldableOrd (ViewL a) |
Ord a => MonoFoldableOrd (ViewR a) |
Ord a => MonoFoldableOrd (DList a) |
Ord a => MonoFoldableOrd (Option a) |
Ord a => MonoFoldableOrd (NonEmpty a) |
Ord e => MonoFoldableOrd (HashSet e) |
Ord a => MonoFoldableOrd (Vector a) |
(Unbox a, Ord a) => MonoFoldableOrd (Vector a) |
(Ord a, Storable a) => MonoFoldableOrd (Vector a) |
Ord b => MonoFoldableOrd (Either a b) |
Ord b => MonoFoldableOrd (a, b) |
Ord a => MonoFoldableOrd (Const m a) |
(Ord a, Foldable f) => MonoFoldableOrd (IdentityT f a) |
Ord v => MonoFoldableOrd (Map k v) |
(Ord a, Foldable f) => MonoFoldableOrd (ListT f a) |
(Ord a, Foldable f) => MonoFoldableOrd (MaybeT f a) |
Ord v => MonoFoldableOrd (HashMap k v) |
MonoFoldableOrd mono => MonoFoldableOrd (MinLen nat mono) |
(Ord a, Foldable f) => MonoFoldableOrd (ErrorT e f a) |
(Ord a, Foldable f) => MonoFoldableOrd (WriterT w f a) |
(Ord a, Foldable f) => MonoFoldableOrd (WriterT w f a) |
(Ord a, Foldable f, Foldable g) => MonoFoldableOrd (Compose f g a) |
(Ord a, Foldable f, Foldable g) => MonoFoldableOrd (Product f g a) |

maximumMay :: MonoFoldableOrd mono => mono -> Maybe (Element mono)

Safe version of `maximumEx`.

Returns `Nothing` instead of throwing an exception when encountering an empty monomorphic container.

maximumByMay :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> mono -> Maybe (Element mono)

Safe version of `maximumByEx`.

Returns `Nothing` instead of throwing an exception when encountering an empty monomorphic container.

minimumMay :: MonoFoldableOrd mono => mono -> Maybe (Element mono)

Safe version of `minimumEx`.

Returns `Nothing` instead of throwing an exception when encountering an empty monomorphic container.

minimumByMay :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> mono -> Maybe (Element mono)

Safe version of `minimumByEx`.

Returns `Nothing` instead of throwing an exception when encountering an empty monomorphic container.

class (MonoFunctor mono, MonoFoldable mono) => MonoTraversable mono where

Monomorphic containers that can be traversed from left to right.

Minimal complete definition

Nothing

Methods

otraverse :: Applicative f => (Element mono -> f (Element mono)) -> mono -> f mono

Map each element of a monomorphic container to an action, evaluate these actions from left to right, and collect the results.

omapM :: Monad m => (Element mono -> m (Element mono)) -> mono -> m mono

Map each element of a monomorphic container to a monadic action, evaluate these actions from left to right, and collect the results.

Instances

MonoTraversable ByteString |
MonoTraversable ByteString |
MonoTraversable Text |
MonoTraversable Text |
MonoTraversable [a] |
MonoTraversable (Identity a) |
MonoTraversable (Maybe a) |
MonoTraversable (IntMap a) |
MonoTraversable (Tree a) |
MonoTraversable (Seq a) |
MonoTraversable (ViewL a) |
MonoTraversable (ViewR a) |
MonoTraversable (DList a) |
MonoTraversable (Option a) |
MonoTraversable (NonEmpty a) |
MonoTraversable (Vector a) |
Unbox a => MonoTraversable (Vector a) |
Storable a => MonoTraversable (Vector a) |
MonoTraversable (Either a b) |
MonoTraversable (a, b) |
MonoTraversable (Const m a) |
Traversable f => MonoTraversable (IdentityT f a) |
MonoTraversable (Map k v) |
Traversable f => MonoTraversable (ListT f a) |
Traversable f => MonoTraversable (MaybeT f a) |
MonoTraversable (HashMap k v) |
MonoTraversable mono => MonoTraversable (MinLen nat mono) |
Traversable f => MonoTraversable (ErrorT e f a) |
Traversable f => MonoTraversable (WriterT w f a) |
Traversable f => MonoTraversable (WriterT w f a) |
(Traversable f, Traversable g) => MonoTraversable (Compose f g a) |
(Traversable f, Traversable g) => MonoTraversable (Product f g a) |

ofor :: (MonoTraversable mono, Applicative f) => mono -> (Element mono -> f (Element mono)) -> f mono

`ofor` is `otraverse` with its arguments flipped.

oforM :: (MonoTraversable mono, Monad f) => mono -> (Element mono -> f (Element mono)) -> f mono

`oforM` is `omapM` with its arguments flipped.

ofoldlUnwrap :: MonoFoldable mono => (x -> Element mono -> x) -> x -> (x -> b) -> mono -> b

A strict left fold, together with an unwrap function.

This is convenient when the accumulator value is not the same as the final expected type. It is provided mainly for integration with the `foldl` package, to be used in conjunction with `purely`.

Since 0.3.1

ofoldMUnwrap :: (Monad m, MonoFoldable mono) => (x -> Element mono -> m x) -> m x -> (x -> m b) -> mono -> m b

A monadic strict left fold, together with an unwrap function.

Similar to `foldlUnwrap`, but allows monadic actions. To be used with `impurely` from `foldl`.

Since 0.3.1

class MonoPointed mono where

Typeclass for monomorphic containers that an element can be lifted into.

For any `MonoFunctor`, the following law holds:

    omap f . opoint = opoint . f

Minimal complete definition

Nothing

Methods

opoint :: Element mono -> mono

Lift an element into a monomorphic container.

`opoint` is the same as `pure` for an `Applicative`

Instances

MonoPointed ByteString |
MonoPointed ByteString |
MonoPointed IntSet |
MonoPointed Text |
MonoPointed Text |
MonoPointed [a] |
MonoPointed (IO a) |
MonoPointed (Identity a) |
MonoPointed (ZipList a) |
MonoPointed (Maybe a) |
MonoPointed (Set a) |
MonoPointed (Tree a) |
MonoPointed (Seq a) |
MonoPointed (ViewL a) |
MonoPointed (ViewR a) |
MonoPointed (DList a) |
MonoPointed (Option a) |
MonoPointed (NonEmpty a) |
Hashable a => MonoPointed (HashSet a) |
MonoPointed (Vector a) |
Unbox a => MonoPointed (Vector a) |
Storable a => MonoPointed (Vector a) |
MonoPointed (r -> a) |
MonoPointed (Either a b) |
Monoid a => MonoPointed (a, b) |
Monoid m => MonoPointed (Const m a) |
Monad m => MonoPointed (WrappedMonad m a) |
Applicative m => MonoPointed (IdentityT m a) |
Applicative m => MonoPointed (ListT m a) |
Applicative f => MonoPointed (WrappedApplicative f a) |
MonoPointed (MaybeApply f a) |
Applicative f => MonoPointed (MaybeT f a) |
MonoPointed mono => MonoPointed (MinLen (Succ Zero) mono) |
MonoPointed mono => MonoPointed (MinLen Zero mono) |
Arrow a => MonoPointed (WrappedArrow a b c) |
MonoPointed (Cokleisli w a b) |
MonoPointed (ContT r m a) |
Applicative m => MonoPointed (ReaderT r m a) |
Applicative m => MonoPointed (StateT s m a) |
Applicative m => MonoPointed (StateT s m a) |
Applicative m => MonoPointed (ErrorT e m a) |
(Monoid w, Applicative m) => MonoPointed (WriterT w m a) |
(Monoid w, Applicative m) => MonoPointed (WriterT w m a) |
(Applicative f, Applicative g) => MonoPointed (Compose f g a) |
Applicative f => MonoPointed (Static f a b) |
(Applicative f, Applicative g) => MonoPointed (Product f g a) |
(Monoid w, Applicative m) => MonoPointed (RWST r w s m a) |
(Monoid w, Applicative m) => MonoPointed (RWST r w s m a) |

class MonoFunctor mono => MonoComonad mono where

Typeclass for monomorphic containers where it is always okay to "extract" a value from with `oextract`, and where you can extrapolate any "extracting" function to be a function on the whole part with `oextend`.

`oextend` and `oextract` should work together following the laws:

    oextend oextract      = id
    oextract . oextend f  = f
    oextend f . oextend g = oextend (f . oextend g)

As an intuition, ``oextend` f` uses `f` to "build up" a new `mono` with pieces from the old one received by `f`.

Minimal complete definition

Nothing

Methods

oextract :: mono -> Element mono

Extract an element from `mono`. Can be thought of as a dual concept to `opoint`.

oextend :: (mono -> Element mono) -> mono -> mono

Extend a `mono -> `Element` mono` function to be a `mono -> mono`; that is, builds a new `mono` from the old one by using pieces glimpsed from the given function.

Instances

MonoComonad (Identity a) |
MonoComonad (Tree a) |
MonoComonad (ViewL a) |
MonoComonad (ViewR a) |
MonoComonad (NonEmpty a) |
Monoid m => MonoComonad (m -> a) |
MonoComonad (e, a) |
Comonad w => MonoComonad (IdentityT w a) |
MonoComonad (Arg a b) |
IsSequence mono => MonoComonad (MinLen (Succ Zero) mono) | `oextract` is `head`. For ``oextend` f`, the new `mono` is populated by applying `f` to successive `tail`s of the original `mono`. For example, for ``MinLen` (`Succ` `Zero`) [`Int`]`, or ``NonNull` [`Int`]`:
    oextend f [1,2,3,4,5] = [ f [1, 2, 3, 4, 5]
                              , f [2, 3, 4, 5]
                              , f [3, 4, 5]
                              , f [4, 5]
                              , f [5]
                              ]
Meant to be a direct analogy to the instance for `NonEmpty` `a`.
(Comonad w, Monoid m) => MonoComonad (TracedT m w a) |
Comonad w => MonoComonad (StoreT s w a) |
Comonad w => MonoComonad (EnvT e w a) |