diff --git a/compiler/Build/Source.hs b/compiler/Build/Source.hs index 08656b6..56ec622 100644 --- a/compiler/Build/Source.hs +++ b/compiler/Build/Source.hs @@ -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 ] diff --git a/compiler/Transform/Check.hs b/compiler/Transform/Check.hs index 490c7f7..057537f 100644 --- a/compiler/Transform/Check.hs +++ b/compiler/Transform/Check.hs @@ -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