on master help sign in
Get rid of logging and add Int, Float, Char, Bool to the global environment
commit3f96acf1f17ac89ab69854f843ab19af970afadd authorEvan Czaplicki <info@elm-lang.org> dateMon 29 Jul 2013, 13:23 (13 years ago) parent2f49151
1 file changed+5−25
compiler/Transform/Canonicalize.hs+5−25
compiler/Transform/Canonicalize.hs+5−25
@@ -15,19 +15,8 @@ import qualified SourceSyntax.Type as Type
1515import qualified Transform.SortDefinitions as SD
1616import Text.PrettyPrint
1717
18−-- todo: remove these
19−import System.IO.Unsafe
20−import SourceSyntax.PrettyPrint
21−
2218interface :: String -> ModuleInterface -> ModuleInterface
2319interface moduleName iface =
24− let f x = unsafePerformIO $ do
25− putStrLn "----------------------\ncanonicalize interface"
26− putStr "iface " >> print iface
27− putStr "canons " >> print canons
28− putStr "iface' " >> print x
29− return x
30− in f $
3120 ModuleInterface {
3221 iTypes = Map.mapKeys prefix (Map.map renameType' (iTypes iface)),
3322 iAdts = map (both prefix renameCtors) (iAdts iface),
@@ -60,12 +49,7 @@ renameType rename tipe =
6049
6150metadataModule :: Interfaces -> MetadataModule t v -> Either [Doc] (MetadataModule t v)
6251metadataModule ifaces modul =
63− do let f x = unsafePerformIO $ do
64− print realImports
65− print ifaces
66− putStr "initialEnv " >> print initialEnv
67− return x
68− program' <- f $ rename initialEnv (program modul)
52+ do program' <- rename initialEnv (program modul)
6953 return $ modul { program = program' }
7054 where
7155 get1 (a,_,_) = a
@@ -79,18 +63,14 @@ metadataModule ifaces modul =
7963 As alias -> map (pair (alias ++ ".")) allNames
8064 Hiding vars -> map (pair "") $ filter (flip Set.notMember vs) allNames
8165 where vs = Set.fromList vars
82− Importing vars -> f $ map (pair "") $ filter (flip Set.member vs) allNames
66+ Importing vars -> map (pair "") $ filter (flip Set.member vs) allNames
8367 where vs = Set.fromList $ map (\v -> name ++ "." ++ v) vars
84− f y = unsafePerformIO $ do
85− print vs
86− print allNames
87− print y
88− return y
8968
9069 pair n = (n,n)
9170 localEnv = concat [ map (pair . get1) (aliases modul)
9271 , map (pair . get1) (datatypes modul) ]
93− globalEnv = map pair $ [ saveEnvName, "::", "[]" ] ++ map (\n -> "_Tuple" ++ show n) [0..9]
72+ globalEnv = map pair $ ["_List",saveEnvName,"::","[]","Int","Float","Char","Bool"] ++
73+ map (\n -> "_Tuple" ++ show n) [0..9]
9474 realImports = filter (not . List.isPrefixOf "Native." . fst) (imports modul)
9575 initialEnv = Map.fromList (concatMap canon realImports ++ localEnv ++ globalEnv)
9676
@@ -139,7 +119,7 @@ rename env lexpr@(L t s expr) =
139119 frnm (f,e) = (,) f `liftM` rename env e
140120
141121 Binop op e1 e2 ->
142− do op' <- if isOp op then return op else format (replace env op)
122+ do op' <- format (replace env op)
143123 Binop op' `liftM` rnm e1 `ap` rnm e2
144124
145125 Lambda pattern e ->