From 55aebadd5a64eb3f6a566168bbeeeb7cbb4ccb44 Mon Sep 17 00:00:00 2001 From: hallgren Date: Mon, 20 Oct 2014 15:05:43 +0000 Subject: Remove some dead code * The following modules are no longer used and have been removed completely: GF.Compile.Compute.ConcreteLazy GF.Compile.Compute.ConcreteStrict GF.Compile.Refresh * The STM monad has been commented out. It was only used in GF.Compile.SubExpOpt, where could be replaced with a plain State monad, since no error handling was needed. One of the functions was hardwired to the Err monad, but did in fact not use error handling, so it was turned into a pure function. * The function errVal has been renamed to fromErr (since it is analogous to fromMaybe). * Replaced 'fail' with 'raise' and 'return ()' with 'done' in a few places. * Some additional old code that was already commented out has been removed. --- src/compiler/GF/Data/ErrM.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/compiler/GF/Data/ErrM.hs') diff --git a/src/compiler/GF/Data/ErrM.hs b/src/compiler/GF/Data/ErrM.hs index d687a70a5..033c1efac 100644 --- a/src/compiler/GF/Data/ErrM.hs +++ b/src/compiler/GF/Data/ErrM.hs @@ -12,15 +12,25 @@ -- hack for BNFC generated files. AR 21/9/2003 ----------------------------------------------------------------------------- -module GF.Data.ErrM (Err(..)) where +module GF.Data.ErrM where import Control.Monad (MonadPlus(..),ap) import Control.Applicative --- | like @Maybe@ type with error msgs +-- | Like 'Maybe' type with error msgs data Err a = Ok a | Bad String deriving (Read, Show, Eq) +-- | Analogue of 'maybe' +err :: (String -> b) -> (a -> b) -> Err a -> b +err d f e = case e of + Ok a -> f a + Bad s -> d s + +-- | Analogue of 'fromMaybe' +fromErr :: a -> Err a -> a +fromErr a = err (const a) id + instance Monad Err where return = Ok fail = Bad -- cgit v1.2.3