summaryrefslogtreecommitdiff
path: root/DSL/Util.hs
diff options
context:
space:
mode:
Diffstat (limited to 'DSL/Util.hs')
-rw-r--r--DSL/Util.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/DSL/Util.hs b/DSL/Util.hs
index 75d38af..44d272c 100644
--- a/DSL/Util.hs
+++ b/DSL/Util.hs
@@ -28,20 +28,20 @@ runChecks fs s
hcf :: Machine -> String -> IO Machine
hcf m msg = putStrLn msg >> return m{ ok=False }
-appendProcTable :: [ProcSpec] -> ProcTable -> Maybe ProcTable
+appendProcTable :: [ProcSpec] -> ProcTable -> Either String ProcTable
appendProcTable x y = go x
where
- go [] = Just y
+ go [] = Right y
go ((n, bs):ps) = go ps >>= f
where
f acc
- | member n acc = Nothing
- | otherwise = Just $ insert n bs acc
+ | member n acc = Left $ "Duplicate PROC definition: " ++ n
+ | otherwise = Right $ insert n bs acc
-mergeProcTables :: ProcTable -> ProcTable -> Maybe ProcTable
+mergeProcTables :: ProcTable -> ProcTable -> Either String ProcTable
mergeProcTables x = appendProcTable $ toList x
-buildProcTable :: [ProcSpec] -> Maybe ProcTable
+buildProcTable :: [ProcSpec] -> Either String ProcTable
buildProcTable ps = appendProcTable ps empty
unreachable :: a