HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulevalidity-0.12.1.0Haskell2010

Data.Validity

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).

  • 2 types
  • 3 classes
  • 30 values
classclass Validity a where
#

A class of types that have additional invariants defined upon them

Methods

Instances38Validity, …
  • Validity IntegerDefined in validity-0.12.1.0 · Data.Validity

    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.

  • Validity NaturalDefined in validity-0.12.1.0 · Data.Validity

    Valid according to isValidNatural

  • Validity Int16Defined in validity-0.12.1.0 · Data.Validity
  • Validity Int32Defined in validity-0.12.1.0 · Data.Validity
  • Validity Int64Defined in validity-0.12.1.0 · Data.Validity

    Trivially valid

  • Validity Int8Defined in validity-0.12.1.0 · Data.Validity
  • Validity Word16Defined in validity-0.12.1.0 · Data.Validity
  • Validity Word32Defined in validity-0.12.1.0 · Data.Validity
  • Validity Word64Defined in validity-0.12.1.0 · Data.Validity

    Trivially valid

  • Validity Word8Defined in validity-0.12.1.0 · Data.Validity
  • Validity BoolDefined in validity-0.12.1.0 · Data.Validity

    Trivially valid

  • Validity CharDefined in validity-0.12.1.0 · Data.Validity

    Trivially valid

  • Validity DoubleDefined in validity-0.12.1.0 · Data.Validity

    Trivially valid:

  • Validity FloatDefined in validity-0.12.1.0 · Data.Validity

    Trivially valid:

  • Validity IntDefined in validity-0.12.1.0 · Data.Validity

    Trivially valid

  • Validity OrderingDefined in validity-0.12.1.0 · Data.Validity

    Trivially valid

  • Validity WordDefined in validity-0.12.1.0 · Data.Validity

    Trivially valid

  • Validity ValidationChainDefined in validity-0.12.1.0 · Data.Validity
  • Validity ()Defined in validity-0.12.1.0 · Data.Validity

    Trivially valid

  • Validity a => Validity (First a)Defined in validity-0.12.1.0 · Data.Validity

    Valid values the same as it's base type:

  • Validity a => Validity (Last a)Defined in validity-0.12.1.0 · Data.Validity

    Valid values the same as it's base type:

  • Validity a => Validity (NonEmpty a)Defined in validity-0.12.1.0 · Data.Validity

    A nonempty list is valid if all the elements are valid.

    See the instance for 'Validity [a]' for more information.

  • Validity a => Validity (Identity a)Defined in validity-0.12.1.0 · Data.Validity

    Valid values the same as it's base type:

  • Validity a => Validity (First a)Defined in validity-0.12.1.0 · Data.Validity

    Valid values the same as it's base type:

  • Validity a => Validity (Last a)Defined in validity-0.12.1.0 · Data.Validity

    Valid values the same as it's base type:

  • Validity a => Validity (Dual a)Defined in validity-0.12.1.0 · Data.Validity

    Valid values the same as it's base type:

  • Validity a => Validity (Maybe a)Defined in validity-0.12.1.0 · Data.Validity

    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.

  • Validity a => Validity [a]Defined in validity-0.12.1.0 · Data.Validity

    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

  • (Validity a, Ord a, Num a, Integral a) => Validity (Ratio a)Defined in validity-0.12.1.0 · Data.Validity

    Valid if the contained numbers are valid and the denominator is strictly positive.

  • HasResolution a => Validity (Fixed a)Defined in validity-0.12.1.0 · Data.Validity

    Valid according to the contained Integer.

  • (Validity a, Validity b) => Validity (Either a b)Defined in validity-0.12.1.0 · Data.Validity

    Any Either of things is valid if the contents are valid in either of the cases.

  • (Validity a, Validity b) => Validity (a, b)Defined in validity-0.12.1.0 · Data.Validity

    Any tuple of things is valid if both of its elements are valid

  • Validity (f a) => Validity (Alt f a)Defined in validity-0.12.1.0 · Data.Validity

    Valid values the same as it's base type:

  • Validity a => Validity (Const a b)Defined in validity-0.12.1.0 · Data.Validity

    Valid values the same as it's base type:

  • (Validity a, Validity b, Validity c) => Validity (a, b, c)Defined in validity-0.12.1.0 · Data.Validity

    Any triple of things is valid if all three of its elements are valid

  • (Validity a, Validity b, Validity c, Validity d) => Validity (a, b, c, d)Defined in validity-0.12.1.0 · Data.Validity

    Any quadruple of things is valid if all four of its elements are valid

  • (Validity a, Validity b, Validity c, Validity d, Validity e) => Validity (a, b, c, d, e)Defined in validity-0.12.1.0 · Data.Validity

    Any quintuple of things is valid if all five of its elements are valid

  • (Validity a, Validity b, Validity c, Validity d, Validity e, Validity f) => Validity (a, b, c, d, e, f)Defined in validity-0.12.1.0 · Data.Validity

    Any sextuple of things is valid if all six of its elements are valid

Helper functions to define validate

11 declarations
valuecheck :: Bool -> String -> Validation
#

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"
valueannotate :: Validity a => a -> String -> Validation
#

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"
        ]
valueinvalid :: String -> Validation
#

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

Helpers for specific types

Char

RealFloat (Double)

Ratio

Utilities

0 declarations

Utilities for validity checking

Utilities for validation

newtypenewtype Validation
#

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.

Instances6Eq, Show, Generic, Semigroup, Monoid, Rep
datadata ValidationChain
#
Instances5Eq, Show, Generic, Validity, Rep
valueprettyValidate :: Validity a => a -> Either String a
#

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.

Re-exports

2 declarations
classclass Semigroup a => Monoid a where
#

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 newtypes and make those instances of Monoid, e.g. Data.Semigroup.Sum and Data.Semigroup.Product.

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

Methods

  • mempty :: a

    Identity of mappend

    Examples
    Example1 expression
    "Hello world" <> mempty"Hello world"
    Example1 expression
    mempty <> [1, 2, 3][1,2,3]
  • mappend :: a -> a -> a

    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

    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.

    Example1 expression
    mconcat ["Hello", " ", "Haskell", "!"]"Hello Haskell!"
Instances56Monoid, …
  • Monoid ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Monoid AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Monoid EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Monoid LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types

    mappend takes the longer of two lifetimes.

  • Monoid ExceptionContextDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Context
  • Monoid OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid ValidationDefined in validity-0.12.1.0 · Data.Validity
  • Monoid ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid (Comparison a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

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

    mempty :: Comparison a
    mempty = Comparison _ _ -> EQ
    
  • Monoid (Equivalence a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

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

    mempty :: Equivalence a
    mempty = Equivalence _ _ -> True
    
  • Monoid (Predicate a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

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

    mempty :: Predicate a
    mempty = _ -> True
    
  • Monoid (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monoid (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monoid (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Monoid a => Monoid (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Monoid a => Monoid (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Monoid a => Monoid (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid a => Monoid (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid m => Monoid (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Monoid p => Monoid (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup a => Monoid (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base

    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.

  • Bits a => Monoid (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Monoid (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • FiniteBits a => Monoid (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits

    This constraint is arguably too strong. However, as some types (such as Natural) have undefined complement, this is the only safe choice.

  • FiniteBits a => Monoid (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits

    This constraint is arguably too strong. However, as some types (such as Natural) have undefined complement, this is the only safe choice.

  • Num a => Monoid (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Num a => Monoid (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord a => Monoid (Max a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Ord a => Monoid (Min a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • (Generic a, Monoid (Rep a ())) => Monoid (Generically a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord a, Bounded a) => Monoid (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • (Ord a, Bounded a) => Monoid (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Monoid (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Monoid (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid a => Monoid (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant

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

    mempty :: Op a b
    mempty = Op _ -> mempty
    
  • Monoid a => Monoid (ST s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ST
  • Monoid b => Monoid (a -> b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • (Monoid a, Monoid b) => Monoid (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Alternative f => Monoid (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid (f p) => Monoid (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid a => Monoid (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • (Applicative f, Monoid a) => Monoid (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid c => Monoid (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid (f a), Monoid (g a)) => Monoid (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Monoid (f p), Monoid (g p)) => Monoid ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid (f (g a)) => Monoid (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Monoid (f (g p)) => Monoid ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid (f p) => Monoid (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
classclass Semigroup a where
#

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)

Methods

  • (<>) :: a -> a -> ainfixr 6

    An associative operation.

    Examples
    Example1 expression
    [1,2,3] <> [4,5,6][1,2,3,4,5,6]
    Example1 expression
    Just [1, 2, 3] <> Just [4, 5, 6]Just [1,2,3,4,5,6]
    Example1 expression
    putStr "Hello, " <> putStrLn "World!"Hello, World!
  • sconcat :: NonEmpty a -> a

    Reduce a non-empty list with <>

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

    Examples

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

    Example1 expression
    import Data.List.NonEmpty (NonEmpty (..))
    Example1 expression
    sconcat $ "Hello" :| [" ", "Haskell", "!"]"Hello Haskell!"
    Example1 expression
    sconcat $ Just [1, 2, 3] :| [Nothing, Just [4, 5, 6]]Just [1,2,3,4,5,6]
    Example1 expression
    sconcat $ Left 1 :| [Right 2, Left 3, Right 4]Right 2
  • stimes :: Integral b => b -> a -> a

    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
    Example1 expression
    stimes 4 [1][1,1,1,1]
    Example1 expression
    stimes 5 (putStr "hi!")hi!hi!hi!hi!hi!
    Example1 expression
    stimes 3 (Right ":)")Right ":)"
Instances65Semigroup, …
  • Semigroup ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Semigroup VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Semigroup AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Semigroup EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Semigroup EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Semigroup LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Semigroup ExceptionContextDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Context
  • Semigroup OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup ValidationDefined in validity-0.12.1.0 · Data.Validity
  • Semigroup ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid m => Semigroup (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Semigroup (FromMaybe b)Defined in base-4.20.2.0 · Data.Foldable1
  • Semigroup (NonEmptyDList a)Defined in base-4.20.2.0 · Data.Foldable1
  • Semigroup (Comparison a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    (<>) 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'
    
  • Semigroup (Equivalence a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    (<>) 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
    
  • Semigroup (Predicate a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    (<>) 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
    
  • Semigroup (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Semigroup (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Semigroup (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Semigroup (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Semigroup (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Semigroup [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup a => Semigroup (JoinWith a)Defined in base-4.20.2.0 · Data.Foldable1
  • Semigroup a => Semigroup (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Semigroup a => Semigroup (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Semigroup a => Semigroup (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Semigroup a => Semigroup (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Semigroup a => Semigroup (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup a => Semigroup (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup a => Semigroup (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup p => Semigroup (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Bits a => Semigroup (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Semigroup (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Semigroup (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • FiniteBits a => Semigroup (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits

    This constraint is arguably too strong. However, as some types (such as Natural) have undefined complement, this is the only safe choice.

  • Num a => Semigroup (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Num a => Semigroup (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord a => Semigroup (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Semigroup (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Ord a => Semigroup (Max a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Ord a => Semigroup (Min a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • (Generic a, Semigroup (Rep a ())) => Semigroup (Generically a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • Semigroup (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Semigroup (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup a => Semigroup (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    (<>) @(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
    
  • Semigroup a => Semigroup (ST s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ST
  • Semigroup b => Semigroup (a -> b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • (Semigroup a, Semigroup b) => Semigroup (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Alternative f => Semigroup (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Semigroup (f p) => Semigroup (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup a => Semigroup (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • (Applicative f, Semigroup a) => Semigroup (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • (Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup c => Semigroup (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Semigroup (f a), Semigroup (g a)) => Semigroup (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Semigroup (f p), Semigroup (g p)) => Semigroup ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Semigroup (f (g a)) => Semigroup (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Semigroup (f (g p)) => Semigroup ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup (f p) => Semigroup (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base