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

Subtyping on pairs #241

Closed
ngrimm opened this issue May 19, 2015 · 2 comments
Closed

Subtyping on pairs #241

ngrimm opened this issue May 19, 2015 · 2 comments

Comments

@ngrimm
Copy link
Contributor

ngrimm commented May 19, 2015

I had a problem with subtyping in pairs and I reduced it to this program:

module Pairs

val test1 : (x:int{x>0} * unit)
let test1 = 2, ()

val test2 : (x:int * unit)
let test2 = test1 

It fails with:

pairs.fst(7,12-7,17): Subtyping check failed; expected type (Tuple2 int unit); got type (Tuple2 x:int{(x > 0)} unit)
@catalin-hritcu
Copy link
Member

AFAIK this is a known limitation. Adding polarities would solve this, but for now you can build explicit coercion functions:

val coerce : (nat * unit) -> (int * unit)
let coerce p = let (x1,x2) = p in (x1,x2)

val test2' : (x:int * unit)
let test2' = coerce test1

@catalin-hritcu
Copy link
Member

There is already an issue about this #65, closing as duplicate.

catalin-hritcu added a commit that referenced this issue May 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants