drop old record syntax

This commit is contained in:
2026-03-29 10:27:35 -07:00
parent ee9664838f
commit 2f1185bf4c
3 changed files with 4 additions and 15 deletions

View File

@@ -109,7 +109,6 @@ asAtom = do
recordUpdate : Parser Raw recordUpdate : Parser Raw
recordUpdate' : Parser Raw
parenTypeExp : Parser Raw parenTypeExp : Parser Raw
parenTypeExp = do parenTypeExp = do
@@ -127,7 +126,7 @@ atom : Parser Raw
atom = do atom = do
pure MkUnit pure MkUnit
RU <$> getPos <* keyword "U" RU <$> getPos <* keyword "U"
<|> recordUpdate' <|> recordUpdate
-- <|> RVar <$> getPos <*> ident -- <|> RVar <$> getPos <*> ident
<|> asAtom <|> asAtom
<|> RVar <$> getPos <*> uident <|> RVar <$> getPos <*> uident
@@ -136,7 +135,6 @@ atom = do
<|> RImplicit <$> getPos <* keyword "_" <|> RImplicit <$> getPos <* keyword "_"
<|> RHole <$> getPos <* keyword "?" <|> RHole <$> getPos <* keyword "?"
<|> parenTypeExp <|> parenTypeExp
<|> recordUpdate
updateClause : Parser UpdateClause updateClause : Parser UpdateClause
updateClause = do updateClause = do
@@ -148,16 +146,7 @@ updateClause = do
True => pure $ AssignField fc nm tm True => pure $ AssignField fc nm tm
_ => pure $ ModifyField fc nm tm _ => pure $ ModifyField fc nm tm
-- ambiguity vs {a} or {a} -> ... is tough, we can do [] or put a keyword in front.
recordUpdate = do recordUpdate = do
fc <- getPos
symbol "["
clauses <- sepBy (symbol ";") updateClause
symbol "]"
tm <- optional atom
pure $ RUpdateRec fc clauses tm
recordUpdate' = do
fc <- getPos fc <- getPos
symbol "{" symbol "{"
clauses <- sepBy (symbol ";") updateClause clauses <- sepBy (symbol ";") updateClause

View File

@@ -9,4 +9,4 @@ record Bar where
foo : Foo foo : Foo
blah : Bar Bar blah : Bar Bar
blah x = [ foo $= [ bar := 1]] x blah x = { foo $= { bar := 1}} x

View File

@@ -8,12 +8,12 @@ record Foo where
baz : Nat baz : Nat
blah : Foo Foo blah : Foo Foo
blah x = [ bar := Z ] x blah x = { bar := Z } x
main : IO Unit main : IO Unit
main = do main = do
let x = blah $ MkFoo (S Z) (S (S Z)) let x = blah $ MkFoo (S Z) (S (S Z))
printLn x.bar printLn x.bar
-- this is unfortunate, it can't get record type from a meta -- this is unfortunate, it can't get record type from a meta
let x' = the Foo $ [ baz := Z ] x let x' = the Foo $ { baz := Z } x
printLn x'.baz printLn x'.baz