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.

  1. traceId :: String -> String

    base-compat Debug.Trace.Compat

    Like trace but returns the message instead of a third value.

    >>> traceId "hello"
    hello
    "hello"
    

  2. traceShowId :: Show a => a -> a

    base-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")
    

  3. package validity

    Validity typeclass For more info, see the readme. Note: There are companion instance packages for this library:

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

  5. class Semigroup a => Monoid a

    validity Data.Validity

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

    You can alternatively define mconcat instead of mempty, in which case the laws are: 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. Sum and Product. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

  6. newtype Validation

    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.

  7. Validation :: [ValidationChain] -> Validation

    validity Data.Validity

    No documentation available.

  8. data ValidationChain

    validity Data.Validity

    No documentation available.

  9. class Validity a

    validity Data.Validity

    A class of types that have additional invariants defined upon them

  10. checkValidity :: Validity a => a -> Either [ValidationChain] a

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

Page 413 of many | Previous | Next