Hoogle Search
Within LTS Haskell 22.21 (ghc-9.6.5)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
orElse :: (Selective f, Semigroup e) => f (Either e a) -> f (Either e a) -> f (Either e a)selective Control.Selective Return the first Right value. If both are Left's, accumulate errors.
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 :: 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 :: 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.
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 :: STM a -> STM a -> STM astack Stack.Prelude 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 :: STM a -> STM a -> STM atermonad Termonad.Prelude 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 :: 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)