change {A} to mean {_ : A} instead of {A : _}

This commit is contained in:
2024-11-06 21:10:05 -08:00
parent 375c16f4fd
commit eb1388caa8
3 changed files with 18 additions and 17 deletions

View File

@@ -225,7 +225,8 @@ varname = (ident <|> uident <|> keyword "_" *> pure "_")
ebind : Parser (List (FC, String, Icit, Raw))
ebind = do
-- don't commit until we see the ":"
names <- try (sym "(" *> some (withPos varname) <* sym ":")
sym "("
names <- try (some (withPos varname) <* sym ":")
ty <- typeExpr
sym ")"
pure $ map (\(pos, name) => (pos, name, Explicit, ty)) names
@@ -234,18 +235,18 @@ ibind : Parser (List (FC, String, Icit, Raw))
ibind = do
sym "{"
-- REVIEW - I have name required and type optional, which I think is the opposite of what I expect
names <- some $ withPos varname
ty <- optional (sym ":" >> typeExpr)
names <- try (some (withPos varname) <* sym ":")
ty <- typeExpr
sym "}"
pure $ map (\(pos,name) => (pos, name, Implicit, fromMaybe (RImplicit pos) ty)) names
pure $ map (\(pos,name) => (pos, name, Implicit, ty)) names
abind : Parser (List (FC, String, Icit, Raw))
abind = do
sym "{{"
names <- some $ withPos varname
ty <- optional (sym ":" >> typeExpr)
names <- try (some (withPos varname) <* sym ":")
ty <- typeExpr
sym "}}"
pure $ map (\(pos,name) => (pos, name, Auto, fromMaybe (RImplicit pos) ty)) names
pure $ map (\(pos,name) => (pos, name, Auto, ty)) names
arrow : Parser Unit
arrow = sym "->" <|> sym ""