Begin using the new boundVarList function

This commit is contained in:
Evan Czaplicki 2014-02-10 00:17:49 +01:00
parent 9dd5dff279
commit b2f3ff35dc
2 changed files with 5 additions and 7 deletions

View file

@ -2,7 +2,6 @@
module Build.Source (build) where module Build.Source (build) where
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified Data.Set as Set
import System.FilePath as FP import System.FilePath as FP
import Text.PrettyPrint (Doc) import Text.PrettyPrint (Doc)
@ -33,7 +32,7 @@ build noPrelude interfaces source =
let exports' let exports'
| null exs = | null exs =
let get = Set.toList . Pattern.boundVars in let get = Pattern.boundVarList in
concat [ get pattern | Definition (Expr.Definition pattern _ _) <- decls ] ++ concat [ get pattern | Definition (Expr.Definition pattern _ _) <- decls ] ++
concat [ map fst ctors | Datatype _ _ ctors <- decls ] ++ concat [ map fst ctors | Datatype _ _ ctors <- decls ] ++
[ name | TypeAlias name _ (Type.Record _ _) <- decls ] [ name | TypeAlias name _ (Type.Record _ _) <- decls ]

View file

@ -32,7 +32,7 @@ dupErr err x =
duplicates :: [D.Declaration] -> [String] duplicates :: [D.Declaration] -> [String]
duplicates decls = duplicates decls =
map msg (dups (portNames ++ concatMap getNames defPatterns)) ++ map msg (dups (portNames ++ concatMap Pattern.boundVarList defPatterns)) ++
case mapM exprDups (portExprs ++ defExprs) of case mapM exprDups (portExprs ++ defExprs) of
Left name -> [msg name] Left name -> [msg name]
Right _ -> [] Right _ -> []
@ -50,14 +50,13 @@ duplicates decls =
D.Out name expr _ -> (name, [expr]) D.Out name expr _ -> (name, [expr])
D.In name _ -> (name, []) D.In name _ -> (name, [])
getNames = Set.toList . Pattern.boundVars exprDups :: E.Expr -> Either String E.Expr
exprDups :: E.LExpr -> Either String E.LExpr
exprDups expr = Expr.crawlLet defsDups expr exprDups expr = Expr.crawlLet defsDups expr
defsDups :: [E.Def] -> Either String [E.Def] defsDups :: [E.Def] -> Either String [E.Def]
defsDups defs = defsDups defs =
case dups $ concatMap (\(E.Definition name _ _) -> getNames name) defs of let varsIn (E.Definition pattern _ _) = Pattern.boundVarList pattern in
case dups $ concatMap varsIn defs of
[] -> Right defs [] -> Right defs
name:_ -> Left name name:_ -> Left name