sugar on binders
This commit is contained in:
@@ -12,7 +12,7 @@ List : U -> U
|
|||||||
List = \ A => (L : U) -> L -> (A -> L -> L) -> L
|
List = \ A => (L : U) -> L -> (A -> L -> L) -> L
|
||||||
|
|
||||||
-- need more sugar for lambdas
|
-- need more sugar for lambdas
|
||||||
nil : (A : U) -> (L : U) -> L -> (A -> L -> L) -> L
|
nil : (A L : U) -> L -> (A -> L -> L) -> L
|
||||||
nil = \ A => \ L => \ n => \ f => n
|
nil = \ A => \ L => \ n => \ f => n
|
||||||
|
|
||||||
Bool : U
|
Bool : U
|
||||||
|
|||||||
@@ -176,36 +176,37 @@ term = caseExpr
|
|||||||
<|> lamExpr
|
<|> lamExpr
|
||||||
<|> parseOp
|
<|> parseOp
|
||||||
|
|
||||||
expBinder : Parser Raw
|
|
||||||
expBinder = do
|
ebind : Parser (List (String, Icit, Raw))
|
||||||
|
ebind = do
|
||||||
sym "("
|
sym "("
|
||||||
name <- ident
|
names <- some ident
|
||||||
sym ":"
|
sym ":"
|
||||||
ty <- typeExpr
|
ty <- typeExpr
|
||||||
sym ")"
|
sym ")"
|
||||||
sym "->"
|
pure $ map (\name => (name, Explicit, ty)) names
|
||||||
scope <- typeExpr
|
|
||||||
pure $ RPi (Just name) Explicit ty scope
|
|
||||||
|
|
||||||
impBinder : Parser Raw
|
ibind : Parser (List (String, Icit, Raw))
|
||||||
impBinder = do
|
ibind = do
|
||||||
sym "{"
|
sym "{"
|
||||||
name <- ident
|
names <- some ident
|
||||||
sym ":"
|
sym ":"
|
||||||
ty <- typeExpr
|
ty <- typeExpr
|
||||||
sym "}"
|
sym "}"
|
||||||
|
pure $ map (\name => (name, Explicit, ty)) names
|
||||||
|
|
||||||
|
-- Collect a bunch of binders (A : U) {y : A} -> ...
|
||||||
|
binders : Parser Raw
|
||||||
|
binders = do
|
||||||
|
binds <- many (ibind <|> ebind)
|
||||||
sym "->"
|
sym "->"
|
||||||
scope <- typeExpr
|
scope <- typeExpr
|
||||||
pure $ RPi (Just name) Implicit ty scope
|
pure $ foldr mkBind scope (join binds)
|
||||||
|
where
|
||||||
|
mkBind : (String, Icit, Raw) -> Raw -> Raw
|
||||||
|
mkBind (name, icit, ty) scope = RPi (Just name) icit ty scope
|
||||||
|
|
||||||
-- something binder looking
|
typeExpr = binders
|
||||||
-- todo sepby space or whatever
|
|
||||||
export
|
|
||||||
binder : Parser Raw
|
|
||||||
binder = expBinder <|> impBinder
|
|
||||||
|
|
||||||
|
|
||||||
typeExpr = binder
|
|
||||||
<|> do
|
<|> do
|
||||||
exp <- term
|
exp <- term
|
||||||
scope <- optional (sym "->" *> mustWork typeExpr)
|
scope <- optional (sym "->" *> mustWork typeExpr)
|
||||||
|
|||||||
Reference in New Issue
Block a user