[simplify the data type Type
Helmut Grohne <grohne@cs.uni-bonn.de>**20150209153158
 Ignore-this: 7e09228772a1b15bc375449fc28502cf
 
 Remove constructors ArrowT, ListT and TupleT. These can also be represented as
 compositions of AppT and ConT. Re-define their lower-case constructors suitably
 and improve pretty-printing to cover for these cases.
] hunk ./src/Syntax/Name.hs 4
-    isTuple,isAnyTuple,  isCons, isNil,
-    
+    arrowName, isTuple, isAnyTuple, isCons, isNil, listTypeName,
+
hunk ./src/Syntax/Name.hs 10
-import Language.Haskell.TH (Name, mkName, tupleDataName)
+import Language.Haskell.TH (Name, mkName, tupleDataName, tupleTypeName)
+
+arrowName :: Name
+arrowName = ''(->)
hunk ./src/Syntax/Name.hs 21
+listTypeName :: Name
+listTypeName = ''[]
+
hunk ./src/Syntax/Ppr.hs 10
+import Data.Maybe (fromMaybe)
hunk ./src/Syntax/Ppr.hs 64
-pprParendType (ConT c)   = pretty c
-pprParendType (TupleT 0) = text "()"
-pprParendType (TupleT n) = parens (hcat (replicate (n-1) comma))
-pprParendType ArrowT     = parens (text "->")
-pprParendType ListT      = text "[]"
+pprParendType (ConT c)   = fromMaybe (pretty c) $ lookup c (
+        (listTypeName, text "[]") :
+        (arrowName, parens (text "->")) :
+        (tupleTypeName 0, text "()") :
+        [ (tupleTypeName i, parens (hcat (replicate (i-1) comma))) | i <- [2..15] ])
hunk ./src/Syntax/Ppr.hs 72
-pprTyApp (ArrowT, [arg1,arg2]) = sep [pprFunArgType arg1 <+> text "->", pretty arg2]
-pprTyApp (ListT, [arg]) = brackets (pretty arg)
-pprTyApp (TupleT n, args)
- | length args == n = parens (sep (punctuate comma (map pretty args)))
+pprTyApp (ConT n, [arg1, arg2])
+  | n == arrowName = sep [pprFunArgType arg1 <+> text "->", pretty arg2]
+pprTyApp (ConT n, [arg])
+  | n == listTypeName = brackets (pretty arg)
+pprTyApp (ConT n, args)
+  | n == tupleTypeName (length args) = parens (sep (punctuate comma (map pretty args)))
hunk ./src/Syntax/Ppr.hs 84
-pprFunArgType ty@((ArrowT `AppT` _) `AppT` _) = parens (pretty ty)
+pprFunArgType ty@((ConT a `AppT` _) `AppT` _) | a == arrowName = parens (pretty ty)
hunk ./src/Syntax/Ppr.hs 213
+
hunk ./src/Syntax/Type.hs 59
- | TupleT Int
- | ArrowT
- | ListT
hunk ./src/Syntax/Type.hs 84
-isListT (AppT ListT _)    = True
hunk ./src/Syntax/Type.hs 92
-dataName (TupleT n)
-        | n<2            = return ''()
-        | otherwise      = return . mkName . concat $ ["(",replicate (n-1) ',',")"]
-dataName ArrowT          = return ''(->)
-dataName ListT           = return ''[]
hunk ./src/Syntax/Type.hs 123
+arrowCon = ConT ''(->)
+
hunk ./src/Syntax/Type.hs 126
-unArrowT (AppT (AppT ArrowT e1) e2) = e1 : (unArrowT e2)
+unArrowT (AppT (AppT a e1) e2) | a == arrowCon = e1 : unArrowT e2
hunk ./src/Syntax/Type.hs 136
-apArrowT t1 t2 = AppT (AppT ArrowT t1) t2
+apArrowT t1 t2 = AppT (AppT arrowCon t1) t2
hunk ./src/Syntax/Type.hs 142
-listT = AppT ListT
+listT = AppT (ConT ''[])
hunk ./src/Syntax/Type.hs 145
-tupT l = foldAppT (TupleT . length $ l) l
+tupT l = foldAppT (ConT (tupleDataName (length l))) l
hunk ./src/Syntax/Type.hs 192
-    -- tuples
-    sameSymAtRoot (TupleT i1) (TupleT i2)     = i1 == i2
-    sameSymAtRoot (TupleT i) (ConT n)         = isTuple n i
-    sameSymAtRoot (ConT n)(TupleT i)          = isTuple n i
-    -- lists
-    sameSymAtRoot ListT ListT                 = True
-    sameSymAtRoot ListT (ConT n)              = isNil n
-    sameSymAtRoot (ConT n) ListT              = isNil n
hunk ./src/Syntax/Type.hs 193
-    sameSymAtRoot ArrowT ArrowT               = True
hunk ./src/Syntax/UnifyTy.hs 50
-    match (TupleT i)(TupleT i') 
-        | i == i'                    = return nullSubst
-    match (ConT n)(ConT n')     
+    match (ConT n) (ConT n')
hunk ./src/Syntax/UnifyTy.hs 52
-    match ListT ListT                = return nullSubst
-    match ArrowT ArrowT              = return nullSubst
hunk ./src/Syntax/UnifyTy.hs 65
-    mgu (TupleT i)(TupleT i') 
-        | i == i'                  = return nullSubst
-    mgu (ConT n)(ConT n')     
+    mgu (ConT n) (ConT n')
hunk ./src/Syntax/UnifyTy.hs 67
-    mgu ListT ListT                = return nullSubst
-    mgu ArrowT ArrowT              = return nullSubst
