1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Elm.Compiler.Objects.Internal
20import Prelude hiding (lookup)
21import Control.Arrow (first)
22import Control.Monad (liftM, liftM2)
24import qualified Data.Map as Map
25import qualified Data.Text as Text
27import qualified AST.Expression.Optimized as Opt
28import qualified AST.Module.Name as ModuleName
29import qualified AST.Module as Module
30import qualified AST.Variable as Var
38 Graph (Map.Map Var.Global Opt.Decl)
42-- OBJECT GRAPH HELPERS
45fromModule :: Module.Optimized -> Graph
46fromModule (Module.Module home info) =
47 Graph $ Map.fromList $
48 map (first (Var.Global home)) (Module.program info)
51union :: Graph -> Graph -> Graph
52union (Graph objs1) (Graph objs2) =
53 Graph (Map.union objs1 objs2)
56unions :: [Graph] -> Graph
58 Graph (Map.unions (map destruct graphs))
61destruct :: Graph -> Map.Map Var.Global Opt.Decl
62destruct (Graph graph) =
71 SymbolTable (Map.Map Var.Global Symbol)
74symbolTable :: Map.Map Var.Global Symbol -> SymbolTable
86lookup :: Var.Global -> SymbolTable -> Maybe Symbol
87lookup var (SymbolTable symbols) =
88 Map.lookup var symbols
96 = Mains [ModuleName.Canonical]
97 | Value ModuleName.Canonical Text.Text
100mains :: [ModuleName.Canonical] -> Roots
105value :: ModuleName.Canonical -> String -> Roots
107 Value home (Text.pack name)
110toGlobals :: Roots -> [Var.Global]
112 hiddenDependencies ++
115 map (\home -> Var.Global home "main") modules
118 [ Var.Global home name ]
121-- needed for (==) and toString
122hiddenDependencies :: [Var.Global]
124 [ Var.Global (ModuleName.inCore "Dict") "toList"
125 , Var.Global (ModuleName.inCore "Set") "toList"
133instance Binary Graph where
141instance Binary Symbol where
142 put (Symbol home name) =
146 liftM2 Symbol get get
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list