-
Notifications
You must be signed in to change notification settings - Fork 459
Institute parser for Core. #42
Conversation
I tried to pull the history from this patch over but I was not able to figure out how to resolve conflicts from `git am`.
robrix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one 👍
| ] | ||
|
|
||
| comp :: (TokenParsing m, Monad m) => m Core | ||
| comp = braces (sconcat <$> sepEndByNonEmpty expr semi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be labelled (<?>)?
| expr :: (TokenParsing m, Monad m) => m Core | ||
| expr = chainl1 atom go where | ||
| go = choice [ (:.) <$ dot | ||
| , (:$) <$ notFollowedBy dot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
argh I still love this so much
|
|
||
| lambda :: (TokenParsing m, Monad m) => m Core | ||
| lambda = Lam <$ lambduh <*> name <* arrow <*> core <?> "lambda" where | ||
| lambduh = symbolic 'λ' <|> symbolic '\\' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on an Emacs function I have to insert a literal lambda: obviously, lambda has a tendency to collide with Lisp operators 😂
| lambda :: (TokenParsing m, Monad m) => m Core | ||
| lambda = Lam <$ lambduh <*> name <* arrow <*> core <?> "lambda" where | ||
| lambduh = symbolic 'λ' <|> symbolic '\\' | ||
| arrow = symbol "→" <|> symbol "->" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m still kind of ambivalent about unicode symbols in general, but the pretty-printer is awfully nice and round-tripping seems like a good property, so 👍
| strpath = Path <$> between (symbolic '"') (symbolic '"') (some $ noneOf "\"") | ||
|
|
||
| lit :: (TokenParsing m, Monad m) => m Core | ||
| lit = let x `given` n = x <$ reserved n in choice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always forget you can define infix functions this way, just like any other operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! And you can give them a custom precedence, too!
| @@ -0,0 +1,118 @@ | |||
| {-# LANGUAGE ExplicitForAll, FlexibleInstances, LambdaCase, MultiParamTypeClasses, OverloadedLists, | |||
| ScopedTypeVariables #-} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think we’re using any of these extensions any more. No foralls, no instances, no \case, and the HashSet is being defined in Data.Name now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
robrix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few suggestions. Nice!
| name = \case | ||
| Gen p -> pretty p | ||
| Path p -> strlit (Pretty.viaShow p ) | ||
| User n -> encloseIf (needsQuotation n) (symbol "#{") (symbol "}") (pretty n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
| infixl 2 :$$ | ||
| infixr 1 :>>$ | ||
| infix 3 :=$ | ||
| infixl 4 :.$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
I tried to pull the history from this patch over but I was not able to
figure out how to resolve conflicts from
git am.