Hoogle Search
Within LTS Haskell 24.2 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
ghc-lib-parser GHC.Data.Maybe Flipped version of fromMaybe, useful for chaining.
orElse :: Parser x s a -> Parser e s a -> Parser e s abytesmith Data.Bytes.Parser There is a law-abiding instance of Alternative for Parser. However, it is not terribly useful since error messages seldom have a Monoid instance. This function is a variant of <|> that is right-biased in its treatment of error messages. Consequently, orElse lacks an identity. See attoparsec issue #122 for more discussion of this topic.
orElse :: (Selective f, Semigroup e) => f (Either e a) -> f (Either e a) -> f (Either e a)rebase Rebase.Prelude Return the first Right value. If both are Left's, accumulate errors.
orElse :: STM a -> STM a -> STM aeffectful Effectful.Concurrent.STM Compose two alternative STM actions (GHC only). If the first action completes without retrying then it forms the result of the orElse. Otherwise, if the first action retries, then the second action is tried in its place. If both actions retry then the orElse as a whole retries.
orElse :: MonadSTM stm => stm a -> stm a -> stm aconcurrency Control.Monad.STM.Class Run the first transaction and, if it retrys, run the second instead. This is just mplus.
orElse :: Semigroup e => Validator e inp a -> Validator e inp a -> Validator e inp avalida Valida.Combinators Build a validator that succeeds if either of the given validators succeed. The first (left-most) Success is returned. If both fail, the errors are combined. Other validator is not used if first one succeeds.
vald1 `orElse` (vald2 `orElse` vald3) = (vald1 `orElse` vald2) `orElse` vald3
failV e `orElse` vald = vald
vald `orElse` failV e = vald
Examples
>>> let vald = failureIf (>0) "Positive" `orElse` failureIf even "Even" >>> runValidator vald 5 Success 5 >>> runValidator vald 4 Failure ("Positive" :| ["Even"]) >>> runValidator vald 0 Success 0 >>> runValidator vald (-1) Success (-1)
orElse :: Semigroup e => ValidationRule e a -> ValidationRule e a -> ValidationRule e avalida-base Valida.Combinators Build a rule that succeeds if either of the given rules succeed. If both fail, the errors are combined.
rule1 `orElse` (rule2 `orElse` rule3) = (rule1 `orElse` rule2) `orElse` rule3
falseRule e `orElse` rule = rule
rule `orElse` falseRule e = rule
Examples
>>> let rule = failureIf (>0) "Positive" `orElse` failureIf even "Even" >>> runValidator (validate rule) 5 Success 5 >>> runValidator (validate rule) 4 Failure ("Positive" :| ["Even"]) >>> runValidator (validate rule) 0 Success 0 >>> runValidator (validate rule) (-1) Success (-1)
orElse :: Validate v => v e a -> a -> avalidation Data.Validation v orElse a returns a when v is Failure, and the a in Success a. This can be thought of as having the less general type:
orElse :: Validation e a -> a -> a
orElse :: STM a -> STM a -> STM aclassy-prelude-yesod ClassyPrelude.Yesod Compose two alternative STM actions (GHC only). If the first action completes without retrying then it forms the result of the orElse. Otherwise, if the first action retries, then the second action is tried in its place. If both actions retry then the orElse as a whole retries.
orElseSTM :: STM a -> STM a -> STM aclassy-prelude ClassyPrelude Synonym for orElse.