diff options
Diffstat (limited to 'DSL/Util.hs')
| -rw-r--r-- | DSL/Util.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/DSL/Util.hs b/DSL/Util.hs index 7767b4b..75d38af 100644 --- a/DSL/Util.hs +++ b/DSL/Util.hs @@ -1,5 +1,7 @@ module DSL.Util where +import Data.Map.Strict (empty, member, insert, toList) + import DSL.Types tAny :: TypeCheck @@ -26,6 +28,22 @@ runChecks fs s hcf :: Machine -> String -> IO Machine hcf m msg = putStrLn msg >> return m{ ok=False } +appendProcTable :: [ProcSpec] -> ProcTable -> Maybe ProcTable +appendProcTable x y = go x + where + go [] = Just y + go ((n, bs):ps) = go ps >>= f + where + f acc + | member n acc = Nothing + | otherwise = Just $ insert n bs acc + +mergeProcTables :: ProcTable -> ProcTable -> Maybe ProcTable +mergeProcTables x = appendProcTable $ toList x + +buildProcTable :: [ProcSpec] -> Maybe ProcTable +buildProcTable ps = appendProcTable ps empty + unreachable :: a unreachable = error "this branch should be unreachable" |
