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

View file

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