parameterized-utils-2.1.11.0: Classes and data structures for working with data-kind indexed types

Copyright | (c) Galois Inc 2014-2019
Maintainer | Joe Hendrix <jhendrix@galois.com>
Safe Haskell | Trustworthy
Language | Haskell2010

Data.Parameterized.TraversableF

Description

This module declares classes for working with structures that accept a single parametric type parameter.

Synopsis

- class FunctorF (m :: (k -> Type) -> Type) where
  - fmapF :: (forall (x :: k). f x -> g x) -> m f -> m g
- class FoldableF (t :: (k -> Type) -> Type) where
  - foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> t e -> m
  - foldrF :: (forall (s :: k). e s -> b -> b) -> b -> t e -> b
  - foldlF :: (forall (s :: k). b -> e s -> b) -> b -> t e -> b
  - foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> t e -> b
  - foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> t e -> b
  - toListF :: (forall (tp :: k). f tp -> a) -> t f -> [a]
- foldlMF :: (FoldableF t, Monad m) => (forall (x :: k). b -> f x -> m b) -> b -> t f -> m b
- foldlMF' :: (FoldableF t, Monad m) => (forall (x :: k). b -> f x -> m b) -> b -> t f -> m b
- foldrMF :: (FoldableF t, Monad m) => (forall (x :: k). f x -> b -> m b) -> b -> t f -> m b
- foldrMF' :: (FoldableF t, Monad m) => (forall (x :: k). f x -> b -> m b) -> b -> t f -> m b
- class (FunctorF t, FoldableF t) => TraversableF (t :: (k -> Type) -> Type) where
  - traverseF :: Applicative m => (forall (s :: k). e s -> m (f s)) -> t e -> m (t f)
- traverseF_ :: (FoldableF t, Applicative f) => (forall (s :: k). e s -> f a) -> t e -> f ()
- forF_ :: (FoldableF t, Applicative m) => t f -> (forall (x :: k). f x -> m a) -> m ()
- forF :: (TraversableF t, Applicative m) => t e -> (forall (s :: k). e s -> m (f s)) -> m (t f)
- fmapFDefault :: TraversableF t => (forall (s :: k). e s -> f s) -> t e -> t f
- foldMapFDefault :: (TraversableF t, Monoid m) => (forall (s :: k). e s -> m) -> t e -> m
- allF :: FoldableF t => (forall (tp :: k). f tp -> Bool) -> t f -> Bool
- anyF :: FoldableF t => (forall (tp :: k). f tp -> Bool) -> t f -> Bool
- lengthF :: forall {k} t (f :: k -> Type). FoldableF t => t f -> Int

# Documentation

class FunctorF (m :: (k -> Type) -> Type) where Source #

A parameterized type that is a functor on all instances.

Methods

fmapF :: (forall (x :: k). f x -> g x) -> m f -> m g Source #

#### Instances

Instances details

FunctorF (Proxy :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods fmapF :: (forall (x :: k). f x -> g x) -> Proxy f -> Proxy g Source #
FunctorF (All :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.All Methods fmapF :: (forall (x :: k). f x -> g x) -> All f -> All g Source #
FunctorF (Some :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.Some Methods fmapF :: (forall (x :: k). f x -> g x) -> Some f -> Some g Source #
FunctorF (Const x :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods fmapF :: (forall (x0 :: k). f x0 -> g x0) -> Const x f -> Const x g Source #
FunctorF (MapF ktp :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.Map Methods fmapF :: (forall (x :: k). f x -> g x) -> MapF ktp f -> MapF ktp g Source #
FunctorF (Pair a :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.Pair Methods fmapF :: (forall (x :: k). f x -> g x) -> Pair a f -> Pair a g Source #
(FunctorF f, FunctorF g) => FunctorF (Product f g :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods fmapF :: (forall (x :: k). f0 x -> g0 x) -> Product f g f0 -> Product f g g0 Source #
(FunctorF f, FunctorF g) => FunctorF (Sum f g :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods fmapF :: (forall (x :: k). f0 x -> g0 x) -> Sum f g f0 -> Sum f g g0 Source #
(FunctorF s, FunctorFC t) => FunctorF (Compose s t :: (l -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods fmapF :: (forall (x :: l). f x -> g x) -> Compose s t f -> Compose s t g Source #

class FoldableF (t :: (k -> Type) -> Type) where Source #

This is a generalization of the `Foldable` class to structures over parameterized terms.

Minimal complete definition

foldMapF | foldrF

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> t e -> m Source #

Map each element of the structure to a monoid, and combine the results.

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> t e -> b Source #

Right-associative fold of a structure.

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> t e -> b Source #

Left-associative fold of a structure.

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> t e -> b Source #

Right-associative fold of a structure, but with strict application of the operator.

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> t e -> b Source #

Left-associative fold of a parameterized structure with a strict accumulator.

toListF :: (forall (tp :: k). f tp -> a) -> t f -> [a] Source #

Convert structure to list.

#### Instances

Instances details

FoldableF (Proxy :: (k -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.TraversableF

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> Proxy e -> m Source #

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> Proxy e -> b Source #

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> Proxy e -> b Source #

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> Proxy e -> b Source #

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> Proxy e -> b Source #

toListF :: (forall (tp :: k). f tp -> a) -> Proxy f -> [a] Source #

FoldableF (All :: (k -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.All

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> All e -> m Source #

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> All e -> b Source #

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> All e -> b Source #

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> All e -> b Source #

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> All e -> b Source #

toListF :: (forall (tp :: k). f tp -> a) -> All f -> [a] Source #

FoldableF (Some :: (k -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.Some

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> Some e -> m Source #

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> Some e -> b Source #

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> Some e -> b Source #

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> Some e -> b Source #

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> Some e -> b Source #

toListF :: (forall (tp :: k). f tp -> a) -> Some f -> [a] Source #

FoldableF (Const x :: (k -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.TraversableF

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> Const x e -> m Source #

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> Const x e -> b Source #

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> Const x e -> b Source #

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> Const x e -> b Source #

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> Const x e -> b Source #

toListF :: (forall (tp :: k). f tp -> a) -> Const x f -> [a] Source #

FoldableF (MapF ktp :: (k -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.Map

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> MapF ktp e -> m Source #

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> MapF ktp e -> b Source #

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> MapF ktp e -> b Source #

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> MapF ktp e -> b Source #

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> MapF ktp e -> b Source #

toListF :: (forall (tp :: k). f tp -> a) -> MapF ktp f -> [a] Source #

FoldableF (Pair a :: (k -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.Pair

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> Pair a e -> m Source #

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> Pair a e -> b Source #

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> Pair a e -> b Source #

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> Pair a e -> b Source #

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> Pair a e -> b Source #

toListF :: (forall (tp :: k). f tp -> a0) -> Pair a f -> [a0] Source #

(FoldableF f, FoldableF g) => FoldableF (Product f g :: (k -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.TraversableF

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> Product f g e -> m Source #

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> Product f g e -> b Source #

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> Product f g e -> b Source #

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> Product f g e -> b Source #

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> Product f g e -> b Source #

toListF :: (forall (tp :: k). f0 tp -> a) -> Product f g f0 -> [a] Source #

(FoldableF f, FoldableF g) => FoldableF (Sum f g :: (k -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.TraversableF

Methods

foldMapF :: Monoid m => (forall (s :: k). e s -> m) -> Sum f g e -> m Source #

foldrF :: (forall (s :: k). e s -> b -> b) -> b -> Sum f g e -> b Source #

foldlF :: (forall (s :: k). b -> e s -> b) -> b -> Sum f g e -> b Source #

foldrF' :: (forall (s :: k). e s -> b -> b) -> b -> Sum f g e -> b Source #

foldlF' :: (forall (s :: k). b -> e s -> b) -> b -> Sum f g e -> b Source #

toListF :: (forall (tp :: k). f0 tp -> a) -> Sum f g f0 -> [a] Source #

(TraversableF s, TraversableFC t) => FoldableF (Compose s t :: (l -> Type) -> Type) Source # |

Instance details

Defined in Data.Parameterized.TraversableF

Methods

foldMapF :: Monoid m => (forall (s0 :: l). e s0 -> m) -> Compose s t e -> m Source #

foldrF :: (forall (s0 :: l). e s0 -> b -> b) -> b -> Compose s t e -> b Source #

foldlF :: (forall (s0 :: l). b -> e s0 -> b) -> b -> Compose s t e -> b Source #

foldrF' :: (forall (s0 :: l). e s0 -> b -> b) -> b -> Compose s t e -> b Source #

foldlF' :: (forall (s0 :: l). b -> e s0 -> b) -> b -> Compose s t e -> b Source #

toListF :: (forall (tp :: l). f tp -> a) -> Compose s t f -> [a] Source #

foldlMF :: (FoldableF t, Monad m) => (forall (x :: k). b -> f x -> m b) -> b -> t f -> m b Source #

Monadic fold over the elements of a structure from left to right.

foldlMF' :: (FoldableF t, Monad m) => (forall (x :: k). b -> f x -> m b) -> b -> t f -> m b Source #

Monadic strict fold over the elements of a structure from left to right.

foldrMF :: (FoldableF t, Monad m) => (forall (x :: k). f x -> b -> m b) -> b -> t f -> m b Source #

Monadic fold over the elements of a structure from right to left.

foldrMF' :: (FoldableF t, Monad m) => (forall (x :: k). f x -> b -> m b) -> b -> t f -> m b Source #

Monadic strict fold over the elements of a structure from right to left.

class (FunctorF t, FoldableF t) => TraversableF (t :: (k -> Type) -> Type) where Source #

Methods

traverseF :: Applicative m => (forall (s :: k). e s -> m (f s)) -> t e -> m (t f) Source #

#### Instances

Instances details

TraversableF (Proxy :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods traverseF :: Applicative m => (forall (s :: k). e s -> m (f s)) -> Proxy e -> m (Proxy f) Source #
TraversableF (Some :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.Some Methods traverseF :: Applicative m => (forall (s :: k). e s -> m (f s)) -> Some e -> m (Some f) Source #
TraversableF (Const x :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods traverseF :: Applicative m => (forall (s :: k). e s -> m (f s)) -> Const x e -> m (Const x f) Source #
TraversableF (MapF ktp :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.Map Methods traverseF :: Applicative m => (forall (s :: k). e s -> m (f s)) -> MapF ktp e -> m (MapF ktp f) Source #
(TraversableF f, TraversableF g) => TraversableF (Product f g :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods traverseF :: Applicative m => (forall (s :: k). e s -> m (f0 s)) -> Product f g e -> m (Product f g f0) Source #
(TraversableF f, TraversableF g) => TraversableF (Sum f g :: (k -> Type) -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableF Methods traverseF :: Applicative m => (forall (s :: k). e s -> m (f0 s)) -> Sum f g e -> m (Sum f g f0) Source #
(TraversableF s, TraversableFC t) => TraversableF (Compose s t :: (l -> Type) -> Type) Source # | Traverse twice over: go under the `t`, under the `s` and lift `m` out.
Instance details Defined in Data.Parameterized.TraversableF Methods traverseF :: Applicative m => (forall (s0 :: l). e s0 -> m (f s0)) -> Compose s t e -> m (Compose s t f) Source #

traverseF_ :: (FoldableF t, Applicative f) => (forall (s :: k). e s -> f a) -> t e -> f () Source #

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

forF_ :: (FoldableF t, Applicative m) => t f -> (forall (x :: k). f x -> m a) -> m () Source #

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

forF :: (TraversableF t, Applicative m) => t e -> (forall (s :: k). e s -> m (f s)) -> m (t f) Source #

Flipped `traverseF`

fmapFDefault :: TraversableF t => (forall (s :: k). e s -> f s) -> t e -> t f Source #

This function may be used as a value for `fmapF` in a `FunctorF` instance.

foldMapFDefault :: (TraversableF t, Monoid m) => (forall (s :: k). e s -> m) -> t e -> m Source #

This function may be used as a value for `foldMap` in a `Foldable` instance.

allF :: FoldableF t => (forall (tp :: k). f tp -> Bool) -> t f -> Bool Source #

Return `True` if all values satisfy the predicate.

anyF :: FoldableF t => (forall (tp :: k). f tp -> Bool) -> t f -> Bool Source #

Return `True` if any values satisfy the predicate.

lengthF :: forall {k} t (f :: k -> Type). FoldableF t => t f -> Int Source #

Return number of elements that we fold over.