Hoogle Search
Within LTS Haskell 24.40 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
base-compat Debug.Trace.Compat Like trace but returns the message instead of a third value.
>>> traceId "hello" hello "hello"
traceShowId :: Show a => a -> abase-compat Debug.Trace.Compat Like traceShow but returns the shown value instead of a third value.
>>> traceShowId (1+2+3, "hello" ++ "world") (6,"helloworld") (6,"helloworld")
-
Validity typeclass For more info, see the readme. Note: There are companion instance packages for this library:
-
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). -
validity Data.Validity 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
- Unit mconcat (pure x) = x
- Multiplication mconcat (join xss) = mconcat (fmap mconcat xss)
- Subclass mconcat (toList xs) = sconcat xs
-
validity Data.Validity 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.
Validation :: [ValidationChain] -> Validationvalidity Data.Validity No documentation available.
-
validity Data.Validity No documentation available.
-
validity Data.Validity A class of types that have additional invariants defined upon them
checkValidity :: Validity a => a -> Either [ValidationChain] avalidity Data.Validity validate a given value. This function returns either all the reasons why the given value is invalid, in the form of a list of ValidationChains, 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 ValidationChains to a user.