forall / ∀ syntactic sugar
This commit is contained in:
@@ -252,6 +252,15 @@ arrow : Parser Unit
|
||||
arrow = sym "->" <|> sym "→"
|
||||
|
||||
-- Collect a bunch of binders (A : U) {y : A} -> ...
|
||||
|
||||
forAll : Parser Raw
|
||||
forAll = do
|
||||
keyword "forall" <|> keyword "∀"
|
||||
all <- some (withPos varname)
|
||||
keyword "."
|
||||
scope <- typeExpr
|
||||
pure $ foldr (\ (fc, n), sc => RPi fc (Just n) Implicit (RImplicit fc) sc) scope all
|
||||
|
||||
binders : Parser Raw
|
||||
binders = do
|
||||
binds <- many (abind <|> ibind <|> ebind)
|
||||
@@ -262,7 +271,9 @@ binders = do
|
||||
mkBind : FC -> (String, Icit, Raw) -> Raw -> Raw
|
||||
mkBind fc (name, icit, ty) scope = RPi fc (Just name) icit ty scope
|
||||
|
||||
typeExpr = binders
|
||||
typeExpr
|
||||
= binders
|
||||
<|> forAll
|
||||
<|> do
|
||||
fc <- getPos
|
||||
exp <- term
|
||||
|
||||
@@ -8,10 +8,8 @@ import Lib.Common
|
||||
keywords : List String
|
||||
keywords = ["let", "in", "where", "case", "of", "data", "U", "do",
|
||||
"ptype", "pfunc", "module", "infixl", "infixr", "infix",
|
||||
"->", "→", ":", "=>", ":=", "=", "<-", "\\", "_"]
|
||||
|
||||
specialOps : List String
|
||||
specialOps = ["->", ":", "=>", ":=", "=", "<-"]
|
||||
"∀", "forall", ".",
|
||||
"->", "→", ":", "=>", ":=", "=", "<-", "\\", "_"]
|
||||
|
||||
checkKW : String -> Token Kind
|
||||
checkKW s = if elem s keywords then Tok Keyword s else Tok Ident s
|
||||
@@ -20,10 +18,10 @@ checkUKW : String -> Token Kind
|
||||
checkUKW s = if elem s keywords then Tok Keyword s else Tok UIdent s
|
||||
|
||||
identMore : Lexer
|
||||
identMore = alphaNum <|> exact "." <|> exact "'" <|> exact "_"
|
||||
identMore = alphaNum <|> exact "'" <|> exact "_"
|
||||
|
||||
singleton : Lexer
|
||||
singleton = oneOf "()\\{}[],?"
|
||||
singleton = oneOf "()\\{}[],?."
|
||||
|
||||
quo : Recognise True
|
||||
quo = is '"'
|
||||
|
||||
Reference in New Issue
Block a user