Skip to content
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

Allow restricted higher-rank polymorphism #58

Closed
evincarofautumn opened this issue Jul 30, 2013 · 2 comments
Closed

Allow restricted higher-rank polymorphism #58

evincarofautumn opened this issue Jul 30, 2013 · 2 comments

Comments

@evincarofautumn
Copy link
Owner

It should be possible to write this function:

def trip (a a (a a -> a) -> (a & a & a)):
  -> { a b f }
  a b f@
  a b f@
  a b f@
  pair pair

But its type is:

r s a. r a a (s a as a) → r (a & a & a))

When it should be the rank-2:

r a. r a a (∀s. a as a) → r (a & a & a))

So the compiler complains because f is applied to different stack types.

@strager
Copy link
Collaborator

strager commented Aug 1, 2013

Why not this?

def trip (a a (a a -> a) -> (a & a & a)):
  -> { a b f }
  a b f@  // fat
  dup dup
  pair pair

Or is it just a bad example?

@kchaloux
Copy link
Collaborator

kchaloux commented Aug 1, 2013

There is already a workaround for it:

def trip (a a (a a -> a) -> (a & a & a)):
  -> { a b c }
  a b f@ -> x
  a b f@ -> y
  a b f@ -> z
  x y z pair pair

But the behavior that most would probably expect would be for invocations of f to still be valid when applied multiple times, the same way any normal local can be pushed onto the stack multiple times after it is bound.

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

No branches or pull requests

3 participants