on feb5ece help sign in
elk/src/Elm/Compiler/Objects.hs
58 lines 998 B history raw
1{-# OPTIONS_GHC -Wall #-}
2module Elm.Compiler.Objects
3 ( Gen.Roots
4 , mains
5 , value
6 , Opt.Graph
7 , empty
8 , union
9 , unions
10 ,
11 )
12 where
15import qualified Data.List as List
16import qualified Data.Map as Map
17import qualified Data.Text as Text
19import qualified AST.Optimized as Opt
20import qualified AST.Module.Name as ModuleName
21import qualified Generate.JavaScript as Gen
25-- ROOTS
28mains :: [ModuleName.Canonical] -> Gen.Roots
29mains =
30 Gen.Mains
33value :: ModuleName.Canonical -> String -> Gen.Roots
34value home name =
35 Gen.Value home (Text.pack name)
39-- COMBINE GRAPHS
42{-# NOINLINE empty #-}
43empty :: Opt.Graph
44empty =
45 Opt.Graph Map.empty Map.empty Map.empty
48union :: Opt.Graph -> Opt.Graph -> Opt.Graph
49union (Opt.Graph mains1 graph1 fields1) (Opt.Graph mains2 graph2 fields2) =
50 Opt.Graph
51 (Map.union mains1 mains2)
52 (Map.union graph1 graph2)
53 (Map.union fields1 fields2)
56unions :: [Opt.Graph] -> Opt.Graph
57unions graphs =
58 List.foldl' union empty graphs