validity-0.12.1.0: Validity typeclass

Safe Haskell | None
Language | Haskell2010

Data.Validity

Contents

- Helper functions to define `validate`
  - Helpers for specific types
    - Char
    - RealFloat (Double)
    - Ratio
- Utilities
  - Utilities for validity checking
  - Utilities for validation
- Re-exports

Description

`Validity` is used to specify additional invariants upon values that are not enforced by the type system.

Let's take an example. Suppose we were to implement a type `Prime` that represents prime integers.

If you were to completely enforce the invariant that the represented number is a prime, then we could use `Natural` and only store the index of the given prime in the infinite sequence of prime numbers. This is very safe but also very expensive if we ever want to use the number, because we would have to calculcate all the prime numbers until that index.

Instead we choose to implement `Prime` by a `newtype Prime = Prime Int`. Now we have to maintain the invariant that the `Int` that we use to represent the prime is in fact positive and a prime.

The `Validity` typeclass allows us to specify this invariant (and enables testing via the `genvalidity` libraries: https://hackage.haskell.org/package/genvalidity ):

    instance Validity Prime where
        validate (Prime n) = check (isPrime n) "The 'Int' is prime."

If certain typeclass invariants exist, you can make these explicit in the validity instance as well. For example, 'Fixed a' is only valid if `a` has an `HasResolution` instance, so the correct validity instance is `HasResolution a => Validity (Fixed a)`.

Synopsis

- class Validity a where
  - validate :: a -> Validation
- trivialValidation :: a -> Validation
- genericValidate :: (Generic a, GValidity (Rep a)) => a -> Validation
- check :: Bool -> String -> Validation
- declare :: String -> Bool -> Validation
- annotate :: Validity a => a -> String -> Validation
- delve :: Validity a => String -> a -> Validation
- decorate :: String -> Validation -> Validation
- decorateList :: [a] -> (a -> Validation) -> Validation
- decorateString :: String -> (Char -> Validation) -> Validation
- invalid :: String -> Validation
- valid :: Validation
- validateCharNotUtf16SurrogateCodePoint :: Char -> Validation
- isUtf16SurrogateCodePoint :: Char -> Bool
- validateCharNotLineSeparator :: Char -> Validation
- isLineSeparator :: Char -> Bool
- validateStringSingleLine :: String -> Validation
- isSingleLine :: String -> Bool
- validateNotNaN :: RealFloat a => a -> Validation
- validateNotInfinite :: RealFloat a => a -> Validation
- validateRatioNotNaN :: Integral a => Ratio a -> Validation
- validateRatioNotInfinite :: Integral a => Ratio a -> Validation
- validateRatioNormalised :: Integral a => Ratio a -> Validation
- isValid :: Validity a => a -> Bool
- isInvalid :: Validity a => a -> Bool
- constructValid :: Validity a => a -> Maybe a
- constructValidUnsafe :: (Show a, Validity a) => a -> a
- newtype Validation = Validation {
  - unValidation :: [ValidationChain]
  }
- data ValidationChain
  - = Violated String
  - | Location String ValidationChain
- checkValidity :: Validity a => a -> Either [ValidationChain] a
- validationIsValid :: Validation -> Bool
- prettyValidate :: Validity a => a -> Either String a
- prettyValidation :: Validation -> Maybe String
- class Semigroup a => Monoid a where
  - mempty :: a
  - mappend :: a -> a -> a
  - mconcat :: [a] -> a
- class Semigroup a where
  - (<>) :: a -> a -> a
  - sconcat :: NonEmpty a -> a
  - stimes :: Integral b => b -> a -> a

# Documentation

class Validity a where Source #

A class of types that have additional invariants defined upon them

Minimal complete definition

Nothing

Methods

validate :: a -> Validation Source #

default validate :: (Generic a, GValidity (Rep a)) => a -> Validation Source #

#### Instances

Instances details

Validity Int16 Source # |
Instance details Defined in Data.Validity Methods validate :: Int16 -> Validation Source #
Validity Int32 Source # |
Instance details Defined in Data.Validity Methods validate :: Int32 -> Validation Source #
Validity Int64 Source # | Trivially valid
Instance details Defined in Data.Validity Methods validate :: Int64 -> Validation Source #
Validity Int8 Source # |
Instance details Defined in Data.Validity Methods validate :: Int8 -> Validation Source #
Validity Word16 Source # |
Instance details Defined in Data.Validity Methods validate :: Word16 -> Validation Source #
Validity Word32 Source # |
Instance details Defined in Data.Validity Methods validate :: Word32 -> Validation Source #
Validity Word64 Source # | Trivially valid
Instance details Defined in Data.Validity Methods validate :: Word64 -> Validation Source #
Validity Word8 Source # |
Instance details Defined in Data.Validity Methods validate :: Word8 -> Validation Source #
Validity Ordering Source # | Trivially valid
Instance details Defined in Data.Validity Methods validate :: Ordering -> Validation Source #
Validity ValidationChain Source # |
Instance details Defined in Data.Validity Methods validate :: ValidationChain -> Validation Source #

Validity Integer Source #

Trivially valid

Integer is not trivially valid under the hood, but instantiating `Validity` correctly would force validity to depend on a specific (big integer library `integer-gmp` versus `integer-simple`). This is rather impractical so for the time being we have opted for assuming that an `Integer` is always valid. Even though this is not technically sound, it is good enough for now.

Instance details Defined in Data.Validity Methods validate :: Integer -> Validation Source #
Validity Natural Source # | Valid according to `isValidNatural`
Instance details Defined in Data.Validity Methods validate :: Natural -> Validation Source #
Validity () Source # | Trivially valid
Instance details Defined in Data.Validity Methods validate :: () -> Validation Source #
Validity Bool Source # | Trivially valid
Instance details Defined in Data.Validity Methods validate :: Bool -> Validation Source #
Validity Char Source # | Trivially valid
Instance details Defined in Data.Validity Methods validate :: Char -> Validation Source #
Validity Double Source # | Trivially valid:
Instance details Defined in Data.Validity Methods validate :: Double -> Validation Source #
Validity Float Source # | Trivially valid:
Instance details Defined in Data.Validity Methods validate :: Float -> Validation Source #
Validity Int Source # | Trivially valid
Instance details Defined in Data.Validity Methods validate :: Int -> Validation Source #
Validity Word Source # | Trivially valid
Instance details Defined in Data.Validity Methods validate :: Word -> Validation Source #
Validity a => Validity (First a) Source # | Valid values the same as it's base type:
Instance details Defined in Data.Validity Methods validate :: First a -> Validation Source #
Validity a => Validity (Last a) Source # | Valid values the same as it's base type:
Instance details Defined in Data.Validity Methods validate :: Last a -> Validation Source #
Validity a => Validity (NonEmpty a) Source # | A nonempty list is valid if all the elements are valid. See the instance for 'Validity [a]' for more information.
Instance details Defined in Data.Validity Methods validate :: NonEmpty a -> Validation Source #
Validity a => Validity (Identity a) Source # | Valid values the same as it's base type:
Instance details Defined in Data.Validity Methods validate :: Identity a -> Validation Source #
Validity a => Validity (First a) Source # | Valid values the same as it's base type:
Instance details Defined in Data.Validity Methods validate :: First a -> Validation Source #
Validity a => Validity (Last a) Source # | Valid values the same as it's base type:
Instance details Defined in Data.Validity Methods validate :: Last a -> Validation Source #
Validity a => Validity (Dual a) Source # | Valid values the same as it's base type:
Instance details Defined in Data.Validity Methods validate :: Dual a -> Validation Source #
(Validity a, Ord a, Num a, Integral a) => Validity (Ratio a) Source # | Valid if the contained numbers are valid and the denominator is strictly positive.
Instance details Defined in Data.Validity Methods validate :: Ratio a -> Validation Source #
Validity a => Validity (Maybe a) Source # | A Maybe thing is valid if the thing inside is valid or it's nothing It makes sense to assume that `Nothing` is valid. If Nothing wasn't valid, you wouldn't have used a Maybe in the datastructure.
Instance details Defined in Data.Validity Methods validate :: Maybe a -> Validation Source #
Validity a => Validity [a] Source # | A list of things is valid if all of the things are valid. This means that the empty list is considered valid. If the empty list should not be considered valid as part of your custom data type, make sure to write a custom `Validity instance`
Instance details Defined in Data.Validity Methods validate :: [a] -> Validation Source #
HasResolution a => Validity (Fixed a) Source # | Valid according to the contained `Integer`.
Instance details Defined in Data.Validity Methods validate :: Fixed a -> Validation Source #
(Validity a, Validity b) => Validity (Either a b) Source # | Any Either of things is valid if the contents are valid in either of the cases.
Instance details Defined in Data.Validity Methods validate :: Either a b -> Validation Source #
(Validity a, Validity b) => Validity (a, b) Source # | Any tuple of things is valid if both of its elements are valid
Instance details Defined in Data.Validity Methods validate :: (a, b) -> Validation Source #
Validity a => Validity (Const a b) Source # | Valid values the same as it's base type:
Instance details Defined in Data.Validity Methods validate :: Const a b -> Validation Source #
Validity (f a) => Validity (Alt f a) Source # | Valid values the same as it's base type:
Instance details Defined in Data.Validity Methods validate :: Alt f a -> Validation Source #
(Validity a, Validity b, Validity c) => Validity (a, b, c) Source # | Any triple of things is valid if all three of its elements are valid
Instance details Defined in Data.Validity Methods validate :: (a, b, c) -> Validation Source #
(Validity a, Validity b, Validity c, Validity d) => Validity (a, b, c, d) Source # | Any quadruple of things is valid if all four of its elements are valid
Instance details Defined in Data.Validity Methods validate :: (a, b, c, d) -> Validation Source #
(Validity a, Validity b, Validity c, Validity d, Validity e) => Validity (a, b, c, d, e) Source # | Any quintuple of things is valid if all five of its elements are valid
Instance details Defined in Data.Validity Methods validate :: (a, b, c, d, e) -> Validation Source #
(Validity a, Validity b, Validity c, Validity d, Validity e, Validity f) => Validity (a, b, c, d, e, f) Source # | Any sextuple of things is valid if all six of its elements are valid
Instance details Defined in Data.Validity Methods validate :: (a, b, c, d, e, f) -> Validation Source #

# Helper functions to define `validate`

trivialValidation :: a -> Validation Source #

Declare any value to be valid in validation

    trivialValidation a = seq a mempty

genericValidate :: (Generic a, GValidity (Rep a)) => a -> Validation Source #

check :: Bool -> String -> Validation Source #

Check that a given invariant holds.

The given string should describe the invariant, not the violation.

Example:

    check (x < 5) "x is strictly smaller than 5"

instead of

    check (x < 5) "x is greater than 5"

declare :: String -> Bool -> Validation Source #

`check`, but with the arguments flipped

annotate :: Validity a => a -> String -> Validation Source #

Declare a sub-part as a necessary part for validation, and annotate it with a name.

Example:

    validate (a, b) =
        mconcat
            [ annotate a "The first element of the tuple"
            , annotate b "The second element of the tuple"
            ]

delve :: Validity a => String -> a -> Validation Source #

`annotate`, but with the arguments flipped.

decorate :: String -> Validation -> Validation Source #

Decorate a validation with a location

decorateList :: [a] -> (a -> Validation) -> Validation Source #

Decorate a piecewise validation of a list with their location in the list

decorateString :: String -> (Char -> Validation) -> Validation Source #

`decorateList`, but specifically for `String`s

    decorateString = decorateList

invalid :: String -> Validation Source #

Construct a trivially invalid `Validation`

Example:

    data Wrong
        = Wrong
        | Fine
        deriving (Show, Eq)

    instance Validity Wrong where
        validate w =
            case w of
                Wrong -> invalid "Wrong"
                Fine -> valid

valid :: Validation Source #

## Helpers for specific types

### Char

validateCharNotUtf16SurrogateCodePoint :: Char -> Validation Source #

isUtf16SurrogateCodePoint :: Char -> Bool Source #

validateCharNotLineSeparator :: Char -> Validation Source #

isLineSeparator :: Char -> Bool Source #

validateStringSingleLine :: String -> Validation Source #

isSingleLine :: String -> Bool Source #

### RealFloat (Double)

validateNotNaN :: RealFloat a => a -> Validation Source #

validateNotInfinite :: RealFloat a => a -> Validation Source #

### Ratio

validateRatioNotNaN :: Integral a => Ratio a -> Validation Source #

validateRatioNotInfinite :: Integral a => Ratio a -> Validation Source #

validateRatioNormalised :: Integral a => Ratio a -> Validation Source #

# Utilities

## Utilities for validity checking

isValid :: Validity a => a -> Bool Source #

Check whether a value is valid.

isInvalid :: Validity a => a -> Bool Source #

Check whether a value is not valid.

    isInvalid = not . isValid

constructValid :: Validity a => a -> Maybe a Source #

Construct a valid element from an unchecked element

constructValidUnsafe :: (Show a, Validity a) => a -> a Source #

Construct a valid element from an unchecked element, throwing `error` on invalid elements.

## Utilities for validation

newtype Validation Source #

The result of validating a value.

`mempty` means the value was valid.

This type intentionally doesn't have a `Validity` instance to make sure you can never accidentally use `annotate` or `delve` twice.

Constructors

Validation |

Fields

- unValidation :: [ValidationChain]

#### Instances

Instances details

Monoid Validation Source # |
Instance details Defined in Data.Validity Methods mempty :: Validation Source # mappend :: Validation -> Validation -> Validation Source # mconcat :: [Validation] -> Validation Source #
Semigroup Validation Source # |
Instance details Defined in Data.Validity Methods (<>) :: Validation -> Validation -> Validation Source # sconcat :: NonEmpty Validation -> Validation Source # stimes :: Integral b => b -> Validation -> Validation Source #
Generic Validation Source # |

Instance details

Defined in Data.Validity

Associated Types

type Rep Validation |
Instance details Defined in Data.Validity type Rep Validation = D1 ('MetaData "Validation" "Data.Validity" "validity-0.12.1.0-IBZlANNMVyMHKy5a2NhNBx" 'True) (C1 ('MetaCons "Validation" 'PrefixI 'True) (S1 ('MetaSel ('Just "unValidation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ValidationChain])))

Methods

from :: Validation -> Rep Validation x Source #

to :: Rep Validation x -> Validation Source #

Show Validation Source # |
Instance details Defined in Data.Validity Methods showsPrec :: Int -> Validation -> ShowS Source # show :: Validation -> String Source # showList :: [Validation] -> ShowS Source #
Eq Validation Source # |
Instance details Defined in Data.Validity Methods (==) :: Validation -> Validation -> Bool Source # (/=) :: Validation -> Validation -> Bool Source #
type Rep Validation Source # |
Instance details Defined in Data.Validity type Rep Validation = D1 ('MetaData "Validation" "Data.Validity" "validity-0.12.1.0-IBZlANNMVyMHKy5a2NhNBx" 'True) (C1 ('MetaCons "Validation" 'PrefixI 'True) (S1 ('MetaSel ('Just "unValidation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ValidationChain])))

data ValidationChain Source #

Constructors

Violated String |
Location String ValidationChain |

#### Instances

Instances details

Generic ValidationChain Source # |

Instance details

Defined in Data.Validity

Associated Types

type Rep ValidationChain |

Instance details

Defined in Data.Validity

type Rep ValidationChain = D1 ('MetaData "ValidationChain" "Data.Validity" "validity-0.12.1.0-IBZlANNMVyMHKy5a2NhNBx" 'False) (C1 ('MetaCons "Violated" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "Location" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidationChain)))

Methods

from :: ValidationChain -> Rep ValidationChain x Source #

to :: Rep ValidationChain x -> ValidationChain Source #

Show ValidationChain Source # |
Instance details Defined in Data.Validity Methods showsPrec :: Int -> ValidationChain -> ShowS Source # show :: ValidationChain -> String Source # showList :: [ValidationChain] -> ShowS Source #
Eq ValidationChain Source # |
Instance details Defined in Data.Validity Methods (==) :: ValidationChain -> ValidationChain -> Bool Source # (/=) :: ValidationChain -> ValidationChain -> Bool Source #
Validity ValidationChain Source # |
Instance details Defined in Data.Validity Methods validate :: ValidationChain -> Validation Source #
type Rep ValidationChain Source # |

Instance details

Defined in Data.Validity

type Rep ValidationChain = D1 ('MetaData "ValidationChain" "Data.Validity" "validity-0.12.1.0-IBZlANNMVyMHKy5a2NhNBx" 'False) (C1 ('MetaCons "Violated" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "Location" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidationChain)))

checkValidity :: Validity a => a -> Either [ValidationChain] a Source #

validate a given value.

This function returns either all the reasons why the given value is invalid, in the form of a list of `ValidationChain`s, or it returns `Right` with the input value, as evidence that it is valid.

Note: You may want to use `prettyValidation` instead, if you want to display these `ValidationChain`s to a user.

validationIsValid :: Validation -> Bool Source #

Check if a `Validation` concerns a valid value.

prettyValidate :: Validity a => a -> Either String a Source #

Validate a given value

This function will return a nice error if the value is invalid. It will return the original value in `Right` if it was valid, as evidence that it has been validated.

prettyValidation :: Validation -> Maybe String Source #

Render a `Validation` in a somewhat pretty way.

This function will return `Nothing` if the `Validation` concerned a valid value.

# Re-exports

class Semigroup a => Monoid a where Source #

The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:

Right identity
  `x `<>` `mempty` = x`
Left identity
  ``mempty` `<>` x = x`
Associativity
  `x `<>` (y `<>` z) = (x `<>` y) `<>` z` (`Semigroup` law)
Concatenation
  ``mconcat` = `foldr` (`<>`) `mempty``

You can alternatively define `mconcat` instead of `mempty`, in which case the laws are:

Unit
  ``mconcat` (`pure` x) = x`
Multiplication
  ``mconcat` (`join` xss) = `mconcat` (`fmap` `mconcat` xss)`
Subclass
  ``mconcat` (`toList` xs) = `sconcat` xs`

The method names refer to the monoid of lists under concatenation, but there are many other instances.

Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define `newtype`s and make those instances of `Monoid`, e.g. `Sum` and `Product`.

NOTE: `Semigroup` is a superclass of `Monoid` since base-4.11.0.0.

Minimal complete definition

mempty | mconcat

Methods

mempty :: a Source #

Identity of `mappend`

#### Examples

Expand

    >>> "Hello world" <> mempty
    "Hello world"

    >>> mempty <> [1, 2, 3]
    [1,2,3]

mappend :: a -> a -> a Source #

An associative operation

NOTE: This method is redundant and has the default implementation ``mappend` = (`<>`)` since base-4.11.0.0. Should it be implemented manually, since `mappend` is a synonym for (`<>`), it is expected that the two functions are defined the same way. In a future GHC release `mappend` will be removed from `Monoid`.

mconcat :: [a] -> a Source #

Fold a list using the monoid.

For most types, the default definition for `mconcat` will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.

    >>> mconcat ["Hello", " ", "Haskell", "!"]
    "Hello Haskell!"

#### Instances

Instances details

Monoid ByteArray | Since: base-4.17.0.0
Instance details Defined in Data.Array.Byte Methods mempty :: ByteArray Source # mappend :: ByteArray -> ByteArray -> ByteArray Source # mconcat :: [ByteArray] -> ByteArray Source #
Monoid All | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: All Source # mappend :: All -> All -> All Source # mconcat :: [All] -> All Source #
Monoid Any | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Any Source # mappend :: Any -> Any -> Any Source # mconcat :: [Any] -> Any Source #
Monoid ExceptionContext |
Instance details Defined in GHC.Internal.Exception.Context Methods mempty :: ExceptionContext Source # mappend :: ExceptionContext -> ExceptionContext -> ExceptionContext Source # mconcat :: [ExceptionContext] -> ExceptionContext Source #
Monoid Ordering | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: Ordering Source # mappend :: Ordering -> Ordering -> Ordering Source # mconcat :: [Ordering] -> Ordering Source #
Monoid Validation Source # |
Instance details Defined in Data.Validity Methods mempty :: Validation Source # mappend :: Validation -> Validation -> Validation Source # mconcat :: [Validation] -> Validation Source #
Monoid () | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: () Source # mappend :: () -> () -> () Source # mconcat :: [()] -> () Source #

Monoid (Comparison a)

``mempty`` on comparisons always returns `EQ`. Without newtypes this equals ``pure` (`pure` EQ)`.

    mempty :: Comparison a
    mempty = Comparison _ _ -> EQ

Instance details Defined in Data.Functor.Contravariant Methods mempty :: Comparison a Source # mappend :: Comparison a -> Comparison a -> Comparison a Source # mconcat :: [Comparison a] -> Comparison a Source #

Monoid (Equivalence a)

``mempty`` on equivalences always returns `True`. Without newtypes this equals ``pure` (`pure` True)`.

    mempty :: Equivalence a
    mempty = Equivalence _ _ -> True

Instance details Defined in Data.Functor.Contravariant Methods mempty :: Equivalence a Source # mappend :: Equivalence a -> Equivalence a -> Equivalence a Source # mconcat :: [Equivalence a] -> Equivalence a Source #

Monoid (Predicate a)

``mempty`` on predicates always returns `True`. Without newtypes this equals ``pure` True`.

    mempty :: Predicate a
    mempty = _ -> True

Instance details Defined in Data.Functor.Contravariant Methods mempty :: Predicate a Source # mappend :: Predicate a -> Predicate a -> Predicate a Source # mconcat :: [Predicate a] -> Predicate a Source #
(Ord a, Bounded a) => Monoid (Max a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods mempty :: Max a Source # mappend :: Max a -> Max a -> Max a Source # mconcat :: [Max a] -> Max a Source #
(Ord a, Bounded a) => Monoid (Min a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods mempty :: Min a Source # mappend :: Min a -> Min a -> Min a Source # mconcat :: [Min a] -> Min a Source #
Monoid m => Monoid (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods mempty :: WrappedMonoid m Source # mappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source # mconcat :: [WrappedMonoid m] -> WrappedMonoid m Source #
Monoid a => Monoid (Identity a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods mempty :: Identity a Source # mappend :: Identity a -> Identity a -> Identity a Source # mconcat :: [Identity a] -> Identity a Source #
Monoid (First a) | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: First a Source # mappend :: First a -> First a -> First a Source # mconcat :: [First a] -> First a Source #
Monoid (Last a) | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: Last a Source # mappend :: Last a -> Last a -> Last a Source # mconcat :: [Last a] -> Last a Source #
Monoid a => Monoid (Dual a) | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Dual a Source # mappend :: Dual a -> Dual a -> Dual a Source # mconcat :: [Dual a] -> Dual a Source #
Monoid (Endo a) | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Endo a Source # mappend :: Endo a -> Endo a -> Endo a Source # mconcat :: [Endo a] -> Endo a Source #
Num a => Monoid (Product a) | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Product a Source # mappend :: Product a -> Product a -> Product a Source # mconcat :: [Product a] -> Product a Source #
Num a => Monoid (Sum a) | Since: base-2.1
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Sum a Source # mappend :: Sum a -> Sum a -> Sum a Source # mconcat :: [Sum a] -> Sum a Source #
(Generic a, Monoid (Rep a ())) => Monoid (Generically a) | Since: base-4.17.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: Generically a Source # mappend :: Generically a -> Generically a -> Generically a Source # mconcat :: [Generically a] -> Generically a Source #
Monoid p => Monoid (Par1 p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: Par1 p Source # mappend :: Par1 p -> Par1 p -> Par1 p Source # mconcat :: [Par1 p] -> Par1 p Source #
Monoid a => Monoid (IO a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods mempty :: IO a Source # mappend :: IO a -> IO a -> IO a Source # mconcat :: [IO a] -> IO a Source #
Semigroup a => Monoid (Maybe a) | Lift a semigroup into `Maybe` forming a `Monoid` according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup `S` may be turned into a monoid simply by adjoining an element `e` not in `S` and defining `e*e = e` and `e*s = s = s*e` for all `s ∈ S`." Since 4.11.0: constraint on inner `a` value generalised from `Monoid` to `Semigroup`. Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: Maybe a Source # mappend :: Maybe a -> Maybe a -> Maybe a Source # mconcat :: [Maybe a] -> Maybe a Source #
Monoid a => Monoid (Solo a) | Since: base-4.15
Instance details Defined in GHC.Internal.Base Methods mempty :: Solo a Source # mappend :: Solo a -> Solo a -> Solo a Source # mconcat :: [Solo a] -> Solo a Source #
Monoid [a] | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: [a] Source # mappend :: [a] -> [a] -> [a] Source # mconcat :: [[a]] -> [a] Source #

Monoid a => Monoid (Op a b)

``mempty` @(Op a b)` without newtypes is `mempty @(b->a)` = `_ -> mempty`.

    mempty :: Op a b
    mempty = Op _ -> mempty

Instance details Defined in Data.Functor.Contravariant Methods mempty :: Op a b Source # mappend :: Op a b -> Op a b -> Op a b Source # mconcat :: [Op a b] -> Op a b Source #
Monoid (U1 p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: U1 p Source # mappend :: U1 p -> U1 p -> U1 p Source # mconcat :: [U1 p] -> U1 p Source #
(Monoid a, Monoid b) => Monoid (a, b) | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: (a, b) Source # mappend :: (a, b) -> (a, b) -> (a, b) Source # mconcat :: [(a, b)] -> (a, b) Source #
Monoid b => Monoid (a -> b) | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: a -> b Source # mappend :: (a -> b) -> (a -> b) -> a -> b Source # mconcat :: [a -> b] -> a -> b Source #
Monoid a => Monoid (Const a b) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Const Methods mempty :: Const a b Source # mappend :: Const a b -> Const a b -> Const a b Source # mconcat :: [Const a b] -> Const a b Source #
(Applicative f, Monoid a) => Monoid (Ap f a) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: Ap f a Source # mappend :: Ap f a -> Ap f a -> Ap f a Source # mconcat :: [Ap f a] -> Ap f a Source #
Alternative f => Monoid (Alt f a) | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Alt f a Source # mappend :: Alt f a -> Alt f a -> Alt f a Source # mconcat :: [Alt f a] -> Alt f a Source #
Monoid (f p) => Monoid (Rec1 f p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: Rec1 f p Source # mappend :: Rec1 f p -> Rec1 f p -> Rec1 f p Source # mconcat :: [Rec1 f p] -> Rec1 f p Source #
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: (a, b, c) Source # mappend :: (a, b, c) -> (a, b, c) -> (a, b, c) Source # mconcat :: [(a, b, c)] -> (a, b, c) Source #
(Monoid (f a), Monoid (g a)) => Monoid (Product f g a) | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Product Methods mempty :: Product f g a Source # mappend :: Product f g a -> Product f g a -> Product f g a Source # mconcat :: [Product f g a] -> Product f g a Source #
(Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: (f :*: g) p Source # mappend :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p Source # mconcat :: [(f :*: g) p] -> (f :*: g) p Source #
Monoid c => Monoid (K1 i c p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: K1 i c p Source # mappend :: K1 i c p -> K1 i c p -> K1 i c p Source # mconcat :: [K1 i c p] -> K1 i c p Source #
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: (a, b, c, d) Source # mappend :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source # mconcat :: [(a, b, c, d)] -> (a, b, c, d) Source #
Monoid (f (g a)) => Monoid (Compose f g a) | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Compose Methods mempty :: Compose f g a Source # mappend :: Compose f g a -> Compose f g a -> Compose f g a Source # mconcat :: [Compose f g a] -> Compose f g a Source #
Monoid (f (g p)) => Monoid ((f :.: g) p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: (f :.: g) p Source # mappend :: (f :.: g) p -> (f :.: g) p -> (f :.: g) p Source # mconcat :: [(f :.: g) p] -> (f :.: g) p Source #
Monoid (f p) => Monoid (M1 i c f p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: M1 i c f p Source # mappend :: M1 i c f p -> M1 i c f p -> M1 i c f p Source # mconcat :: [M1 i c f p] -> M1 i c f p Source #
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) | Since: base-2.1
Instance details Defined in GHC.Internal.Base Methods mempty :: (a, b, c, d, e) Source # mappend :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source # mconcat :: [(a, b, c, d, e)] -> (a, b, c, d, e) Source #

class Semigroup a where Source #

The class of semigroups (types with an associative binary operation).

Instances should satisfy the following:

Associativity
  `x `<>` (y `<>` z) = (x `<>` y) `<>` z`

You can alternatively define `sconcat` instead of (`<>`), in which case the laws are:

Unit
  ``sconcat` (`pure` x) = x`
Multiplication
  ``sconcat` (`join` xss) = `sconcat` (`fmap` `sconcat` xss)`

Since: base-4.9.0.0

Minimal complete definition

(<>) | sconcat

Methods

(<>) :: a -> a -> a infixr 6 Source #

An associative operation.

#### Examples

Expand

    >>> [1,2,3] <> [4,5,6]
    [1,2,3,4,5,6]

    >>> Just [1, 2, 3] <> Just [4, 5, 6]
    Just [1,2,3,4,5,6]

    >>> putStr "Hello, " <> putStrLn "World!"
    Hello, World!

sconcat :: NonEmpty a -> a Source #

Reduce a non-empty list with `<>`

The default definition should be sufficient, but this can be overridden for efficiency.

#### Examples

Expand

For the following examples, we will assume that we have:

    >>> import Data.List.NonEmpty (NonEmpty (..))

    >>> sconcat $ "Hello" :| [" ", "Haskell", "!"]
    "Hello Haskell!"

    >>> sconcat $ Just [1, 2, 3] :| [Nothing, Just [4, 5, 6]]
    Just [1,2,3,4,5,6]

    >>> sconcat $ Left 1 :| [Right 2, Left 3, Right 4]
    Right 2

stimes :: Integral b => b -> a -> a Source #

Repeat a value `n` times.

The default definition will raise an exception for a multiplier that is `<= 0`. This may be overridden with an implementation that is total. For monoids it is preferred to use `stimesMonoid`.

By making this a member of the class, idempotent semigroups and monoids can upgrade this to execute in \(\mathcal{O}(1)\) by picking `stimes = `stimesIdempotent`` or `stimes = `stimesIdempotentMonoid`` respectively.

#### Examples

Expand

    >>> stimes 4 [1]
    [1,1,1,1]

    >>> stimes 5 (putStr "hi!")
    hi!hi!hi!hi!hi!

    >>> stimes 3 (Right ":)")
    Right ":)"

#### Instances

Instances details

Semigroup ByteArray | Since: base-4.17.0.0
Instance details Defined in Data.Array.Byte Methods (<>) :: ByteArray -> ByteArray -> ByteArray Source # sconcat :: NonEmpty ByteArray -> ByteArray Source # stimes :: Integral b => b -> ByteArray -> ByteArray Source #
Semigroup Void | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: Void -> Void -> Void Source # sconcat :: NonEmpty Void -> Void Source # stimes :: Integral b => b -> Void -> Void Source #
Semigroup All | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: All -> All -> All Source # sconcat :: NonEmpty All -> All Source # stimes :: Integral b => b -> All -> All Source #
Semigroup Any | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Any -> Any -> Any Source # sconcat :: NonEmpty Any -> Any Source # stimes :: Integral b => b -> Any -> Any Source #
Semigroup ExceptionContext |
Instance details Defined in GHC.Internal.Exception.Context Methods (<>) :: ExceptionContext -> ExceptionContext -> ExceptionContext Source # sconcat :: NonEmpty ExceptionContext -> ExceptionContext Source # stimes :: Integral b => b -> ExceptionContext -> ExceptionContext Source #
Semigroup Ordering | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: Ordering -> Ordering -> Ordering Source # sconcat :: NonEmpty Ordering -> Ordering Source # stimes :: Integral b => b -> Ordering -> Ordering Source #
Semigroup Validation Source # |
Instance details Defined in Data.Validity Methods (<>) :: Validation -> Validation -> Validation Source # sconcat :: NonEmpty Validation -> Validation Source # stimes :: Integral b => b -> Validation -> Validation Source #
Semigroup () | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: () -> () -> () Source # sconcat :: NonEmpty () -> () Source # stimes :: Integral b => b -> () -> () Source #
Semigroup (FromMaybe b) |
Instance details Defined in Data.Foldable1 Methods (<>) :: FromMaybe b -> FromMaybe b -> FromMaybe b Source # sconcat :: NonEmpty (FromMaybe b) -> FromMaybe b Source # stimes :: Integral b0 => b0 -> FromMaybe b -> FromMaybe b Source #
Semigroup a => Semigroup (JoinWith a) |
Instance details Defined in Data.Foldable1 Methods (<>) :: JoinWith a -> JoinWith a -> JoinWith a Source # sconcat :: NonEmpty (JoinWith a) -> JoinWith a Source # stimes :: Integral b => b -> JoinWith a -> JoinWith a Source #
Semigroup (NonEmptyDList a) |
Instance details Defined in Data.Foldable1 Methods (<>) :: NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a Source # sconcat :: NonEmpty (NonEmptyDList a) -> NonEmptyDList a Source # stimes :: Integral b => b -> NonEmptyDList a -> NonEmptyDList a Source #

Semigroup (Comparison a)

`(`<>`)` on comparisons combines results with `(`<>`) @Ordering`. Without newtypes this equals ``liftA2` (`liftA2` (`<>`))`.

    (<>) :: Comparison a -> Comparison a -> Comparison a
    Comparison cmp <> Comparison cmp' = Comparison a a' ->
      cmp a a' <> cmp a a'

Instance details Defined in Data.Functor.Contravariant Methods (<>) :: Comparison a -> Comparison a -> Comparison a Source # sconcat :: NonEmpty (Comparison a) -> Comparison a Source # stimes :: Integral b => b -> Comparison a -> Comparison a Source #

Semigroup (Equivalence a)

`(`<>`)` on equivalences uses logical conjunction `(`&&`)` on the results. Without newtypes this equals ``liftA2` (`liftA2` (&&))`.

    (<>) :: Equivalence a -> Equivalence a -> Equivalence a
    Equivalence equiv <> Equivalence equiv' = Equivalence a b ->
      equiv a b && equiv' a b

Instance details Defined in Data.Functor.Contravariant Methods (<>) :: Equivalence a -> Equivalence a -> Equivalence a Source # sconcat :: NonEmpty (Equivalence a) -> Equivalence a Source # stimes :: Integral b => b -> Equivalence a -> Equivalence a Source #

Semigroup (Predicate a)

`(`<>`)` on predicates uses logical conjunction `(`&&`)` on the results. Without newtypes this equals ``liftA2` (&&)`.

    (<>) :: Predicate a -> Predicate a -> Predicate a
    Predicate pred <> Predicate pred' = Predicate a ->
      pred a && pred' a

Instance details Defined in Data.Functor.Contravariant Methods (<>) :: Predicate a -> Predicate a -> Predicate a Source # sconcat :: NonEmpty (Predicate a) -> Predicate a Source # stimes :: Integral b => b -> Predicate a -> Predicate a Source #
Semigroup (First a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: First a -> First a -> First a Source # sconcat :: NonEmpty (First a) -> First a Source # stimes :: Integral b => b -> First a -> First a Source #
Semigroup (Last a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: Last a -> Last a -> Last a Source # sconcat :: NonEmpty (Last a) -> Last a Source # stimes :: Integral b => b -> Last a -> Last a Source #
Ord a => Semigroup (Max a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: Max a -> Max a -> Max a Source # sconcat :: NonEmpty (Max a) -> Max a Source # stimes :: Integral b => b -> Max a -> Max a Source #
Ord a => Semigroup (Min a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: Min a -> Min a -> Min a Source # sconcat :: NonEmpty (Min a) -> Min a Source # stimes :: Integral b => b -> Min a -> Min a Source #
Monoid m => Semigroup (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source # sconcat :: NonEmpty (WrappedMonoid m) -> WrappedMonoid m Source # stimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m Source #
Semigroup (NonEmpty a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: NonEmpty a -> NonEmpty a -> NonEmpty a Source # sconcat :: NonEmpty (NonEmpty a) -> NonEmpty a Source # stimes :: Integral b => b -> NonEmpty a -> NonEmpty a Source #
Semigroup a => Semigroup (Identity a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.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 #
Semigroup (First a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: First a -> First a -> First a Source # sconcat :: NonEmpty (First a) -> First a Source # stimes :: Integral b => b -> First a -> First a Source #
Semigroup (Last a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: Last a -> Last a -> Last a Source # sconcat :: NonEmpty (Last a) -> Last a Source # stimes :: Integral b => b -> Last a -> Last a Source #
Semigroup a => Semigroup (Dual a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Dual a -> Dual a -> Dual a Source # sconcat :: NonEmpty (Dual a) -> Dual a Source # stimes :: Integral b => b -> Dual a -> Dual a Source #
Semigroup (Endo a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Endo a -> Endo a -> Endo a Source # sconcat :: NonEmpty (Endo a) -> Endo a Source # stimes :: Integral b => b -> Endo a -> Endo a Source #
Num a => Semigroup (Product a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.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 #
Num a => Semigroup (Sum a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.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 #
(Generic a, Semigroup (Rep a ())) => Semigroup (Generically a) | Since: base-4.17.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: Generically a -> Generically a -> Generically a Source # sconcat :: NonEmpty (Generically a) -> Generically a Source # stimes :: Integral b => b -> Generically a -> Generically a Source #
Semigroup p => Semigroup (Par1 p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: Par1 p -> Par1 p -> Par1 p Source # sconcat :: NonEmpty (Par1 p) -> Par1 p Source # stimes :: Integral b => b -> Par1 p -> Par1 p Source #
Semigroup a => Semigroup (IO a) | Since: base-4.10.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: IO a -> IO a -> IO a Source # sconcat :: NonEmpty (IO a) -> IO a Source # stimes :: Integral b => b -> IO a -> IO a Source #
Semigroup a => Semigroup (Maybe a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: Maybe a -> Maybe a -> Maybe a Source # sconcat :: NonEmpty (Maybe a) -> Maybe a Source # stimes :: Integral b => b -> Maybe a -> Maybe a Source #
Semigroup a => Semigroup (Solo a) | Since: base-4.15
Instance details Defined in GHC.Internal.Base Methods (<>) :: Solo a -> Solo a -> Solo a Source # sconcat :: NonEmpty (Solo a) -> Solo a Source # stimes :: Integral b => b -> Solo a -> Solo a Source #
Semigroup [a] | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: [a] -> [a] -> [a] Source # sconcat :: NonEmpty [a] -> [a] Source # stimes :: Integral b => b -> [a] -> [a] Source #

Semigroup a => Semigroup (Op a b)

`(`<>`) @(Op a b)` without newtypes is `(`<>`) @(b->a)` = `liftA2 (`<>`)`. This lifts the `Semigroup` operation `(`<>`)` over the output of `a`.

    (<>) :: Op a b -> Op a b -> Op a b
    Op f <> Op g = Op a -> f a <> g a

Instance details Defined in Data.Functor.Contravariant Methods (<>) :: Op a b -> Op a b -> Op a b Source # sconcat :: NonEmpty (Op a b) -> Op a b Source # stimes :: Integral b0 => b0 -> Op a b -> Op a b Source #
Semigroup (Either a b) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Either Methods (<>) :: Either a b -> Either a b -> Either a b Source # sconcat :: NonEmpty (Either a b) -> Either a b Source # stimes :: Integral b0 => b0 -> Either a b -> Either a b Source #
Semigroup (U1 p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: U1 p -> U1 p -> U1 p Source # sconcat :: NonEmpty (U1 p) -> U1 p Source # stimes :: Integral b => b -> U1 p -> U1 p Source #
Semigroup (V1 p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: V1 p -> V1 p -> V1 p Source # sconcat :: NonEmpty (V1 p) -> V1 p Source # stimes :: Integral b => b -> V1 p -> V1 p Source #
(Semigroup a, Semigroup b) => Semigroup (a, b) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a, b) -> (a, b) -> (a, b) Source # sconcat :: NonEmpty (a, b) -> (a, b) Source # stimes :: Integral b0 => b0 -> (a, b) -> (a, b) Source #
Semigroup b => Semigroup (a -> b) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a -> b) -> (a -> b) -> a -> b Source # sconcat :: NonEmpty (a -> b) -> a -> b Source # stimes :: Integral b0 => b0 -> (a -> b) -> a -> b Source #
Semigroup a => Semigroup (Const a b) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Const Methods (<>) :: Const a b -> Const a b -> Const a b Source # sconcat :: NonEmpty (Const a b) -> Const a b Source # stimes :: Integral b0 => b0 -> Const a b -> Const a b Source #
(Applicative f, Semigroup a) => Semigroup (Ap f a) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: Ap f a -> Ap f a -> Ap f a Source # sconcat :: NonEmpty (Ap f a) -> Ap f a Source # stimes :: Integral b => b -> Ap f a -> Ap f a Source #
Alternative f => Semigroup (Alt f a) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Alt f a -> Alt f a -> Alt f a Source # sconcat :: NonEmpty (Alt f a) -> Alt f a Source # stimes :: Integral b => b -> Alt f a -> Alt f a Source #
Semigroup (f p) => Semigroup (Rec1 f p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: Rec1 f p -> Rec1 f p -> Rec1 f p Source # sconcat :: NonEmpty (Rec1 f p) -> Rec1 f p Source # stimes :: Integral b => b -> Rec1 f p -> Rec1 f p Source #
(Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a, b, c) -> (a, b, c) -> (a, b, c) Source # sconcat :: NonEmpty (a, b, c) -> (a, b, c) Source # stimes :: Integral b0 => b0 -> (a, b, c) -> (a, b, c) Source #
(Semigroup (f a), Semigroup (g a)) => Semigroup (Product f g a) | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Product Methods (<>) :: Product f g a -> Product f g a -> Product f g a Source # sconcat :: NonEmpty (Product f g a) -> Product f g a Source # stimes :: Integral b => b -> Product f g a -> Product f g a Source #
(Semigroup (f p), Semigroup (g p)) => Semigroup ((f :*: g) p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p Source # sconcat :: NonEmpty ((f :*: g) p) -> (f :*: g) p Source # stimes :: Integral b => b -> (f :*: g) p -> (f :*: g) p Source #
Semigroup c => Semigroup (K1 i c p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: K1 i c p -> K1 i c p -> K1 i c p Source # sconcat :: NonEmpty (K1 i c p) -> K1 i c p Source # stimes :: Integral b => b -> K1 i c p -> K1 i c p Source #
(Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source # sconcat :: NonEmpty (a, b, c, d) -> (a, b, c, d) Source # stimes :: Integral b0 => b0 -> (a, b, c, d) -> (a, b, c, d) Source #
Semigroup (f (g a)) => Semigroup (Compose f g a) | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Compose Methods (<>) :: Compose f g a -> Compose f g a -> Compose f g a Source # sconcat :: NonEmpty (Compose f g a) -> Compose f g a Source # stimes :: Integral b => b -> Compose f g a -> Compose f g a Source #
Semigroup (f (g p)) => Semigroup ((f :.: g) p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: (f :.: g) p -> (f :.: g) p -> (f :.: g) p Source # sconcat :: NonEmpty ((f :.: g) p) -> (f :.: g) p Source # stimes :: Integral b => b -> (f :.: g) p -> (f :.: g) p Source #
Semigroup (f p) => Semigroup (M1 i c f p) | Since: base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: M1 i c f p -> M1 i c f p -> M1 i c f p Source # sconcat :: NonEmpty (M1 i c f p) -> M1 i c f p Source # stimes :: Integral b => b -> M1 i c f p -> M1 i c f p Source #
(Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) | Since: base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source # sconcat :: NonEmpty (a, b, c, d, e) -> (a, b, c, d, e) Source # stimes :: Integral b0 => b0 -> (a, b, c, d, e) -> (a, b, c, d, e) Source #