on master help sign in
Get rid of SourceSyntax.Everything module
commite119d8ef62af9fdff3b779281064cd116a46d1b4 authorEvan Czaplicki <info@elm-lang.org> dateSun 22 Dec 2013, 15:18 (13 years ago) parentf8bf89b
11 files changed+50−49
Elm.cabal−3 compiler/Build/Dependencies.hs+3−3 compiler/Build/Source.hs+5−3 compiler/Generate/JavaScript.hs+10−6 compiler/Generate/Noscript.hs+5−1 compiler/Parse/Pattern.hs+2−2 compiler/SourceSyntax/Everything.hs−17 compiler/Transform/Check.hs+4−1 compiler/Transform/Optimize.hs+5−1 compiler/Transform/SortDefinitions.hs+3−1 compiler/Type/Constrain/Declaration.hs+13−11
Elm.cabal−3
@@ -39,7 +39,6 @@ Library
3939 Hs-Source-Dirs: compiler
4040 other-modules: SourceSyntax.Declaration,
4141 SourceSyntax.Expression,
42− SourceSyntax.Everything,
4342 SourceSyntax.Helpers,
4443 SourceSyntax.Literal,
4544 SourceSyntax.Location,
@@ -118,7 +117,6 @@ Executable elm
118117 Hs-Source-Dirs: compiler
119118 other-modules: SourceSyntax.Declaration,
120119 SourceSyntax.Expression,
121− SourceSyntax.Everything,
122120 SourceSyntax.Helpers,
123121 SourceSyntax.Literal,
124122 SourceSyntax.Location,
@@ -195,7 +193,6 @@ Executable elm-doc
195193 Main-is: Docs.hs
196194 Hs-Source-Dirs: compiler
197195 other-modules: SourceSyntax.Declaration,
198− SourceSyntax.Everything,
199196 SourceSyntax.Expression,
200197 SourceSyntax.Helpers,
201198 SourceSyntax.Literal,
compiler/Build/Dependencies.hs+3−3
@@ -18,7 +18,7 @@ import System.FilePath as FP
1818import System.IO
1919import Text.PrettyPrint (Doc)
2020
21−import SourceSyntax.Everything
21+import qualified SourceSyntax.Module as Module
2222import qualified SourceSyntax.Type as Type
2323import qualified Parse.Parse as Parse
2424import qualified Metadata.Prelude as Prelude
@@ -32,7 +32,7 @@ import qualified Elm.Internal.Name as N
3232import qualified Elm.Internal.Version as V
3333import qualified Elm.Internal.Dependencies as Deps
3434
35−getSortedDependencies :: [FilePath] -> Interfaces -> FilePath -> IO [String]
35+getSortedDependencies :: [FilePath] -> Module.Interfaces -> FilePath -> IO [String]
3636getSortedDependencies srcDirs builtIns root =
3737 do extras <- extraDependencies
3838 let allSrcDirs = srcDirs ++ Maybe.fromMaybe [] extras
@@ -86,7 +86,7 @@ sortDeps depends =
8686 mistakes = filter (\scc -> length scc > 1) sccs
8787 msg = "A cyclical module dependency or was detected in:\n"
8888
89−readDeps :: [FilePath] -> Interfaces -> FilePath -> ErrorT String IO [Deps]
89+readDeps :: [FilePath] -> Module.Interfaces -> FilePath -> ErrorT String IO [Deps]
9090readDeps srcDirs builtIns root = do
9191 let ifaces = (Set.fromList . Map.keys) builtIns
9292 State.evalStateT (go ifaces root) Set.empty
compiler/Build/Source.hs+5−3
@@ -11,7 +11,9 @@ import System.Exit
1111import System.FilePath as FP
1212import Text.PrettyPrint (Doc)
1313
14−import SourceSyntax.Everything
14+import SourceSyntax.Declaration
15+import SourceSyntax.Module
16+import qualified SourceSyntax.Expression as Expr
1517import qualified SourceSyntax.Type as Type
1618import qualified Parse.Parse as Parse
1719import qualified Metadata.Prelude as Prelude
@@ -38,7 +40,7 @@ build noPrelude interfaces source =
3840 let exports'
3941 | null exs =
4042 let get = Set.toList . SD.boundVars in
41− concat [ get pattern | Definition (Def pattern _) <- decls ] ++
43+ concat [ get pattern | Definition (Expr.Def pattern _) <- decls ] ++
4244 concat [ map fst ctors | Datatype _ _ ctors <- decls ] ++
4345 [ name | TypeAlias name _ (Type.Record _ _) <- decls ]
4446 | otherwise = exs
@@ -49,7 +51,7 @@ build noPrelude interfaces source =
4951 exports = exports',
5052 imports = ims,
5153 -- reorder AST into strongly connected components
52− program = SD.sortDefs . dummyLet $ TcDecl.toExpr decls,
54+ program = SD.sortDefs . Expr.dummyLet $ TcDecl.toExpr decls,
5355 types = Map.empty,
5456 datatypes = [ (name,vars,ctors) | Datatype name vars ctors <- decls ],
5557 fixities = [ (assoc,level,op) | Fixity assoc level op <- decls ],
compiler/Generate/JavaScript.hs+10−6
@@ -9,8 +9,12 @@ import qualified Data.Set as Set
99
1010import qualified Generate.Cases as Case
1111import qualified Generate.Markdown as MD
12−import SourceSyntax.Everything
12+import qualified SourceSyntax.Helpers as Help
13+import SourceSyntax.Literal
14+import SourceSyntax.Pattern
1315import SourceSyntax.Location
16+import SourceSyntax.Expression
17+import SourceSyntax.Module
1418import qualified Transform.SortDefinitions as SD
1519import Language.ECMAScript3.Syntax
1620import Language.ECMAScript3.PrettyPrint
@@ -21,7 +25,7 @@ split = go []
2125 where
2226 go vars str =
2327 case break (=='.') str of
24− (x,'.':rest) | isOp x -> vars ++ [x ++ '.' : rest]
28+ (x,'.':rest) | Help.isOp x -> vars ++ [x ++ '.' : rest]
2529 | otherwise -> go (vars ++ [x]) rest
2630 (x,[]) -> vars ++ [x]
2731
@@ -197,7 +201,7 @@ definition def =
197201 let assign x = varDecl x expr'
198202 case pattern of
199203 PVar x
200− | isOp x ->
204+ | Help.isOp x ->
201205 let op = LBracket () (ref "_op") (string x) in
202206 return [ ExprStmt () $ AssignExpr () OpAssign op expr' ]
203207 | otherwise ->
@@ -220,7 +224,7 @@ definition def =
220224
221225 decl x n = varDecl x (dotSep ["$","_" ++ show n])
222226 setup vars
223− | isTuple name = assign "$" : vars
227+ | Help.isTuple name = assign "$" : vars
224228 | otherwise = safeAssign : vars
225229
226230 safeAssign = varDecl "$" (CondExpr () if' expr' exception)
@@ -304,7 +308,7 @@ generate unsafeModule =
304308
305309 jsExports = assign ("_elm" : names modul ++ ["values"]) (ObjectLit () exs)
306310 where
307− exs = map entry . filter (not . isOp) $ "_op" : exports modul
311+ exs = map entry . filter (not . Help.isOp) $ "_op" : exports modul
308312 entry x = (PropId () (var x), ref x)
309313
310314 assign path expr =
@@ -380,7 +384,7 @@ binop span op e1 e2 =
380384 js1 = expression e1
381385 js2 = expression e2
382386
383− func | isOp operator = BracketRef () (dotSep (init parts ++ ["_op"])) (string operator)
387+ func | Help.isOp operator = BracketRef () (dotSep (init parts ++ ["_op"])) (string operator)
384388 | otherwise = dotSep parts
385389 where
386390 parts = split op
compiler/Generate/Noscript.hs+5−1
@@ -1,7 +1,11 @@
11module Generate.Noscript (noscript) where
22
33import Data.List (isInfixOf)
4−import SourceSyntax.Everything
4+import SourceSyntax.Declaration (Declaration(..))
5+import SourceSyntax.Expression
6+import SourceSyntax.Literal
7+import SourceSyntax.Location
8+import SourceSyntax.Module
59import qualified Generate.Markdown as MD
610
711noscript :: Module t v -> String
compiler/Parse/Pattern.hs+2−2
@@ -11,9 +11,9 @@ import Text.Parsec.Indent
1111
1212import Parse.Helpers
1313import Parse.Literal
14+import SourceSyntax.Literal
15+import SourceSyntax.Pattern hiding (tuple, list)
1416import qualified SourceSyntax.Pattern as Pattern
15−import SourceSyntax.Everything hiding (tuple)
16−
1717
1818basic :: IParser Pattern
1919basic = choice
compiler/SourceSyntax/Everything.hsdeleted−17
@@ -1,17 +0,0 @@
1−module SourceSyntax.Everything
2− (module SourceSyntax.Helpers,
3− module SourceSyntax.Location,
4− module SourceSyntax.Literal,
5− module SourceSyntax.Pattern,
6− module SourceSyntax.Expression,
7− module SourceSyntax.Declaration,
8− module SourceSyntax.Module
9− ) where
10−
11−import SourceSyntax.Helpers
12−import SourceSyntax.Location
13−import SourceSyntax.Literal
14−import SourceSyntax.Pattern hiding (tuple, list, cons, nil, prettyParens)
15−import SourceSyntax.Expression
16−import SourceSyntax.Declaration hiding (Assoc(..))
17−import SourceSyntax.Module
compiler/Transform/Check.hs+4−1
@@ -1,7 +1,10 @@
11module Transform.Check (mistakes) where
22
33import Transform.SortDefinitions (boundVars)
4−import SourceSyntax.Everything
4+import SourceSyntax.Declaration (Declaration(..))
5+import SourceSyntax.Expression
6+import SourceSyntax.Pattern
7+import SourceSyntax.Location
58import SourceSyntax.PrettyPrint
69import qualified SourceSyntax.Type as T
710import Data.List as List
compiler/Transform/Optimize.hs+5−1
@@ -1,6 +1,10 @@
11module Transform.Optimize (optimize) where
22
3−import SourceSyntax.Everything
3+import SourceSyntax.Declaration (Declaration(..))
4+import SourceSyntax.Expression
5+import SourceSyntax.Literal
6+import SourceSyntax.Location
7+import SourceSyntax.Module
48import Control.Arrow (second, (***))
59import Data.Char (isAlpha)
610
compiler/Transform/SortDefinitions.hs+3−1
@@ -6,7 +6,9 @@ import Control.Applicative ((<$>))
66import qualified Data.Set as Set
77import qualified Data.Map as Map
88import qualified SourceSyntax.Type as ST
9−import SourceSyntax.Everything
9+import SourceSyntax.Expression
10+import SourceSyntax.Location
11+import SourceSyntax.Pattern
1012import qualified Data.Graph as Graph
1113import qualified Data.Map as Map
1214import qualified Data.Maybe as Maybe
compiler/Type/Constrain/Declaration.hs+13−11
@@ -9,7 +9,9 @@ import qualified Type.Constrain.Expression as TcExpr
99import qualified Type.Environment as Env
1010
1111import SourceSyntax.Declaration
12−import qualified SourceSyntax.Everything as Src
12+import qualified SourceSyntax.Expression as Src
13+import qualified SourceSyntax.Location as L
14+import qualified SourceSyntax.Pattern as P
1315import qualified SourceSyntax.Type as Type
1416
1517toExpr :: [Declaration t v] -> [Src.Def t v]
@@ -25,34 +27,34 @@ toDefs decl =
2527 toDefs (ctor, tipes) =
2628 let vars = take (length tipes) arguments
2729 tbody = Type.Data name $ map Type.Var tvars
28− body = Src.none . Src.Data ctor $ map (Src.none . Src.Var) vars
30+ body = L.none . Src.Data ctor $ map (L.none . Src.Var) vars
2931 in [ Src.TypeAnnotation ctor $ foldr Type.Lambda tbody tipes
30− , Src.Def (Src.PVar ctor) $ buildFunction body vars
32+ , Src.Def (P.PVar ctor) $ buildFunction body vars
3133 ]
3234
3335 TypeAlias name tvars tipe@(Type.Record fields ext) ->
3436 [ Src.TypeAnnotation name $ foldr Type.Lambda tipe args
35− , Src.Def (Src.PVar name) $ buildFunction record vars ]
37+ , Src.Def (P.PVar name) $ buildFunction record vars ]
3638 where
3739 args = case ext of
3840 Type.EmptyRecord -> map snd fields
3941 _ -> map snd fields ++ [ext]
4042
41− var = Src.none . Src.Var
43+ var = L.none . Src.Var
4244 vars = take (length args) arguments
4345
4446 efields = zip (map fst fields) (map var vars)
4547 record = case ext of
46− Type.EmptyRecord -> Src.none $ Src.Record efields
47− _ -> foldl (\r (f,v) -> Src.none $ Src.Insert r f v) (var $ last vars) efields
48+ Type.EmptyRecord -> L.none $ Src.Record efields
49+ _ -> foldl (\r (f,v) -> L.none $ Src.Insert r f v) (var $ last vars) efields
4850
4951 -- Type aliases must be added to an extended equality dictionary,
5052 -- but they do not require any basic constraints.
5153 TypeAlias _ _ _ -> []
5254
53− ImportEvent _ expr@(Src.L s _) name tipe ->
55+ ImportEvent _ expr@(L.L s _) name tipe ->
5456 [ Src.TypeAnnotation name tipe
55− , Src.Def (Src.PVar name) (Src.L s $ Src.App (Src.L s $ Src.Var "constant") expr) ]
57+ , Src.Def (P.PVar name) (L.L s $ Src.App (L.L s $ Src.Var "constant") expr) ]
5658
5759 ExportEvent _ name tipe ->
5860 [ Src.TypeAnnotation name tipe ]
@@ -64,5 +66,5 @@ toDefs decl =
6466arguments :: [String]
6567arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show n) [1..]
6668
67−buildFunction body@(Src.L s _) vars =
68− foldr (\p e -> Src.L s (Src.Lambda p e)) body (map Src.PVar vars)
69+buildFunction body@(L.L s _) vars =
70+ foldr (\p e -> L.L s (Src.Lambda p e)) body (map P.PVar vars)