on master help sign in
Merge branch 'master' into make
ad235f9Evan Czaplicki
src/Docs.hs+2−2
@@ -25,7 +25,7 @@ import qualified AST.Expression.Source as Src
25import qualified AST.Variable as Var
25import qualified AST.Variable as Var
26
26
27import Text.Parsec hiding (newline,spaces)
27import Text.Parsec hiding (newline,spaces)
28−import Parse.Declaration (alias,datatype,infixDecl)
28+import Parse.Declaration (typeDecl,infixDecl)
29import Parse.Expression (typeAnnotation)
29import Parse.Expression (typeAnnotation)
30import Parse.Helpers
30import Parse.Helpers
31import qualified Parse.Module as Module
31import qualified Parse.Module as Module
@@ -102,7 +102,7 @@ docThing = uncommentable <|> commented <|> uncommented ""
102 uncommented comment
102 uncommented comment
103
103
104 uncommented comment = do
104 uncommented comment = do
105− (src,def) <- withSource $ choice [ alias, datatype, D.Definition <$> typeAnnotation ]
105+ (src,def) <- withSource $ choice [ typeDecl, D.Definition <$> typeAnnotation ]
106 return (comment, def, src)
106 return (comment, def, src)
107
107
108
108
src/Parse/Declaration.hs+23−20
@@ -9,32 +9,35 @@ import qualified Parse.Expression as Expr
9import Parse.Helpers
9import Parse.Helpers
10import qualified Parse.Type as Type
10import qualified Parse.Type as Type
11
11
12+
12declaration :: IParser D.SourceDecl
13declaration :: IParser D.SourceDecl
13declaration =
14declaration =
14− alias <|> datatype <|> infixDecl <|> port <|> definition
15+ typeDecl <|> infixDecl <|> port <|> definition
16+
15
17
16definition :: IParser D.SourceDecl
18definition :: IParser D.SourceDecl
17definition = D.Definition <$> Expr.def
19definition = D.Definition <$> Expr.def
18
20
21+
19−alias :: IParser D.SourceDecl
22+typeDecl :: IParser D.SourceDecl
20−alias = do
23+typeDecl =
21− reserved "type" <?> "type alias (type Point = {x:Int, y:Int})"
24+ do reserved "type" <?> "type declaration"
22− forcedWS
25+ forcedWS
26+ isAlias <- optionMaybe (string "alias" >> forcedWS)
27+ case isAlias of
28+ Just _ ->
23− name <- capVar
29+ do name <- capVar
24− args <- spacePrefix lowVar
30+ args <- spacePrefix lowVar
25− padded equals
31+ padded equals
26− tipe <- Type.expr
32+ tipe <- Type.expr
27− return (D.TypeAlias name args tipe)
33+ return (D.TypeAlias name args tipe)
28−
34+
29−datatype :: IParser D.SourceDecl
35+ Nothing ->
30−datatype = do
31− reserved "data" <?> "datatype definition (data T = A | B | ...)"
32− forcedWS
33− name <- capVar <?> "name of data-type"
36+ do name <- capVar <?> "name of data-type"
34− args <- spacePrefix lowVar
37+ args <- spacePrefix lowVar
35− padded equals
38+ padded equals
36− tcs <- pipeSep1 Type.constructor
39+ tcs <- pipeSep1 Type.constructor
37− return $ D.Datatype name args tcs
40+ return $ D.Datatype name args tcs
38
41
39
42
40infixDecl :: IParser D.SourceDecl
43infixDecl :: IParser D.SourceDecl
src/Parse/Helpers.hs+11−9
@@ -22,15 +22,17 @@ import qualified AST.Literal as L
22import qualified AST.PrettyPrint as P
22import qualified AST.PrettyPrint as P
23import qualified AST.Variable as Variable
23import qualified AST.Variable as Variable
24
24
25+reserveds :: [String]
26+reserveds =
25−reserveds = [ "if", "then", "else"
27+ [ "if", "then", "else"
26− , "case", "of"
28+ , "case", "of"
27− , "let", "in"
29+ , "let", "in"
28− , "data", "type"
30+ , "data", "type"
29− , "module", "where"
31+ , "module", "where"
30− , "import", "as", "hiding", "open"
32+ , "import", "as", "hiding", "open"
31− , "export", "foreign"
33+ , "export", "foreign"
32− , "deriving", "port"
34+ , "deriving", "port"
33− ]
35+ ]
34
36
35expecting = flip (<?>)
37expecting = flip (<?>)
36
38
tests/libraries/Test/Array.elm+2
@@ -37,6 +37,8 @@ tests =
37 , test "append" <| assertEqual [42,42,81,81,81] (Array.toList (Array.append (Array.repeat 2 42) (Array.repeat 3 81)))
37 , test "append" <| assertEqual [42,42,81,81,81] (Array.toList (Array.append (Array.repeat 2 42) (Array.repeat 3 81)))
38 , test "appendEmpty 1" <| assertEqual [1..33] (Array.toList (Array.append Array.empty (Array.fromList [1..33])))
38 , test "appendEmpty 1" <| assertEqual [1..33] (Array.toList (Array.append Array.empty (Array.fromList [1..33])))
39 , test "appendEmpty 2" <| assertEqual [1..33] (Array.toList (Array.append (Array.fromList [1..33]) Array.empty))
39 , test "appendEmpty 2" <| assertEqual [1..33] (Array.toList (Array.append (Array.fromList [1..33]) Array.empty))
40+ , test "appendSmall 1" <| assertEqual [1..33] (Array.toList (Array.append (Array.fromList [1..30]) (Array.fromList [31..33])))
41+ , test "appendSmall 2" <| assertEqual [1..33] (Array.toList (Array.append (Array.fromList [1..3]) (Array.fromList [4..33])))
40 , test "appendAndSlice" <| assertEqual [0..100] (Array.toList holeArray)
42 , test "appendAndSlice" <| assertEqual [0..100] (Array.toList holeArray)
41 ]
43 ]
42 getAndSetTests = suite "Get and Set"
44 getAndSetTests = suite "Get and Set"