on master help sign in
Add -Wall to a bunch of SourceSyntax files and get them warning free
commit270dbf87223162e679ebdfa5113621e271d3d023 authorEvan Czaplicki <info@elm-lang.org> dateSat 4 Jan 2014, 10:14 (13 years ago) parent863d31b
7 files changed+32−23
compiler/SourceSyntax/Declaration.hs+13−3 compiler/SourceSyntax/Helpers.hs+1−1 compiler/SourceSyntax/Literal.hs+1 compiler/SourceSyntax/Module.hs+2−14 compiler/SourceSyntax/Pattern.hs+10−2 compiler/SourceSyntax/Type.hs+5−1 compiler/SourceSyntax/Variable.hs−2
compiler/SourceSyntax/Declaration.hs+13−3
@@ -13,7 +13,7 @@ data Declaration' port def
1313 | TypeAlias String [String] T.Type [Derivation]
1414 | Port port
1515 | Fixity Assoc Int String
16− deriving (Eq, Show)
16+ deriving (Show)
1717
1818data Assoc = L | N | R
1919 deriving (Eq)
@@ -25,12 +25,12 @@ data ParsePort
2525 = PortAnnotation String T.Type
2626 | SendDefinition String Expr.LParseExpr
2727 | RecvDefinition String Expr.LParseExpr
28− deriving (Eq,Show)
28+ deriving (Show)
2929
3030data Port
3131 = Send String Expr.LExpr T.Type
3232 | Recv String Expr.LExpr T.Type
33− deriving (Eq,Show)
33+ deriving (Show)
3434
3535type ParseDeclaration = Declaration' ParsePort Expr.ParseDef
3636type Declaration = Declaration' Port Expr.Def
@@ -59,6 +59,16 @@ instance Show Assoc where
5959 N -> "non"
6060 R -> "right"
6161
62+instance Binary Assoc where
63+ get = do n <- getWord8
64+ return $ case n of
65+ 0 -> L
66+ 1 -> N
67+ 2 -> R
68+ _ -> error "Error reading valid associativity from serialized string"
69+
70+ put assoc = putWord8 $ case assoc of { L -> 0 ; N -> 1 ; R -> 2 }
71+
6272instance (Pretty port, Pretty def) => Pretty (Declaration' port def) where
6373 pretty decl =
6474 case decl of
compiler/SourceSyntax/Helpers.hs+1−1
@@ -1,4 +1,4 @@
1−
1+{-# OPTIONS_GHC -Wall #-}
22module SourceSyntax.Helpers where
33
44import qualified Data.Char as Char
compiler/SourceSyntax/Literal.hs+1
@@ -1,3 +1,4 @@
1+{-# OPTIONS_GHC -Wall #-}
12module SourceSyntax.Literal where
23
34import SourceSyntax.PrettyPrint
compiler/SourceSyntax/Module.hs+2−14
@@ -1,15 +1,13 @@
1+{-# OPTIONS_GHC -Wall #-}
12module SourceSyntax.Module where
23
34import Data.Binary
4−import Data.List (intercalate)
55import qualified Data.Map as Map
66import Control.Applicative ((<$>), (<*>))
7−import Control.Arrow (second)
87
98import SourceSyntax.Expression (LExpr)
109import SourceSyntax.Declaration
1110import SourceSyntax.Type
12−import System.FilePath (joinPath)
1311
1412import qualified Elm.Internal.Version as Version
1513
@@ -66,6 +64,7 @@ data ModuleInterface = ModuleInterface {
6664 iFixities :: [(Assoc, Int, String)]
6765} deriving Show
6866
67+metaToInterface :: MetadataModule -> ModuleInterface
6968metaToInterface metaModule =
7069 ModuleInterface
7170 { iVersion = Version.elmVersion
@@ -85,14 +84,3 @@ instance Binary ModuleInterface where
8584 put (iAdts modul)
8685 put (iAliases modul)
8786 put (iFixities modul)
88−
89−
90−instance Binary Assoc where
91− get = do n <- getWord8
92− return $ case n of
93− 0 -> L
94− 1 -> N
95− 2 -> R
96− _ -> error "Error reading valid associativity from serialized string"
97−
98− put assoc = putWord8 $ case assoc of { L -> 0 ; N -> 1 ; R -> 2 }
compiler/SourceSyntax/Pattern.hs+10−2
@@ -1,6 +1,6 @@
1+{-# OPTIONS_GHC -Wall #-}
12module SourceSyntax.Pattern where
23
3−import Data.List (intercalate)
44import SourceSyntax.Helpers as Help
55import SourceSyntax.PrettyPrint
66import Text.PrettyPrint as PP
@@ -15,9 +15,16 @@ data Pattern = PData String [Pattern]
1515 | PLiteral Literal.Literal
1616 deriving (Eq, Ord, Show)
1717
18+cons :: Pattern -> Pattern -> Pattern
1819cons h t = PData "::" [h,t]
19−nil = PData "[]" []
20+
21+nil :: Pattern
22+nil = PData "[]" []
23+
24+list :: [Pattern] -> Pattern
2025list = foldr cons nil
26+
27+tuple :: [Pattern] -> Pattern
2128tuple es = PData ("_Tuple" ++ show (length es)) es
2229
2330boundVars :: Pattern -> Set.Set String
@@ -48,6 +55,7 @@ instance Pretty Pattern where
4855 PP.parens . commaCat $ map pretty ps
4956 else hsep (PP.text name : map prettyParens ps)
5057
58+prettyParens :: Pattern -> Doc
5159prettyParens pattern = parensIf needsThem (pretty pattern)
5260 where
5361 needsThem =
compiler/SourceSyntax/Type.hs+5−1
@@ -1,3 +1,4 @@
1+{-# OPTIONS_GHC -Wall #-}
12module SourceSyntax.Type where
23
34import Data.Binary
@@ -31,7 +32,7 @@ tupleOf ts = Data ("_Tuple" ++ show (length ts)) ts
3132instance Pretty Type where
3233 pretty tipe =
3334 case tipe of
34− Lambda t1 t2 -> P.sep [ t, P.sep (map (P.text "->" <+>) ts) ]
35+ Lambda _ _ -> P.sep [ t, P.sep (map (P.text "->" <+>) ts) ]
3536 where t:ts = collectLambdas tipe
3637 Var x -> P.text x
3738 Data "_List" [t] -> P.brackets (pretty t)
@@ -47,12 +48,14 @@ instance Pretty Type where
4748 prettyField (f,t) = P.text f <+> P.text ":" <+> pretty t
4849 prettyFields = commaSep . map prettyField $ fields
4950
51+collectLambdas :: Type -> [Doc]
5052collectLambdas tipe =
5153 case tipe of
5254 Lambda arg@(Lambda _ _) body -> P.parens (pretty arg) : collectLambdas body
5355 Lambda arg body -> pretty arg : collectLambdas body
5456 _ -> [pretty tipe]
5557
58+collectRecords :: Type -> ([(String,Type)], Type)
5659collectRecords = go []
5760 where
5861 go fields tipe =
@@ -60,6 +63,7 @@ collectRecords = go []
6063 Record fs ext -> go (fs ++ fields) ext
6164 _ -> (fields, tipe)
6265
66+prettyParens :: Type -> Doc
6367prettyParens tipe = parensIf needed (pretty tipe)
6468 where
6569 needed =
compiler/SourceSyntax/Variable.hsdeleted−2
@@ -1,2 +0,0 @@
1−module SourceSyntax.Variable where
2−