Subversion

Galculator

[/] [src/] [Control/] [MonadOr.hs] - Diff between revs 1 and 3

Only display areas with differences

Rev 1 Rev 3
{-# OPTIONS_GHC -Wall #-} {-# OPTIONS_GHC -Wall #-}
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
{- | {- |
Module : Control.MonadOr Module : Control.MonadOr
Description : MonadOr definition. Description : MonadOr definition.
Copyright : (c) Paulo Silva Copyright : (c) Paulo Silva
License : LGPL License : LGPL
Maintainer : paufil@di.uminho.pt Maintainer : paufil@di.uminho.pt
Stability : experimental Stability : experimental
Portability : portable Portability : portable
Monad definition satisfying the Monoid and Left Catch laws as refered in Monad definition satisfying the Monoid and Left Catch laws as refered in
<http://www.haskell.org/haskellwiki/MonadPlus_reform_proposal> <http://www.haskell.org/haskellwiki/MonadPlus_reform_proposal>
-} -}
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
module Control.MonadOr ( module Control.MonadOr (
  MonadOr,   MonadOr,
  morelse   morelse
 ) where  ) where
   
import Control.Monad import Control.Monad.Error
  import Control.Monad.State
   
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
class MonadPlus m => MonadOr m where class MonadPlus m => MonadOr m where
  morelse :: m a -> m a -> m a   morelse :: m a -> m a -> m a
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
instance MonadOr [] where instance MonadOr [] where
  morelse [] b = b   morelse [] b = b
  morelse a _ = a   morelse a _ = a
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- This instance is equal to mplus for maybe -- This instance is equal to mplus for maybe
instance MonadOr Maybe where instance MonadOr Maybe where
  morelse = mplus   morelse = mplus
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
  instance (Monad m, Error e) => MonadOr (ErrorT e m) where
    morelse = mplus
   
  -------------------------------------------------------------------------------
 
  instance MonadOr m => MonadOr (StateT s m) where
      m `morelse` n = StateT $ \s -> runStateT m s `morelse` runStateT n s
   
  -------------------------------------------------------------------------------
 
 
 
Generated by GNU enscript 1.6.4.
 
 
   

Theme by Vikram Singh | Powered by WebSVN v1.61