Skip to content

Add the Boehm Berarducci encoding of Lists as a test #12841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 16, 2021

Add the Boehm Berarducci encoding of Lists in polymorphic lambda calculus as a test case. It's useful to verify
we are dealing correctly with polymorphic function types and lambdas and to track possible future improvements
in type inference. The type annotations given in the test case all seem to be necessary.

Add the Boehm Berarducci encoding of Lists in polymorphic lambda calculus as a test case

def fst[T](v: ListView[T]): T = v(hd => tl => hd)(() => ???)
def snd[T](v: ListView[T]): List[T] = v(hd => tl => tl)(() => ???)
def isPair[T](v: ListView[T]): Boolean = v(hd => tl => false)(() => true)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is reversed (true should be false, false should be true). Otherwise LGTM.

@odersky odersky merged commit b1d5760 into scala:master Jun 17, 2021
@odersky odersky deleted the add-polyfun-test branch June 17, 2021 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants