Skip to content

Commit

Permalink
syntax sugar for self types on ADTs
Browse files Browse the repository at this point in the history
the following syntax:

data[] Bool { #True:Bool #False:Bool }: Bool

will desugar to:

$(s: Bool) data[] Bool { #True:Bool #False:Bool }

the extra self type is useful for equality, for the reasons below:
https://gist.github.com/VictorTaelin/3f748a46e95071e29462b1ac93c294c5
  • Loading branch information
VictorTaelin committed Oct 21, 2024
1 parent 1dcb8f7 commit 6771da0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Kind/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,14 @@ parseDat = withSrc $ do
tele <- parseTele
return $ Ctr nm tele
char_end '}'
return $ Dat scp cts
ann <- P.optionMaybe $ P.try $ do
skip
char_skp ':'
parseTerm
let dat = Dat scp cts
return $ case ann of
Just a -> Slf "" a (\x -> dat)
Nothing -> dat

parseTele :: Parser Tele
parseTele = do
Expand Down

0 comments on commit 6771da0

Please sign in to comment.