Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Conversation

@patrickt
Copy link
Contributor

@patrickt patrickt commented Jun 3, 2019

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.

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`.
@patrickt patrickt requested a review from robrix June 3, 2019 20:10
Copy link
Contributor

@robrix robrix left a 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)
Copy link
Contributor

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
Copy link
Contributor

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 '\\'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

Copy link
Contributor Author

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 "->"
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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 #-}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

@robrix robrix left a 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)
Copy link
Contributor

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 :.$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@patrickt patrickt mentioned this pull request Jun 4, 2019
@patrickt patrickt merged commit 0097a08 into master Jun 4, 2019
@patrickt patrickt deleted the parse-core branch June 4, 2019 23:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants