aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2022-03-04 14:47:25 +0100
committerMarvin Borner2022-03-04 14:47:25 +0100
commit056bc4c1527e46aac3953b41944dfe64a8aba1e7 (patch)
tree976a01c99aeb5a4306946bfb5e3f601b1e17ca0e
parent67978b6da9092a37921da6351a82d46a74ca3515 (diff)
Lists
-rw-r--r--src/Fun/Grammar.hs17
-rw-r--r--src/Fun/Typer.hs2
2 files changed, 14 insertions, 5 deletions
diff --git a/src/Fun/Grammar.hs b/src/Fun/Grammar.hs
index 422a211..7ec9e42 100644
--- a/src/Fun/Grammar.hs
+++ b/src/Fun/Grammar.hs
@@ -77,12 +77,21 @@ functionTypes =
<+> functionType
>>> build
<?> "function types"
- where build (a, b) = (map resolveType a) ++ [resolveType b]
+ where build (a, b) = a ++ [b]
-functionType :: Parser String
+functionType :: Parser Type
functionType =
- (letter <=> isUpper) <+> oneOrMore alphanum >>> build <?> "function type"
- where build (first, rest) = first : rest
+ (letter <=> isUpper)
+ <+> oneOrMore alphanum
+ >>> build
+ <|> literal '['
+ <-+> functionType
+ <+-> literal ']'
+ >>> buildList
+ <?> "function type"
+ where
+ build (first, rest) = resolveType $ first : rest
+ buildList t = ListType t
functionTypeDelimiter :: Parser Char
functionTypeDelimiter = literal ':' <?> "function type delimiter"
diff --git a/src/Fun/Typer.hs b/src/Fun/Typer.hs
index def34a1..efed9cc 100644
--- a/src/Fun/Typer.hs
+++ b/src/Fun/Typer.hs
@@ -1,6 +1,6 @@
module Fun.Typer where
-data Type = UnknownType | NormalType String
+data Type = UnknownType | NormalType String | ListType Type
deriving Show
-- TODO: Struct (like 'data' with mutiple), Union (like 'data' with '|')