summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Infra/Option.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-11-21 15:01:04 +0000
committerhallgren <hallgren@chalmers.se>2013-11-21 15:01:04 +0000
commitfe065b5ee417f1f155edeeeafdf6f3d2c21da130 (patch)
tree1ea95887392c84040b4bd4b0d9a81418d48dfe38 /src/compiler/GF/Infra/Option.hs
parentaad6a1c4bb78430c90173a719f0c7a27cc5675d5 (diff)
Some more monadic lifting changes
Diffstat (limited to 'src/compiler/GF/Infra/Option.hs')
-rw-r--r--src/compiler/GF/Infra/Option.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/compiler/GF/Infra/Option.hs b/src/compiler/GF/Infra/Option.hs
index 1236e729c..115665419 100644
--- a/src/compiler/GF/Infra/Option.hs
+++ b/src/compiler/GF/Infra/Option.hs
@@ -38,7 +38,7 @@ import GF.Grammar.Predef
import System.FilePath
--import System.IO
-import GF.Data.ErrM
+import GF.Data.Operations(Err,ErrorMonad(..),liftErr)
import Data.Set (Set)
import qualified Data.Set as Set
@@ -68,8 +68,8 @@ helpMessage = usageInfo usageHeader optDescr
-- FIXME: do we really want multi-line errors?
-errors :: [String] -> Err a
-errors = fail . unlines
+errors :: ErrorMonad err => [String] -> err a
+errors = raise . unlines
-- Types
@@ -185,17 +185,19 @@ instance Show Options where
-- Option parsing
-parseOptions :: [String] -- ^ list of string arguments
- -> Err (Options, [FilePath])
+parseOptions :: ErrorMonad err =>
+ [String] -- ^ list of string arguments
+ -> err (Options, [FilePath])
parseOptions args
| not (null errs) = errors errs
- | otherwise = do opts <- liftM concatOptions $ sequence optss
+ | otherwise = do opts <- concatOptions `fmap` liftErr (sequence optss)
return (opts, files)
where
(optss, files, errs) = getOpt RequireOrder optDescr args
-parseModuleOptions :: [String] -- ^ list of string arguments
- -> Err Options
+parseModuleOptions :: ErrorMonad err =>
+ [String] -- ^ list of string arguments
+ -> err Options
parseModuleOptions args = do
(opts,nonopts) <- parseOptions args
if null nonopts