on master help sign in
Get rid of dead dependencies and add -Wall for some files
6a8db4cEvan Czaplicki
compiler/Parse/Binop.hs−1
@@ -1,7 +1,6 @@
1module Parse.Binop (binops, OpTable) where
1module Parse.Binop (binops, OpTable) where
2
2
3import Control.Applicative ((<$>))
3import Control.Applicative ((<$>))
4−import Control.Monad.Error
5import Data.List (intercalate)
4import Data.List (intercalate)
6import qualified Data.Map as Map
5import qualified Data.Map as Map
7
6
compiler/Parse/Declaration.hs+5−9
@@ -1,15 +1,11 @@
1−
1+{-# OPTIONS_GHC -Wall -fno-warn-unused-do-bind #-}
2module Parse.Declaration where
2module Parse.Declaration where
3
3
4−import Control.Applicative ((<$>), (<*>))
4+import Control.Applicative ((<$>))
5−import qualified Data.List as List
6−import qualified Data.Set as Set
7import Text.Parsec hiding (newline,spaces)
5import Text.Parsec hiding (newline,spaces)
8−import Text.Parsec.Indent
9
6
10import Parse.Helpers
7import Parse.Helpers
11import qualified Parse.Expression as Expr
8import qualified Parse.Expression as Expr
12−import qualified SourceSyntax.Type as T
13import qualified Parse.Type as Type
9import qualified Parse.Type as Type
14import qualified SourceSyntax.Declaration as D
10import qualified SourceSyntax.Declaration as D
15
11
@@ -24,15 +20,15 @@ alias :: IParser D.ParseDeclaration
24alias = do
20alias = do
25 reserved "type" <?> "type alias (type Point = {x:Int, y:Int})"
21 reserved "type" <?> "type alias (type Point = {x:Int, y:Int})"
26 forcedWS
22 forcedWS
27− alias <- capVar
23+ name <- capVar
28− args <- spacePrefix lowVar
24+ args <- spacePrefix lowVar
29 padded equals
25 padded equals
30 tipe <- Type.expr
26 tipe <- Type.expr
31 json <- option [] $ do
27 json <- option [] $ do
32 try $ padded (reserved "deriving")
28 try $ padded (reserved "deriving")
33 string "Json"
29 string "Json"
34 return [D.Json]
30 return [D.Json]
35− return (D.TypeAlias alias args tipe json)
31+ return (D.TypeAlias name args tipe json)
36
32
37datatype :: IParser D.ParseDeclaration
33datatype :: IParser D.ParseDeclaration
38datatype = do
34datatype = do
compiler/Parse/Expression.hs+1−2
@@ -1,6 +1,5 @@
1module Parse.Expression (def,term,typeAnnotation,expr) where
1module Parse.Expression (def,term,typeAnnotation,expr) where
2
2
3−import Control.Arrow ((***))
4import Control.Applicative ((<$>), (<*>))
3import Control.Applicative ((<$>), (<*>))
5import Data.List (foldl')
4import Data.List (foldl')
6import Text.Parsec hiding (newline,spaces)
5import Text.Parsec hiding (newline,spaces)
@@ -206,7 +205,7 @@ defStart =
206 where
205 where
207 func pattern =
206 func pattern =
208 case pattern of
207 case pattern of
209− PVar v -> (pattern:) <$> spacePrefix Pattern.term
208+ PVar _ -> (pattern:) <$> spacePrefix Pattern.term
210 _ -> do try (lookAhead (whitespace >> string "="))
209 _ -> do try (lookAhead (whitespace >> string "="))
211 return [pattern]
210 return [pattern]
212
211
compiler/Parse/Literal.hs+3−4
@@ -1,13 +1,12 @@
1+{-# OPTIONS_GHC -Wall -fno-warn-unused-do-bind #-}
1module Parse.Literal (literal) where
2module Parse.Literal (literal) where
2
3
3−import Control.Applicative ((<$>), (<*>))
4+import Control.Applicative ((<$>))
4−import Control.Monad
5import Text.Parsec hiding (newline,spaces)
5import Text.Parsec hiding (newline,spaces)
6−import Text.Parsec.Indent
7−
8import Parse.Helpers
6import Parse.Helpers
9import SourceSyntax.Literal
7import SourceSyntax.Literal
10
8
9+literal :: IParser Literal
11literal = num <|> (Str <$> str) <|> (Chr <$> chr)
10literal = num <|> (Str <$> str) <|> (Chr <$> chr)
12
11
13num :: IParser Literal
12num :: IParser Literal
compiler/Parse/Module.hs+1−2
@@ -1,4 +1,3 @@
1−
2module Parse.Module (moduleDef, getModuleName, imports) where
1module Parse.Module (moduleDef, getModuleName, imports) where
3
2
4import Control.Applicative ((<$>), (<*>))
3import Control.Applicative ((<$>), (<*>))
@@ -6,7 +5,7 @@ import Data.List (intercalate)
6import Text.Parsec hiding (newline,spaces)
5import Text.Parsec hiding (newline,spaces)
7
6
8import Parse.Helpers
7import Parse.Helpers
9−import SourceSyntax.Module (Module(..), ImportMethod(..), Imports)
8+import SourceSyntax.Module (ImportMethod(..), Imports)
10
9
11varList :: IParser [String]
10varList :: IParser [String]
12varList = parens $ commaSep1 (var <|> parens symOp)
11varList = parens $ commaSep1 (var <|> parens symOp)
compiler/Parse/Type.hs+3−4
@@ -1,11 +1,9 @@
1+{-# OPTIONS_GHC -Wall -fno-warn-unused-do-bind #-}
1module Parse.Type where
2module Parse.Type where
2
3
3import Control.Applicative ((<$>),(<*>))
4import Control.Applicative ((<$>),(<*>))
4−import Control.Monad (liftM,mapM)
5−import Data.Char (isLower)
6−import Data.List (lookup,intercalate)
5+import Data.List (intercalate)
7import Text.Parsec
6import Text.Parsec
8−import Text.Parsec.Indent
9
7
10import SourceSyntax.Type as T
8import SourceSyntax.Type as T
11import Parse.Helpers
9import Parse.Helpers
@@ -42,6 +40,7 @@ record =
42 whitespace >> hasType >> whitespace
40 whitespace >> hasType >> whitespace
43 (,) lbl <$> expr
41 (,) lbl <$> expr
44
42
43+capTypeVar :: IParser String
45capTypeVar = intercalate "." <$> dotSep1 capVar
44capTypeVar = intercalate "." <$> dotSep1 capVar
46
45
47constructor0 :: IParser T.Type
46constructor0 :: IParser T.Type
compiler/Type/Constrain/Declaration.hs+8−13
@@ -1,13 +1,6 @@
1+{-# OPTIONS_GHC -Wall #-}
1module Type.Constrain.Declaration where
2module Type.Constrain.Declaration where
2
3
3−import Control.Monad
4−import Control.Applicative ((<$>))
5−
6−import qualified Data.Map as Map
7−
8−import qualified Type.Constrain.Expression as TcExpr
9−import qualified Type.Environment as Env
10−
11import SourceSyntax.Declaration
4import SourceSyntax.Declaration
12import qualified SourceSyntax.Expression as Src
5import qualified SourceSyntax.Expression as Src
13import qualified SourceSyntax.Location as L
6import qualified SourceSyntax.Location as L
@@ -22,15 +15,15 @@ toDefs decl =
22 case decl of
15 case decl of
23 Definition def -> [def]
16 Definition def -> [def]
24
17
25− Datatype name tvars constructors _ -> concatMap toDefs constructors
18+ Datatype name tvars constructors _ -> concatMap toDefs' constructors
26 where
19 where
27− toDefs (ctor, tipes) =
20+ toDefs' (ctor, tipes) =
28 let vars = take (length tipes) arguments
21 let vars = take (length tipes) arguments
29 tbody = Type.Data name $ map Type.Var tvars
22 tbody = Type.Data name $ map Type.Var tvars
30 body = L.none . Src.Data ctor $ map (L.none . Src.Var) vars
23 body = L.none . Src.Data ctor $ map (L.none . Src.Var) vars
31 in [ definition ctor (buildFunction body vars) (foldr Type.Lambda tbody tipes) ]
24 in [ definition ctor (buildFunction body vars) (foldr Type.Lambda tbody tipes) ]
32
25
33− TypeAlias name tvars tipe@(Type.Record fields ext) _ ->
26+ TypeAlias name _ tipe@(Type.Record fields ext) _ ->
34 [ definition name (buildFunction record vars) (foldr Type.Lambda tipe args) ]
27 [ definition name (buildFunction record vars) (foldr Type.Lambda tipe args) ]
35 where
28 where
36 args = case ext of
29 args = case ext of
@@ -53,7 +46,7 @@ toDefs decl =
53 Port port ->
46 Port port ->
54 case port of
47 case port of
55 Send name expr tipe -> [ definition name expr tipe ]
48 Send name expr tipe -> [ definition name expr tipe ]
56− Recv name expr tipe -> -- [ definition name ]
49+ Recv _ _ _ -> -- [ definition name ]
57 error "not sure how to generate constraints for recv yet"
50 error "not sure how to generate constraints for recv yet"
58
51
59 -- no constraints are needed for fixity declarations
52 -- no constraints are needed for fixity declarations
@@ -61,9 +54,11 @@ toDefs decl =
61
54
62
55
63arguments :: [String]
56arguments :: [String]
64−arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show n) [1..]
57+arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show (n :: Int)) [1..]
65
58
59+buildFunction :: Src.LExpr -> [String] -> Src.LExpr
66buildFunction body@(L.L s _) vars =
60buildFunction body@(L.L s _) vars =
67 foldr (\p e -> L.L s (Src.Lambda p e)) body (map P.PVar vars)
61 foldr (\p e -> L.L s (Src.Lambda p e)) body (map P.PVar vars)
68
62
63+definition :: String -> Src.LExpr -> Type.Type -> Src.Def
69definition name expr tipe = Src.Definition (P.PVar name) expr (Just tipe)
64definition name expr tipe = Src.Definition (P.PVar name) expr (Just tipe)
compiler/Type/Constrain/Expression.hs+1−1
@@ -3,7 +3,7 @@ module Type.Constrain.Expression where
3import qualified Data.List as List
3import qualified Data.List as List
4import qualified Data.Map as Map
4import qualified Data.Map as Map
5import qualified Data.Set as Set
5import qualified Data.Set as Set
6−import Control.Applicative ((<$>),(<*>))
6+import Control.Applicative ((<$>))
7import qualified Control.Monad as Monad
7import qualified Control.Monad as Monad
8import Control.Monad.Error
8import Control.Monad.Error
9import qualified Text.PrettyPrint as PP
9import qualified Text.PrettyPrint as PP
compiler/Type/Constrain/Pattern.hs−2
@@ -5,8 +5,6 @@ import Control.Arrow (second)
5import Control.Applicative ((<$>))
5import Control.Applicative ((<$>))
6import qualified Control.Monad as Monad
6import qualified Control.Monad as Monad
7import Control.Monad.Error
7import Control.Monad.Error
8−import qualified Data.List as List
9−import qualified Data.Maybe as Maybe
10import qualified Data.Map as Map
8import qualified Data.Map as Map
11import qualified Text.PrettyPrint as PP
9import qualified Text.PrettyPrint as PP
12
10