-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Tiny library to replace classic if/else
--
@package RichConditional
@version 0.1.0.0
module Control.RichConditional
-- | Instances of this class provide a test on some type a with an
-- alternative case for when it fails. If it passes, it gives a value of
-- type b; otherwise, it gives a value of type c.
class TotalIf a b c
decide :: TotalIf a b c => a -> Decision b c
-- | Instances of this class provide a test on some type a. If it passes,
-- it gives a value of type b; otherwise, it gives Nothing.
class PartialIf a b
indicate :: PartialIf a b => a -> Indication b
-- | A conditional using a TotalIf instance. This is just like the function
-- either which decomposes an Either, except that the Either is
-- produced through a TotalIf instance determined by the types of the
-- cases.
ifElse :: TotalIf a b c => a -> (b -> d) -> (c -> d) -> d
-- | A conditional using a PartialIf instance. This is just like the
-- function maybe which decomposes a Maybe, except that the Maybe
-- is produced through an PartialIf instance determined by the type of
-- the positive case.
inCase :: PartialIf a b => a -> (b -> c) -> c -> c
-- | Like guard but with a bonus: if the condition passes, you
-- actually get a hold of some new information.
ensure :: (Monad m, MonadPlus m, PartialIf a b) => a -> m b
-- | Like ensure but for the positive case (Left) of a TotalIf.
-- Requires a proxy on the negative type in order to disambiguate.
ensurePositive :: (Monad m, MonadPlus m, TotalIf a b c) => a -> u c -> m b
-- | Like ensure but for the negative case (Right) of a TotalIf.
-- Requires a proxy on the positive type in order to disambiguate.
ensureNegative :: (Monad m, MonadPlus m, TotalIf a b c) => a -> u b -> m c
instance TotalIf (Either a b) a b
instance PartialIf (Maybe a) a