on master help sign in
Switch the internal data constructor name for tuples. Before tuple

constructors could be shadowed by user defined ADT's such as "Tuple0", "Tuple2", etc. Now it uses "_Tuple0" to make it impossible to overlap with user defined ASTs.

commit0070a844d05e2ee64241efc7c8fd03d90a97c830 authorEvan Czaplicki <evan@Evans-MacBook-Air.local> dateSun 14 Jul 2013, 19:52 (13 years ago) parente7b949d
7 files changed+10−7
compiler/Metadata/Libraries.hs+1−1 compiler/SourceSyntax/Expression.hs+1−1 compiler/SourceSyntax/Helpers.hs+1−1 compiler/SourceSyntax/Pattern.hs+1−1 compiler/SourceSyntax/Type.hs+1−1 compiler/Type/Constrain/Declaration.hs+1−1 tests/good/Soundness.elm+4−1
compiler/Metadata/Libraries.hs+1−1
@@ -34,7 +34,7 @@ libraries =
3434 ] ++ map makeTuple (inits ['a'..'i'])
3535
3636 makeTuple cs =
37− let name = "Tuple" ++ show (length cs)
37+ let name = "_Tuple" ++ show (length cs)
3838 in (name, concatMap (\c -> c : " -> ") cs ++
3939 name ++ concatMap (\c -> [' ',c]) cs)
4040
compiler/SourceSyntax/Expression.hs+1−1
@@ -36,7 +36,7 @@ data Def tipe var
3636 | TypeAnnotation String Type.Type
3737 deriving (Eq, Show)
3838
39−tuple es = Data ("Tuple" ++ show (length es)) es
39+tuple es = Data ("_Tuple" ++ show (length es)) es
4040
4141delist (Location.L _ _ (Data "::" [h,t])) = h : delist t
4242delist _ = []
compiler/SourceSyntax/Helpers.hs+1−1
@@ -6,7 +6,7 @@ import Data.Char (isSymbol,isDigit)
66brkt s = "{ " ++ s ++ " }"
77
88isTuple name =
9− take 5 name == "Tuple" && all isDigit (drop 5 name)
9+ take 6 name == "_Tuple" && all isDigit (drop 6 name)
1010
1111isOp c =
1212 isSymbol c || elem c "+-/*=.$<>:&|^?%#@~!"
compiler/SourceSyntax/Pattern.hs+1−1
@@ -19,7 +19,7 @@ data Pattern = PData String [Pattern]
1919cons h t = PData "::" [h,t]
2020nil = PData "[]" []
2121list = foldr cons nil
22−tuple es = PData ("Tuple" ++ show (length es)) es
22+tuple es = PData ("_Tuple" ++ show (length es)) es
2323
2424
2525instance Pretty Pattern where
compiler/SourceSyntax/Type.hs+1−1
@@ -23,7 +23,7 @@ listOf :: Type -> Type
2323listOf t = Data "List" [t]
2424
2525tupleOf :: [Type] -> Type
26−tupleOf ts = Data ("Tuple" ++ show (length ts)) ts
26+tupleOf ts = Data ("_Tuple" ++ show (length ts)) ts
2727
2828
2929instance Pretty Type where
compiler/Type/Constrain/Declaration.hs+1−1
@@ -36,7 +36,7 @@ test filePath = do
3636 let expr = sortDefs (toExpr decls)
3737 print $ pretty expr
3838 constraint <- TcExpr.constrain env expr (T.VarN var)
39− print =<< T.extraPretty constraint
39+ --print =<< T.extraPretty constraint
4040 (env,_,_,errors) <- execStateT (solve constraint) TS.initialState
4141 forM (Map.toList env) $ \(n,t) -> do
4242 pt <- T.extraPretty t
tests/good/Soundness.elm+4−1
@@ -1,4 +1,8 @@
11
2+type F = {
3+ x : Int
4+}
5+
26trickyID x = let y = x in y
37
48quad f = twice (twice f)
@@ -6,4 +10,3 @@ twice f x = f (f x)
610
711n = quad (quad trickyID) 4
812c = twice trickyID 'a'
9−