lens-family-core-2.1.2: Haskell 2022 Lens Families

Safe Haskell | Safe-Inferred
Language | Haskell2010

Lens.Family

Contents

- Lenses
- Traversals
- Grates
- Adapters, Grids, and Prisms
- Building and Finding Optics
- Documentation
- Pseudo-imperatives
- Types
- Re-exports

Description

This is the main module for end-users of lens-families-core. If you are not building your own optics such as lenses, traversals, grates, etc., but just using optics made by others, this is the only module you need.

Synopsis

- to :: Phantom f => (s -> a) -> LensLike f s t a b
- view :: FoldLike a s t a b -> s -> a
- (^.) :: s -> FoldLike a s t a b -> a
- folding :: (Foldable g, Phantom f, Applicative f) => (s -> g a) -> LensLike f s t a b
- views :: FoldLike r s t a b -> (a -> r) -> s -> r
- (^..) :: s -> FoldLike [a] s t a b -> [a]
- (^?) :: s -> FoldLike (First a) s t a b -> Maybe a
- toListOf :: FoldLike [a] s t a b -> s -> [a]
- allOf :: FoldLike All s t a b -> (a -> Bool) -> s -> Bool
- anyOf :: FoldLike Any s t a b -> (a -> Bool) -> s -> Bool
- firstOf :: FoldLike (First a) s t a b -> s -> Maybe a
- lastOf :: FoldLike (Last a) s t a b -> s -> Maybe a
- sumOf :: Num a => FoldLike (Sum a) s t a b -> s -> a
- productOf :: Num a => FoldLike (Product a) s t a b -> s -> a
- lengthOf :: Num r => FoldLike (Sum r) s t a b -> s -> r
- nullOf :: FoldLike All s t a b -> s -> Bool
- matching :: LensLike (Either a) s t a b -> s -> Either t a
- over :: ASetter s t a b -> (a -> b) -> s -> t
- (%~) :: ASetter s t a b -> (a -> b) -> s -> t
- set :: ASetter s t a b -> b -> s -> t
- (.~) :: ASetter s t a b -> b -> s -> t
- review :: GrateLike (Constant ()) s t a b -> b -> t
- zipWithOf :: GrateLike (Prod Identity Identity) s t a b -> (a -> a -> b) -> s -> s -> t
- degrating :: AGrate s t a b -> ((s -> a) -> b) -> t
- under :: AResetter s t a b -> (a -> b) -> s -> t
- reset :: AResetter s t a b -> b -> s -> t
- (&) :: s -> (s -> t) -> t
- (+~) :: Num a => ASetter s t a a -> a -> s -> t
- (*~) :: Num a => ASetter s t a a -> a -> s -> t
- (-~) :: Num a => ASetter s t a a -> a -> s -> t
- (//~) :: Fractional a => ASetter s t a a -> a -> s -> t
- (&&~) :: ASetter s t Bool Bool -> Bool -> s -> t
- (||~) :: ASetter s t Bool Bool -> Bool -> s -> t
- (<>~) :: Monoid a => ASetter s t a a -> a -> s -> t
- type AdapterLike f g s t a b = (g a -> f b) -> g s -> f t
- type AdapterLike' f g s a = (g a -> f a) -> g s -> f s
- type LensLike f s t a b = (a -> f b) -> s -> f t
- type LensLike' f s a = (a -> f a) -> s -> f s
- type FoldLike r s t a b = LensLike (Constant r) s t a b
- type FoldLike' r s a = LensLike' (Constant r) s a
- type GrateLike g s t a b = (g a -> b) -> g s -> t
- type GrateLike' g s a = (g a -> a) -> g s -> s
- type AGrate s t a b = GrateLike (PCont b a) s t a b
- type AGrate' s a = GrateLike' (PCont a a) s a
- type ASetter s t a b = LensLike Identity s t a b
- type ASetter' s a = LensLike' Identity s a
- type AResetter s t a b = GrateLike Identity s t a b
- type AResetter' s a = GrateLike' Identity s a
- data PCont i j a
- data First a
- data Last a
- class Functor f => Phantom f
- data Constant a (b :: k)
- data Identity a
- type Prod = Product
- data All
- data Any
- data Sum a
- data Product a

# Lenses

This module provides `^.` for accessing fields and `.~` and `%~` for setting and modifying fields. Lenses are composed with `.` from the `Prelude` and `id` is the identity lens.

Lens composition in this library enjoys the following identities.

-     x^.l1.l2 === x^.l1^.l2

-     l1.l2 %~ f === l1 %~ l2 %~ f

The identity lens behaves as follows.

-     x^.id === x

-     id %~ f === f

The `&` operator, allows for a convenient way to sequence record updating:

    record & l1 .~ value1 & l2 .~ value2

Lenses are implemented in van Laarhoven style. Lenses have type ``Functor` f => (a -> f a) -> s -> f s` and lens families have type ``Functor` f => (a i -> f (a j)) -> s i -> f (s j)`.

Keep in mind that lenses and lens families can be used directly for functorial updates. For example, `_2 id` gives you strength.

    _2 id :: Functor f => (a, f b) -> f (a, b)

Here is an example of code that uses the `Maybe` functor to preserves sharing during update when possible.

    -- | 'sharedUpdate' returns the *identical* object if the update doesn't change anything.
    -- This is useful for preserving sharing.
    sharedUpdate :: Eq a => LensLike' Maybe s a -> (a -> a) -> s -> s
    sharedUpdate l f s = fromMaybe s (l f' s)
     where
      f' a | b == a    = Nothing
           | otherwise = Just b
       where
        b = f a

# Traversals

`^.` can be used with traversals to access monoidal fields. The result will be a `mconcat` of all the fields referenced. The various `fooOf` functions can be used to access different monoidal summaries of some kinds of values.

`^?` can be used to access the first value of a traversal. `Nothing` is returned when the traversal has no references.

`^..` can be used with a traversals and will return a list of all fields referenced.

When `.~` is used with a traversal, all referenced fields will be set to the same value, and when `%~` is used with a traversal, all referenced fields will be modified with the same function.

A variant of `^?` call `matching` returns `Either` a `Right` value which is the first value of the traversal, or a `Left` value which is a "proof" that the traversal has no elements. The "proof" consists of the original input structure, but in the case of polymorphic families, the type parameter is replaced with a fresh type variable, thus proving that the type parameter was unused.

Like all optics, traversals can be composed with `.`, and because every lens is automatically a traversal, lenses and traversals can be composed with `.` yielding a traversal.

Traversals are implemented in van Laarhoven style. Traversals have type ``Applicative` f => (a -> f a) -> s -> f s` and traversal families have type ``Applicative` f => (a i -> f (a j)) -> s i -> f (s j)`.

# Grates

`zipWithOf` can be used with grates to zip two structure together provided a binary operation.

`under` can be to modify each value in a structure according to a function. This works analogous to how `over` works for lenses and traversals.

`review` can be used with grates to construct a constant grate from a single value. This is like a 0-ary `zipWith` function.

`degrating` can be used to build higher arity `zipWithOf` functions:

    zipWith3Of :: AGrate s t a b -> (a -> a -> a -> b) -> s -> s -> s -> t
    zipWith3Of l f s1 s2 s3 = degrating l (\k -> f (k s1) (k s2) (k s3))

Like all optics, grates can be composed with `.`, and `id` is the identity grate.

Grates are implemented in van Laarhoven style.

Grates have type ``Functor` g => (g a -> a) -> g s -> s` and grate families have type ``Functor` g => (g (a i) -> a j) -> g (s i) -> s j`.

Keep in mind that grates and grate families can be used directly for functorial zipping. For example,

    both sum :: Num a => [(a, a)] -> (a, a)

will take a list of pairs return the sum of the first components and the sum of the second components. For another example,

    cod id :: Functor f => f (r -> a) -> r -> f a

will turn a functor full of functions into a function returning a functor full of results.

# Adapters, Grids, and Prisms

The Adapter, Prism, and Grid optics are all `AdapterLike` optics and typically not used directly, but either converted to a `LensLike` optic using `under`, or into a `GrateLike` optic using `over`. See `under` and `over` for details about which conversions are possible.

These optics are implemented in van Laarhoven style.

- Adapters have type `(`Functor` f, `Functor` g) => (g a -> f a) -> g s -> f s` and Adapters families have type `(`Functor` f, `Functor` g) => (g (a i) -> f (a j)) -> g (s i) -> f (s j)`.
- Grids have type `(`Applicative` f, `Functor` g) => (g a -> f a) -> g s -> f s` and Grids families have type `(`Applicative` f, `Functor` g) => (g (a i) -> f (a j)) -> g (s i) -> f (s j)`.
- Prisms have type `(`Applicative` f, `Traversable` g) => (g a -> f a) -> g s -> f s` and Prisms families have type `(`Applicative` f, `Traversable` g) => (g (a i) -> f (a j)) -> g (s i) -> f (s j)`.

Keep in mind that these optics and their families can sometimes be used directly, without using `over` and `under`. Sometimes you can take advantage of the fact that

       LensLike f (g s) t (g a) b
      ==
       AdapterLike f g s t a b
      ==
       GrateLike g s (f t) a (f b)

For example, if you have a grid for your structure to another type that has an `Arbitray` instance, such as grid from a custom word type to `Bool`, e.g. `myWordBitVector :: (Applicative f, Functor g) => AdapterLike' f g MyWord Bool`, you can use the grid to create an `Arbitrary` instance for your structure by directly applying `review`:

    instance Arbitrary MyWord where
      arbitrary = review myWordBitVector arbitrary

# Building and Finding Optics

To build your own optics, see Lens.Family.Unchecked.

For stock optics, see Lens.Family.Stock.

References:

- http://www.twanvl.nl/blog/haskell/cps-functional-references
- http://r6.ca/blog/20120623T104901Z.html
- http://comonad.com/reader/2012/mirrored-lenses/
- http://conal.net/blog/posts/semantic-editor-combinators
- https://r6research.livejournal.com/28050.html

# Documentation

to :: Phantom f => (s -> a) -> LensLike f s t a b Source #

    to :: (s -> a) -> Getter s t a b

`to` promotes a projection function to a read-only lens called a getter. To demote a lens to a projection function, use the section `(^.l)` or `view l`.

    >>> (3 :+ 4, "example")^._1.to(abs)
    5.0 :+ 0.0

view :: FoldLike a s t a b -> s -> a Source #

    view :: Getter s t a b -> s -> a

Demote a lens or getter to a projection function.

    view :: Monoid a => Fold s t a b -> s -> a

Returns the monoidal summary of a traversal or a fold.

(^.) :: s -> FoldLike a s t a b -> a infixl 8 Source #

    (^.) :: s -> Getter s t a b -> a

Access the value referenced by a getter or lens.

    (^.) :: Monoid a => s -> Fold s t a b -> a

Access the monoidal summary referenced by a traversal or a fold.

folding :: (Foldable g, Phantom f, Applicative f) => (s -> g a) -> LensLike f s t a b Source #

    folding :: (s -> [a]) -> Fold s t a b

`folding` promotes a "toList" function to a read-only traversal called a fold.

To demote a traversal or fold to a "toList" function use the section `(^..l)` or `toListOf l`.

views :: FoldLike r s t a b -> (a -> r) -> s -> r Source #

    views :: Monoid r => Fold s t a b -> (a -> r) -> s -> r

Given a fold or traversal, return the `foldMap` of all the values using the given function.

    views :: Getter s t a b -> (a -> r) -> s -> r

`views` is not particularly useful for getters or lenses, but given a getter or lens, it returns the referenced value passed through the given function.

    views l f s = f (view l s)

(^..) :: s -> FoldLike [a] s t a b -> [a] infixl 8 Source #

    (^..) :: s -> Fold s t a b -> [a]

Returns a list of all of the referenced values in order.

(^?) :: s -> FoldLike (First a) s t a b -> Maybe a infixl 8 Source #

    (^?) :: s -> Fold s t a b -> Maybe a

Returns `Just` the first referenced value. Returns `Nothing` if there are no referenced values.

toListOf :: FoldLike [a] s t a b -> s -> [a] Source #

    toListOf :: Fold s t a b -> s -> [a]

Returns a list of all of the referenced values in order.

allOf :: FoldLike All s t a b -> (a -> Bool) -> s -> Bool Source #

    allOf :: Fold s t a b -> (a -> Bool) -> s -> Bool

Returns true if all of the referenced values satisfy the given predicate.

anyOf :: FoldLike Any s t a b -> (a -> Bool) -> s -> Bool Source #

    anyOf :: Fold s t a b -> (a -> Bool) -> s -> Bool

Returns true if any of the referenced values satisfy the given predicate.

firstOf :: FoldLike (First a) s t a b -> s -> Maybe a Source #

    firstOf :: Fold s t a b -> s -> Maybe a

Returns `Just` the first referenced value. Returns `Nothing` if there are no referenced values. See `^?` for an infix version of `firstOf`

lastOf :: FoldLike (Last a) s t a b -> s -> Maybe a Source #

    lastOf :: Fold s t a b -> s -> Maybe a

Returns `Just` the last referenced value. Returns `Nothing` if there are no referenced values.

sumOf :: Num a => FoldLike (Sum a) s t a b -> s -> a Source #

    sumOf :: Num a => Fold s t a b -> s -> a

Returns the sum of all the referenced values.

productOf :: Num a => FoldLike (Product a) s t a b -> s -> a Source #

    productOf :: Num a => Fold s t a b -> s -> a

Returns the product of all the referenced values.

lengthOf :: Num r => FoldLike (Sum r) s t a b -> s -> r Source #

    lengthOf :: Num r => Fold s t a b -> s -> r

Counts the number of references in a traversal or fold for the input.

nullOf :: FoldLike All s t a b -> s -> Bool Source #

    nullOf :: Fold s t a b -> s -> Bool

Returns true if the number of references in the input is zero.

matching :: LensLike (Either a) s t a b -> s -> Either t a Source #

    matching :: Traversal s t a b -> s -> Either t a

Returns `Right` of the first referenced value. Returns `Left` the original value when there are no referenced values. In case there are no referenced values, the result might have a fresh type parameter, thereby proving the original value had no referenced values.

over :: ASetter s t a b -> (a -> b) -> s -> t Source #

    over :: Setter s t a b -> (a -> b) -> s -> t

Demote a setter to a semantic editor combinator.

    over :: Prism s t a b -> Reviwer s t a b
    over :: Grid s t a b -> Grate s t a b
    over :: Adapter s t a b -> Grate s t a b

Covert an `AdapterLike` optic into a `GrateLike` optic.

(%~) :: ASetter s t a b -> (a -> b) -> s -> t infixr 4 Source #

Modify all referenced fields.

set :: ASetter s t a b -> b -> s -> t Source #

Set all referenced fields to the given value.

(.~) :: ASetter s t a b -> b -> s -> t infixr 4 Source #

Set all referenced fields to the given value.

review :: GrateLike (Constant ()) s t a b -> b -> t Source #

    review :: Grate s t a b -> b -> t
    review :: Reviewer s t a b -> b -> t

zipWithOf :: GrateLike (Prod Identity Identity) s t a b -> (a -> a -> b) -> s -> s -> t Source #

    zipWithOf :: Grate s t a b -> (a -> a -> b) -> s -> s -> t

Returns a binary instance of a grate.

    zipWithOf l f x y = degrating l (k -> f (k x) (k y))

degrating :: AGrate s t a b -> ((s -> a) -> b) -> t Source #

    degrating :: Grate s t a b -> ((s -> a) -> b) -> t

Demote a grate to its normal, higher-order function, form.

    degrating . grate = id
    grate . degrating = id

under :: AResetter s t a b -> (a -> b) -> s -> t Source #

    under :: Resetter s t a b -> (a -> b) -> s -> t

Demote a resetter to a semantic editor combinator.

    under :: Prism s t a b -> Traversal s t a b
    under :: Grid s t a b -> Traversal s t a b
    under :: Adapter s t a b -> Lens s t a b

Covert an `AdapterLike` optic into a `LensLike` optic.

Note: this function is unrelated to the lens package's `under` function.

reset :: AResetter s t a b -> b -> s -> t Source #

    reset :: Resetter s t a b -> b -> s -> t

Set all referenced fields to the given value.

(&) :: s -> (s -> t) -> t infixl 1 Source #

A flipped version of `($)`.

# Pseudo-imperatives

(+~) :: Num a => ASetter s t a a -> a -> s -> t infixr 4 Source #

(*~) :: Num a => ASetter s t a a -> a -> s -> t infixr 4 Source #

(-~) :: Num a => ASetter s t a a -> a -> s -> t infixr 4 Source #

(//~) :: Fractional a => ASetter s t a a -> a -> s -> t infixr 4 Source #

(&&~) :: ASetter s t Bool Bool -> Bool -> s -> t infixr 4 Source #

(||~) :: ASetter s t Bool Bool -> Bool -> s -> t infixr 4 Source #

(<>~) :: Monoid a => ASetter s t a a -> a -> s -> t infixr 4 Source #

Monoidally append a value to all referenced fields.

# Types

type AdapterLike f g s t a b = (g a -> f b) -> g s -> f t Source #

type AdapterLike' f g s a = (g a -> f a) -> g s -> f s Source #

type LensLike f s t a b = (a -> f b) -> s -> f t Source #

type LensLike' f s a = (a -> f a) -> s -> f s Source #

type FoldLike r s t a b = LensLike (Constant r) s t a b Source #

type FoldLike' r s a = LensLike' (Constant r) s a Source #

type GrateLike g s t a b = (g a -> b) -> g s -> t Source #

type GrateLike' g s a = (g a -> a) -> g s -> s Source #

type AGrate s t a b = GrateLike (PCont b a) s t a b Source #

type AGrate' s a = GrateLike' (PCont a a) s a Source #

type ASetter s t a b = LensLike Identity s t a b Source #

type ASetter' s a = LensLike' Identity s a Source #

type AResetter s t a b = GrateLike Identity s t a b Source #

type AResetter' s a = GrateLike' Identity s a Source #

data PCont i j a Source #

#### Instances

Instances details

Functor (PCont i j) Source # |
Instance details Defined in Lens.Family Methods fmap :: (a -> b) -> PCont i j a -> PCont i j b Source # (<$) :: a -> PCont i j b -> PCont i j a Source #

data First a Source #

#### Instances

Instances details

Monoid (First a) Source # |
Instance details Defined in Lens.Family Methods mempty :: First a Source # mappend :: First a -> First a -> First a Source # mconcat :: [First a] -> First a Source #
Semigroup (First a) Source # |
Instance details Defined in Lens.Family Methods (<>) :: First a -> First a -> First a Source # sconcat :: NonEmpty (First a) -> First a Source # stimes :: Integral b => b -> First a -> First a Source #

data Last a Source #

#### Instances

Instances details

Monoid (Last a) Source # |
Instance details Defined in Lens.Family Methods mempty :: Last a Source # mappend :: Last a -> Last a -> Last a Source # mconcat :: [Last a] -> Last a Source #
Semigroup (Last a) Source # |
Instance details Defined in Lens.Family Methods (<>) :: Last a -> Last a -> Last a Source # sconcat :: NonEmpty (Last a) -> Last a Source # stimes :: Integral b => b -> Last a -> Last a Source #

class Functor f => Phantom f Source #

Minimal complete definition

coerce

#### Instances

Instances details

Phantom (Const a :: Type -> Type) Source # |
Instance details Defined in Lens.Family.Phantom Methods coerce :: Const a a0 -> Const a b
Phantom f => Phantom (AlongsideLeft f a) Source # |
Instance details Defined in Lens.Family.Stock Methods coerce :: AlongsideLeft f a a0 -> AlongsideLeft f a b
Phantom f => Phantom (AlongsideRight f a) Source # |
Instance details Defined in Lens.Family.Stock Methods coerce :: AlongsideRight f a a0 -> AlongsideRight f a b
Phantom g => Phantom (FromG e g) Source # |
Instance details Defined in Lens.Family.Stock Methods coerce :: FromG e g a -> FromG e g b
Phantom f => Phantom (Backwards f) Source # |
Instance details Defined in Lens.Family.Phantom Methods coerce :: Backwards f a -> Backwards f b
Phantom (Constant a :: Type -> Type) Source # |
Instance details Defined in Lens.Family.Phantom Methods coerce :: Constant a a0 -> Constant a b
Phantom g => Phantom (FromF i j g) Source # |
Instance details Defined in Lens.Family.Stock Methods coerce :: FromF i j g a -> FromF i j g b
(Phantom f, Functor g) => Phantom (Compose f g) Source # |
Instance details Defined in Lens.Family.Phantom Methods coerce :: Compose f g a -> Compose f g b

# Re-exports

data Constant a (b :: k) Source #

Constant functor.

#### Instances

Instances details

Bifoldable (Constant :: Type -> Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods bifold :: Monoid m => Constant m m -> m Source # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Constant a b -> m Source # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Constant a b -> c Source # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Constant a b -> c Source #
Bifunctor (Constant :: Type -> Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods bimap :: (a -> b) -> (c -> d) -> Constant a c -> Constant b d Source # first :: (a -> b) -> Constant a c -> Constant b c Source # second :: (b -> c) -> Constant a b -> Constant a c Source #
Bitraversable (Constant :: Type -> Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Constant a b -> f (Constant c d) Source #
Eq2 (Constant :: Type -> Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Constant a c -> Constant b d -> Bool Source #
Ord2 (Constant :: Type -> Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Constant a c -> Constant b d -> Ordering Source #
Read2 (Constant :: Type -> Type -> Type) |

Instance details

Defined in Data.Functor.Constant

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Constant a b) Source #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Constant a b] Source #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Constant a b) Source #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Constant a b] Source #

Show2 (Constant :: Type -> Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Constant a b -> ShowS Source # liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Constant a b] -> ShowS Source #
Foldable (Constant a :: Type -> Type) |

Instance details

Defined in Data.Functor.Constant

Methods

fold :: Monoid m => Constant a m -> m Source #

foldMap :: Monoid m => (a0 -> m) -> Constant a a0 -> m Source #

foldMap' :: Monoid m => (a0 -> m) -> Constant a a0 -> m Source #

foldr :: (a0 -> b -> b) -> b -> Constant a a0 -> b Source #

foldr' :: (a0 -> b -> b) -> b -> Constant a a0 -> b Source #

foldl :: (b -> a0 -> b) -> b -> Constant a a0 -> b Source #

foldl' :: (b -> a0 -> b) -> b -> Constant a a0 -> b Source #

foldr1 :: (a0 -> a0 -> a0) -> Constant a a0 -> a0 Source #

foldl1 :: (a0 -> a0 -> a0) -> Constant a a0 -> a0 Source #

toList :: Constant a a0 -> [a0] Source #

null :: Constant a a0 -> Bool Source #

length :: Constant a a0 -> Int Source #

elem :: Eq a0 => a0 -> Constant a a0 -> Bool Source #

maximum :: Ord a0 => Constant a a0 -> a0 Source #

minimum :: Ord a0 => Constant a a0 -> a0 Source #

sum :: Num a0 => Constant a a0 -> a0 Source #

product :: Num a0 => Constant a a0 -> a0 Source #

Eq a => Eq1 (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods liftEq :: (a0 -> b -> Bool) -> Constant a a0 -> Constant a b -> Bool Source #
Ord a => Ord1 (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods liftCompare :: (a0 -> b -> Ordering) -> Constant a a0 -> Constant a b -> Ordering Source #
Read a => Read1 (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Constant a a0) Source # liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Constant a a0] Source # liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Constant a a0) Source # liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Constant a a0] Source #
Show a => Show1 (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Constant a a0 -> ShowS Source # liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Constant a a0] -> ShowS Source #
Contravariant (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods contramap :: (a' -> a0) -> Constant a a0 -> Constant a a' Source # (>$) :: b -> Constant a b -> Constant a a0 Source #
Traversable (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods traverse :: Applicative f => (a0 -> f b) -> Constant a a0 -> f (Constant a b) Source # sequenceA :: Applicative f => Constant a (f a0) -> f (Constant a a0) Source # mapM :: Monad m => (a0 -> m b) -> Constant a a0 -> m (Constant a b) Source # sequence :: Monad m => Constant a (m a0) -> m (Constant a a0) Source #
Monoid a => Applicative (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods pure :: a0 -> Constant a a0 Source # (<*>) :: Constant a (a0 -> b) -> Constant a a0 -> Constant a b Source # liftA2 :: (a0 -> b -> c) -> Constant a a0 -> Constant a b -> Constant a c Source # (*>) :: Constant a a0 -> Constant a b -> Constant a b Source # (<*) :: Constant a a0 -> Constant a b -> Constant a a0 Source #
Functor (Constant a :: Type -> Type) |
Instance details Defined in Data.Functor.Constant Methods fmap :: (a0 -> b) -> Constant a a0 -> Constant a b Source # (<$) :: a0 -> Constant a b -> Constant a a0 Source #
Phantom (Constant a :: Type -> Type) Source # |
Instance details Defined in Lens.Family.Phantom Methods coerce :: Constant a a0 -> Constant a b
Monoid a => Monoid (Constant a b) |
Instance details Defined in Data.Functor.Constant Methods mempty :: Constant a b Source # mappend :: Constant a b -> Constant a b -> Constant a b Source # mconcat :: [Constant a b] -> Constant a b Source #
Semigroup a => Semigroup (Constant a b) |
Instance details Defined in Data.Functor.Constant Methods (<>) :: Constant a b -> Constant a b -> Constant a b Source # sconcat :: NonEmpty (Constant a b) -> Constant a b Source # stimes :: Integral b0 => b0 -> Constant a b -> Constant a b Source #
Read a => Read (Constant a b) |
Instance details Defined in Data.Functor.Constant Methods readsPrec :: Int -> ReadS (Constant a b) Source # readList :: ReadS [Constant a b] Source # readPrec :: ReadPrec (Constant a b) Source # readListPrec :: ReadPrec [Constant a b] Source #
Show a => Show (Constant a b) |
Instance details Defined in Data.Functor.Constant Methods showsPrec :: Int -> Constant a b -> ShowS Source # show :: Constant a b -> String Source # showList :: [Constant a b] -> ShowS Source #
Eq a => Eq (Constant a b) |
Instance details Defined in Data.Functor.Constant Methods (==) :: Constant a b -> Constant a b -> Bool Source # (/=) :: Constant a b -> Constant a b -> Bool Source #
Ord a => Ord (Constant a b) |

Instance details

Defined in Data.Functor.Constant

Methods

compare :: Constant a b -> Constant a b -> Ordering Source #

(<) :: Constant a b -> Constant a b -> Bool Source #

(<=) :: Constant a b -> Constant a b -> Bool Source #

(>) :: Constant a b -> Constant a b -> Bool Source #

(>=) :: Constant a b -> Constant a b -> Bool Source #

max :: Constant a b -> Constant a b -> Constant a b Source #

min :: Constant a b -> Constant a b -> Constant a b Source #

data Identity a Source #

Identity functor and monad. (a non-strict monad)

Since: base-4.8.0.0

#### Instances

Instances details

MonadFix Identity | Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity Methods mfix :: (a -> Identity a) -> Identity a Source #
Foldable Identity | Since: base-4.8.0.0

Instance details

Defined in Data.Functor.Identity

Methods

fold :: Monoid m => Identity m -> m Source #

foldMap :: Monoid m => (a -> m) -> Identity a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Identity a -> m Source #

foldr :: (a -> b -> b) -> b -> Identity a -> b Source #

foldr' :: (a -> b -> b) -> b -> Identity a -> b Source #

foldl :: (b -> a -> b) -> b -> Identity a -> b Source #

foldl' :: (b -> a -> b) -> b -> Identity a -> b Source #

foldr1 :: (a -> a -> a) -> Identity a -> a Source #

foldl1 :: (a -> a -> a) -> Identity a -> a Source #

toList :: Identity a -> [a] Source #

null :: Identity a -> Bool Source #

length :: Identity a -> Int Source #

elem :: Eq a => a -> Identity a -> Bool Source #

maximum :: Ord a => Identity a -> a Source #

minimum :: Ord a => Identity a -> a Source #

sum :: Num a => Identity a -> a Source #

product :: Num a => Identity a -> a Source #

Eq1 Identity | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Classes Methods liftEq :: (a -> b -> Bool) -> Identity a -> Identity b -> Bool Source #
Ord1 Identity | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Classes Methods liftCompare :: (a -> b -> Ordering) -> Identity a -> Identity b -> Ordering Source #
Read1 Identity | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Classes Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Identity a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Identity a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Identity a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Identity a] Source #
Show1 Identity | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Classes Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Identity a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Identity a] -> ShowS Source #
Traversable Identity | Since: base-4.9.0.0
Instance details Defined in Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Identity a -> f (Identity b) Source # sequenceA :: Applicative f => Identity (f a) -> f (Identity a) Source # mapM :: Monad m => (a -> m b) -> Identity a -> m (Identity b) Source # sequence :: Monad m => Identity (m a) -> m (Identity a) Source #
Applicative Identity | Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity Methods pure :: a -> Identity a Source # (<*>) :: Identity (a -> b) -> Identity a -> Identity b Source # liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c Source # (*>) :: Identity a -> Identity b -> Identity b Source # (<*) :: Identity a -> Identity b -> Identity a Source #
Functor Identity | Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity Methods fmap :: (a -> b) -> Identity a -> Identity b Source # (<$) :: a -> Identity b -> Identity a Source #
Monad Identity | Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity Methods (>>=) :: Identity a -> (a -> Identity b) -> Identity b Source # (>>) :: Identity a -> Identity b -> Identity b Source # return :: a -> Identity a Source #
Identical Identity Source # |
Instance details Defined in Lens.Family.Identical Methods extract :: Identity a -> a
Generic1 Identity |
Instance details Defined in Data.Functor.Identity Associated Types type Rep1 Identity :: k -> Type Source # Methods from1 :: forall (a :: k). Identity a -> Rep1 Identity a Source # to1 :: forall (a :: k). Rep1 Identity a -> Identity a Source #
Storable a => Storable (Identity a) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Identity

Methods

sizeOf :: Identity a -> Int Source #

alignment :: Identity a -> Int Source #

peekElemOff :: Ptr (Identity a) -> Int -> IO (Identity a) Source #

pokeElemOff :: Ptr (Identity a) -> Int -> Identity a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (Identity a) Source #

pokeByteOff :: Ptr b -> Int -> Identity a -> IO () Source #

peek :: Ptr (Identity a) -> IO (Identity a) Source #

poke :: Ptr (Identity a) -> Identity a -> IO () Source #

Monoid a => Monoid (Identity a) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods mempty :: Identity a Source # mappend :: Identity a -> Identity a -> Identity a Source # mconcat :: [Identity a] -> Identity a Source #
Semigroup a => Semigroup (Identity a) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods (<>) :: Identity a -> Identity a -> Identity a Source # sconcat :: NonEmpty (Identity a) -> Identity a Source # stimes :: Integral b => b -> Identity a -> Identity a Source #
Bits a => Bits (Identity a) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Identity

Methods

(.&.) :: Identity a -> Identity a -> Identity a Source #

(.|.) :: Identity a -> Identity a -> Identity a Source #

xor :: Identity a -> Identity a -> Identity a Source #

complement :: Identity a -> Identity a Source #

shift :: Identity a -> Int -> Identity a Source #

rotate :: Identity a -> Int -> Identity a Source #

zeroBits :: Identity a Source #

bit :: Int -> Identity a Source #

setBit :: Identity a -> Int -> Identity a Source #

clearBit :: Identity a -> Int -> Identity a Source #

complementBit :: Identity a -> Int -> Identity a Source #

testBit :: Identity a -> Int -> Bool Source #

bitSizeMaybe :: Identity a -> Maybe Int Source #

bitSize :: Identity a -> Int Source #

isSigned :: Identity a -> Bool Source #

shiftL :: Identity a -> Int -> Identity a Source #

unsafeShiftL :: Identity a -> Int -> Identity a Source #

shiftR :: Identity a -> Int -> Identity a Source #

unsafeShiftR :: Identity a -> Int -> Identity a Source #

rotateL :: Identity a -> Int -> Identity a Source #

rotateR :: Identity a -> Int -> Identity a Source #

popCount :: Identity a -> Int Source #

FiniteBits a => FiniteBits (Identity a) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods finiteBitSize :: Identity a -> Int Source # countLeadingZeros :: Identity a -> Int Source # countTrailingZeros :: Identity a -> Int Source #
Bounded a => Bounded (Identity a) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods minBound :: Identity a Source # maxBound :: Identity a Source #
Enum a => Enum (Identity a) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Identity

Methods

succ :: Identity a -> Identity a Source #

pred :: Identity a -> Identity a Source #

toEnum :: Int -> Identity a Source #

fromEnum :: Identity a -> Int Source #

enumFrom :: Identity a -> [Identity a] Source #

enumFromThen :: Identity a -> Identity a -> [Identity a] Source #

enumFromTo :: Identity a -> Identity a -> [Identity a] Source #

enumFromThenTo :: Identity a -> Identity a -> Identity a -> [Identity a] Source #

Floating a => Floating (Identity a) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Identity

Methods

pi :: Identity a Source #

exp :: Identity a -> Identity a Source #

log :: Identity a -> Identity a Source #

sqrt :: Identity a -> Identity a Source #

(**) :: Identity a -> Identity a -> Identity a Source #

logBase :: Identity a -> Identity a -> Identity a Source #

sin :: Identity a -> Identity a Source #

cos :: Identity a -> Identity a Source #

tan :: Identity a -> Identity a Source #

asin :: Identity a -> Identity a Source #

acos :: Identity a -> Identity a Source #

atan :: Identity a -> Identity a Source #

sinh :: Identity a -> Identity a Source #

cosh :: Identity a -> Identity a Source #

tanh :: Identity a -> Identity a Source #

asinh :: Identity a -> Identity a Source #

acosh :: Identity a -> Identity a Source #

atanh :: Identity a -> Identity a Source #

log1p :: Identity a -> Identity a Source #

expm1 :: Identity a -> Identity a Source #

log1pexp :: Identity a -> Identity a Source #

log1mexp :: Identity a -> Identity a Source #

RealFloat a => RealFloat (Identity a) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Identity

Methods

floatRadix :: Identity a -> Integer Source #

floatDigits :: Identity a -> Int Source #

floatRange :: Identity a -> (Int, Int) Source #

decodeFloat :: Identity a -> (Integer, Int) Source #

encodeFloat :: Integer -> Int -> Identity a Source #

exponent :: Identity a -> Int Source #

significand :: Identity a -> Identity a Source #

scaleFloat :: Int -> Identity a -> Identity a Source #

isNaN :: Identity a -> Bool Source #

isInfinite :: Identity a -> Bool Source #

isDenormalized :: Identity a -> Bool Source #

isNegativeZero :: Identity a -> Bool Source #

isIEEE :: Identity a -> Bool Source #

atan2 :: Identity a -> Identity a -> Identity a Source #

Generic (Identity a) |
Instance details Defined in Data.Functor.Identity Associated Types type Rep (Identity a) :: Type -> Type Source # Methods from :: Identity a -> Rep (Identity a) x Source # to :: Rep (Identity a) x -> Identity a Source #
Ix a => Ix (Identity a) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Identity

Methods

range :: (Identity a, Identity a) -> [Identity a] Source #

index :: (Identity a, Identity a) -> Identity a -> Int Source #

unsafeIndex :: (Identity a, Identity a) -> Identity a -> Int Source #

inRange :: (Identity a, Identity a) -> Identity a -> Bool Source #

rangeSize :: (Identity a, Identity a) -> Int Source #

unsafeRangeSize :: (Identity a, Identity a) -> Int Source #

Num a => Num (Identity a) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods (+) :: Identity a -> Identity a -> Identity a Source # (-) :: Identity a -> Identity a -> Identity a Source # (*) :: Identity a -> Identity a -> Identity a Source # negate :: Identity a -> Identity a Source # abs :: Identity a -> Identity a Source # signum :: Identity a -> Identity a Source # fromInteger :: Integer -> Identity a Source #
Read a => Read (Identity a) | This instance would be equivalent to the derived instances of the `Identity` newtype if the `runIdentity` field were removed Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity Methods readsPrec :: Int -> ReadS (Identity a) Source # readList :: ReadS [Identity a] Source # readPrec :: ReadPrec (Identity a) Source # readListPrec :: ReadPrec [Identity a] Source #
Fractional a => Fractional (Identity a) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods (/) :: Identity a -> Identity a -> Identity a Source # recip :: Identity a -> Identity a Source # fromRational :: Rational -> Identity a Source #
Integral a => Integral (Identity a) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Identity

Methods

quot :: Identity a -> Identity a -> Identity a Source #

rem :: Identity a -> Identity a -> Identity a Source #

div :: Identity a -> Identity a -> Identity a Source #

mod :: Identity a -> Identity a -> Identity a Source #

quotRem :: Identity a -> Identity a -> (Identity a, Identity a) Source #

divMod :: Identity a -> Identity a -> (Identity a, Identity a) Source #

toInteger :: Identity a -> Integer Source #

Real a => Real (Identity a) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods toRational :: Identity a -> Rational Source #
RealFrac a => RealFrac (Identity a) | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods properFraction :: Integral b => Identity a -> (b, Identity a) Source # truncate :: Integral b => Identity a -> b Source # round :: Integral b => Identity a -> b Source # ceiling :: Integral b => Identity a -> b Source # floor :: Integral b => Identity a -> b Source #
Show a => Show (Identity a) | This instance would be equivalent to the derived instances of the `Identity` newtype if the `runIdentity` field were removed Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity Methods showsPrec :: Int -> Identity a -> ShowS Source # show :: Identity a -> String Source # showList :: [Identity a] -> ShowS Source #
Eq a => Eq (Identity a) | Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity Methods (==) :: Identity a -> Identity a -> Bool Source # (/=) :: Identity a -> Identity a -> Bool Source #
Ord a => Ord (Identity a) | Since: base-4.8.0.0

Instance details

Defined in Data.Functor.Identity

Methods

compare :: Identity a -> Identity a -> Ordering Source #

(<) :: Identity a -> Identity a -> Bool Source #

(<=) :: Identity a -> Identity a -> Bool Source #

(>) :: Identity a -> Identity a -> Bool Source #

(>=) :: Identity a -> Identity a -> Bool Source #

max :: Identity a -> Identity a -> Identity a Source #

min :: Identity a -> Identity a -> Identity a Source #

type Rep1 Identity | Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity type Rep1 Identity = D1 ('MetaData "Identity" "Data.Functor.Identity" "base" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Identity a) | Since: base-4.8.0.0
Instance details Defined in Data.Functor.Identity type Rep (Identity a) = D1 ('MetaData "Identity" "Data.Functor.Identity" "base" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

type Prod = Product Source #

data All Source #

Boolean monoid under conjunction (`&&`).

    >>> getAll (All True <> mempty <> All False)
    False

    >>> getAll (mconcat (map (\x -> All (even x)) [2,4,6,7,8]))
    False

#### Instances

Instances details

Monoid All | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods mempty :: All Source # mappend :: All -> All -> All Source # mconcat :: [All] -> All Source #
Semigroup All | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup.Internal Methods (<>) :: All -> All -> All Source # sconcat :: NonEmpty All -> All Source # stimes :: Integral b => b -> All -> All Source #
Bounded All | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods minBound :: All Source # maxBound :: All Source #
Generic All |
Instance details Defined in Data.Semigroup.Internal Associated Types type Rep All :: Type -> Type Source # Methods from :: All -> Rep All x Source # to :: Rep All x -> All Source #
Read All | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS All Source # readList :: ReadS [All] Source # readPrec :: ReadPrec All Source # readListPrec :: ReadPrec [All] Source #
Show All | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods showsPrec :: Int -> All -> ShowS Source # show :: All -> String Source # showList :: [All] -> ShowS Source #
Eq All | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods (==) :: All -> All -> Bool Source # (/=) :: All -> All -> Bool Source #
Ord All | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods compare :: All -> All -> Ordering Source # (<) :: All -> All -> Bool Source # (<=) :: All -> All -> Bool Source # (>) :: All -> All -> Bool Source # (>=) :: All -> All -> Bool Source # max :: All -> All -> All Source # min :: All -> All -> All Source #
type Rep All | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal type Rep All = D1 ('MetaData "All" "Data.Semigroup.Internal" "base" 'True) (C1 ('MetaCons "All" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAll") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

data Any Source #

Boolean monoid under disjunction (`||`).

    >>> getAny (Any True <> mempty <> Any False)
    True

    >>> getAny (mconcat (map (\x -> Any (even x)) [2,4,6,7,8]))
    True

#### Instances

Instances details

Monoid Any | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods mempty :: Any Source # mappend :: Any -> Any -> Any Source # mconcat :: [Any] -> Any Source #
Semigroup Any | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup.Internal Methods (<>) :: Any -> Any -> Any Source # sconcat :: NonEmpty Any -> Any Source # stimes :: Integral b => b -> Any -> Any Source #
Bounded Any | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods minBound :: Any Source # maxBound :: Any Source #
Generic Any |
Instance details Defined in Data.Semigroup.Internal Associated Types type Rep Any :: Type -> Type Source # Methods from :: Any -> Rep Any x Source # to :: Rep Any x -> Any Source #
Read Any | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS Any Source # readList :: ReadS [Any] Source # readPrec :: ReadPrec Any Source # readListPrec :: ReadPrec [Any] Source #
Show Any | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods showsPrec :: Int -> Any -> ShowS Source # show :: Any -> String Source # showList :: [Any] -> ShowS Source #
Eq Any | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods (==) :: Any -> Any -> Bool Source # (/=) :: Any -> Any -> Bool Source #
Ord Any | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods compare :: Any -> Any -> Ordering Source # (<) :: Any -> Any -> Bool Source # (<=) :: Any -> Any -> Bool Source # (>) :: Any -> Any -> Bool Source # (>=) :: Any -> Any -> Bool Source # max :: Any -> Any -> Any Source # min :: Any -> Any -> Any Source #
type Rep Any | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal type Rep Any = D1 ('MetaData "Any" "Data.Semigroup.Internal" "base" 'True) (C1 ('MetaCons "Any" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAny") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

data Sum a Source #

Monoid under addition.

    >>> getSum (Sum 1 <> Sum 2 <> mempty)
    3

#### Instances

Instances details

Foldable Sum | Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Sum m -> m Source #

foldMap :: Monoid m => (a -> m) -> Sum a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Sum a -> m Source #

foldr :: (a -> b -> b) -> b -> Sum a -> b Source #

foldr' :: (a -> b -> b) -> b -> Sum a -> b Source #

foldl :: (b -> a -> b) -> b -> Sum a -> b Source #

foldl' :: (b -> a -> b) -> b -> Sum a -> b Source #

foldr1 :: (a -> a -> a) -> Sum a -> a Source #

foldl1 :: (a -> a -> a) -> Sum a -> a Source #

toList :: Sum a -> [a] Source #

null :: Sum a -> Bool Source #

length :: Sum a -> Int Source #

elem :: Eq a => a -> Sum a -> Bool Source #

maximum :: Ord a => Sum a -> a Source #

minimum :: Ord a => Sum a -> a Source #

sum :: Num a => Sum a -> a Source #

product :: Num a => Sum a -> a Source #

Traversable Sum | Since: base-4.8.0.0
Instance details Defined in Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Sum a -> f (Sum b) Source # sequenceA :: Applicative f => Sum (f a) -> f (Sum a) Source # mapM :: Monad m => (a -> m b) -> Sum a -> m (Sum b) Source # sequence :: Monad m => Sum (m a) -> m (Sum a) Source #
Applicative Sum | Since: base-4.8.0.0
Instance details Defined in Data.Semigroup.Internal Methods pure :: a -> Sum a Source # (<*>) :: Sum (a -> b) -> Sum a -> Sum b Source # liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c Source # (*>) :: Sum a -> Sum b -> Sum b Source # (<*) :: Sum a -> Sum b -> Sum a Source #
Functor Sum | Since: base-4.8.0.0
Instance details Defined in Data.Semigroup.Internal Methods fmap :: (a -> b) -> Sum a -> Sum b Source # (<$) :: a -> Sum b -> Sum a Source #
Monad Sum | Since: base-4.8.0.0
Instance details Defined in Data.Semigroup.Internal Methods (>>=) :: Sum a -> (a -> Sum b) -> Sum b Source # (>>) :: Sum a -> Sum b -> Sum b Source # return :: a -> Sum a Source #
Generic1 Sum |
Instance details Defined in Data.Semigroup.Internal Associated Types type Rep1 Sum :: k -> Type Source # Methods from1 :: forall (a :: k). Sum a -> Rep1 Sum a Source # to1 :: forall (a :: k). Rep1 Sum a -> Sum a Source #
Num a => Monoid (Sum a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods mempty :: Sum a Source # mappend :: Sum a -> Sum a -> Sum a Source # mconcat :: [Sum a] -> Sum a Source #
Num a => Semigroup (Sum a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup.Internal Methods (<>) :: Sum a -> Sum a -> Sum a Source # sconcat :: NonEmpty (Sum a) -> Sum a Source # stimes :: Integral b => b -> Sum a -> Sum a Source #
Bounded a => Bounded (Sum a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods minBound :: Sum a Source # maxBound :: Sum a Source #
Generic (Sum a) |
Instance details Defined in Data.Semigroup.Internal Associated Types type Rep (Sum a) :: Type -> Type Source # Methods from :: Sum a -> Rep (Sum a) x Source # to :: Rep (Sum a) x -> Sum a Source #
Num a => Num (Sum a) | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal Methods (+) :: Sum a -> Sum a -> Sum a Source # (-) :: Sum a -> Sum a -> Sum a Source # (*) :: Sum a -> Sum a -> Sum a Source # negate :: Sum a -> Sum a Source # abs :: Sum a -> Sum a Source # signum :: Sum a -> Sum a Source # fromInteger :: Integer -> Sum a Source #
Read a => Read (Sum a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS (Sum a) Source # readList :: ReadS [Sum a] Source # readPrec :: ReadPrec (Sum a) Source # readListPrec :: ReadPrec [Sum a] Source #
Show a => Show (Sum a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods showsPrec :: Int -> Sum a -> ShowS Source # show :: Sum a -> String Source # showList :: [Sum a] -> ShowS Source #
Eq a => Eq (Sum a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods (==) :: Sum a -> Sum a -> Bool Source # (/=) :: Sum a -> Sum a -> Bool Source #
Ord a => Ord (Sum a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods compare :: Sum a -> Sum a -> Ordering Source # (<) :: Sum a -> Sum a -> Bool Source # (<=) :: Sum a -> Sum a -> Bool Source # (>) :: Sum a -> Sum a -> Bool Source # (>=) :: Sum a -> Sum a -> Bool Source # max :: Sum a -> Sum a -> Sum a Source # min :: Sum a -> Sum a -> Sum a Source #
type Rep1 Sum | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal type Rep1 Sum = D1 ('MetaData "Sum" "Data.Semigroup.Internal" "base" 'True) (C1 ('MetaCons "Sum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Sum a) | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal type Rep (Sum a) = D1 ('MetaData "Sum" "Data.Semigroup.Internal" "base" 'True) (C1 ('MetaCons "Sum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

data Product a Source #

Monoid under multiplication.

    >>> getProduct (Product 3 <> Product 4 <> mempty)
    12

#### Instances

Instances details

Foldable Product | Since: base-4.8.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Product m -> m Source #

foldMap :: Monoid m => (a -> m) -> Product a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Product a -> m Source #

foldr :: (a -> b -> b) -> b -> Product a -> b Source #

foldr' :: (a -> b -> b) -> b -> Product a -> b Source #

foldl :: (b -> a -> b) -> b -> Product a -> b Source #

foldl' :: (b -> a -> b) -> b -> Product a -> b Source #

foldr1 :: (a -> a -> a) -> Product a -> a Source #

foldl1 :: (a -> a -> a) -> Product a -> a Source #

toList :: Product a -> [a] Source #

null :: Product a -> Bool Source #

length :: Product a -> Int Source #

elem :: Eq a => a -> Product a -> Bool Source #

maximum :: Ord a => Product a -> a Source #

minimum :: Ord a => Product a -> a Source #

sum :: Num a => Product a -> a Source #

product :: Num a => Product a -> a Source #

Traversable Product | Since: base-4.8.0.0
Instance details Defined in Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Product a -> f (Product b) Source # sequenceA :: Applicative f => Product (f a) -> f (Product a) Source # mapM :: Monad m => (a -> m b) -> Product a -> m (Product b) Source # sequence :: Monad m => Product (m a) -> m (Product a) Source #
Applicative Product | Since: base-4.8.0.0
Instance details Defined in Data.Semigroup.Internal Methods pure :: a -> Product a Source # (<*>) :: Product (a -> b) -> Product a -> Product b Source # liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c Source # (*>) :: Product a -> Product b -> Product b Source # (<*) :: Product a -> Product b -> Product a Source #
Functor Product | Since: base-4.8.0.0
Instance details Defined in Data.Semigroup.Internal Methods fmap :: (a -> b) -> Product a -> Product b Source # (<$) :: a -> Product b -> Product a Source #
Monad Product | Since: base-4.8.0.0
Instance details Defined in Data.Semigroup.Internal Methods (>>=) :: Product a -> (a -> Product b) -> Product b Source # (>>) :: Product a -> Product b -> Product b Source # return :: a -> Product a Source #
Generic1 Product |
Instance details Defined in Data.Semigroup.Internal Associated Types type Rep1 Product :: k -> Type Source # Methods from1 :: forall (a :: k). Product a -> Rep1 Product a Source # to1 :: forall (a :: k). Rep1 Product a -> Product a Source #
Num a => Monoid (Product a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods mempty :: Product a Source # mappend :: Product a -> Product a -> Product a Source # mconcat :: [Product a] -> Product a Source #
Num a => Semigroup (Product a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup.Internal Methods (<>) :: Product a -> Product a -> Product a Source # sconcat :: NonEmpty (Product a) -> Product a Source # stimes :: Integral b => b -> Product a -> Product a Source #
Bounded a => Bounded (Product a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods minBound :: Product a Source # maxBound :: Product a Source #
Generic (Product a) |
Instance details Defined in Data.Semigroup.Internal Associated Types type Rep (Product a) :: Type -> Type Source # Methods from :: Product a -> Rep (Product a) x Source # to :: Rep (Product a) x -> Product a Source #
Num a => Num (Product a) | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal Methods (+) :: Product a -> Product a -> Product a Source # (-) :: Product a -> Product a -> Product a Source # (*) :: Product a -> Product a -> Product a Source # negate :: Product a -> Product a Source # abs :: Product a -> Product a Source # signum :: Product a -> Product a Source # fromInteger :: Integer -> Product a Source #
Read a => Read (Product a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS (Product a) Source # readList :: ReadS [Product a] Source # readPrec :: ReadPrec (Product a) Source # readListPrec :: ReadPrec [Product a] Source #
Show a => Show (Product a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods showsPrec :: Int -> Product a -> ShowS Source # show :: Product a -> String Source # showList :: [Product a] -> ShowS Source #
Eq a => Eq (Product a) | Since: base-2.1
Instance details Defined in Data.Semigroup.Internal Methods (==) :: Product a -> Product a -> Bool Source # (/=) :: Product a -> Product a -> Bool Source #
Ord a => Ord (Product a) | Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Methods

compare :: Product a -> Product a -> Ordering Source #

(<) :: Product a -> Product a -> Bool Source #

(<=) :: Product a -> Product a -> Bool Source #

(>) :: Product a -> Product a -> Bool Source #

(>=) :: Product a -> Product a -> Bool Source #

max :: Product a -> Product a -> Product a Source #

min :: Product a -> Product a -> Product a Source #

type Rep1 Product | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal type Rep1 Product = D1 ('MetaData "Product" "Data.Semigroup.Internal" "base" 'True) (C1 ('MetaCons "Product" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProduct") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Product a) | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal type Rep (Product a) = D1 ('MetaData "Product" "Data.Semigroup.Internal" "base" 'True) (C1 ('MetaCons "Product" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProduct") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))