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

Conversation

@robrix
Copy link
Contributor

@robrix robrix commented Jul 18, 2019

This PR simplifies our treatment of names significantly, 🔥ing Naming, Name, and Gensym in favour of much simpler local instantiations and folds.

Copy link
Contributor Author

@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.

Ready for review.

)
=> Analysis address value m
-> (Term Core User -> m value)
-> (Term Core User -> m value)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

eval now expects User names.

Lam _ b -> do
n <- Gen <$> fresh
abstract eval n (instantiate (const (pure n)) b)
Lam (Ignored n) b -> abstract eval n (instantiate1 (pure n) b)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of generating a fresh name and substituting it in, we instantiate the scope with the name the user gave the variable. Note that this is probably not what we’re going to want to do for e.g. computed functions, but since we evaluate by analysis instead of by substitution it should be safe.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is so exciting!!

@robrix robrix marked this pull request as ready for review July 19, 2019 15:39
@robrix robrix mentioned this pull request Jul 22, 2019
4 tasks
@robrix robrix requested a review from a team July 23, 2019 19:57
@robrix robrix changed the base branch from types-as-syntax to master August 2, 2019 18:37
Copy link
Contributor

@patrickt patrickt left a comment

Choose a reason for hiding this comment

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

Other than the question about User versus Name (and that’s not hugely important to me; I’d prefer to go with the established conventions in the literature), this looks 💯.

Lam _ b -> do
n <- Gen <$> fresh
abstract eval n (instantiate (const (pure n)) b)
Lam (Ignored n) b -> abstract eval n (instantiate1 (pure n) b)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is so exciting!!

[ let' "x" .= pure "_x"
, let' "y" .= pure "_y"]))
[ let' "this" .= Core.frame
, pure "this" Core.... let' "x" .= pure "_x"
Copy link
Contributor

Choose a reason for hiding this comment

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

$DEITY bless the Haskell parser for gamely accepting Core.....

Copy link
Contributor

Choose a reason for hiding this comment

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

Core.... I haven’t heard that name in years....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😂

import Data.Text.Prettyprint.Doc (Pretty (..))

-- | User-specified and -relevant names.
type User = Text
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point, now that there aren’t different varieties of names between which we have to distinguish, are we better off calling this Name, if only for the immediate comprehension of people new to the codebase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent idea 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going to do this in a later PR to avoid conflicts.

@robrix robrix merged commit 3617455 into master Aug 6, 2019
@robrix robrix deleted the gen-x branch August 6, 2019 15:14
@robrix robrix mentioned this pull request Aug 6, 2019
8 tasks
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