(ann f : (case-> (-> Boolean (U Integer String))
(-> Integer (U Integer String))))
but does not recognize this correct type:
(ann f : (case-> (-> Boolean String)
(-> Integer Integer)))
=>
Type Checker: type mismatch
expected: (case-> (-> Boolean String) (-> Integer Integer))
given: (-> (U Boolean Integer) (U Integer String)) in: f
Is there a reason TR cannot compute the last type? Is it a performance issue?
Alex Knauth
unread,
Aug 8, 2016, 7:56:04 PM8/8/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Stephen Chang, dev
The only reason it couldn't assign that type is because of the type annotation you put on x. If you take away the (U Integer Boolean) annotation an x this works:
Once you put the (U Integer Boolean) annotation, it can treat f as having any super type of (-> (U Boolean Integer) (U Integer String)), but it won't infer anything more specific than what the annotations say.
P.S.
> (case-> (-> Boolean (U Integer String))
> (-> Integer (U Integer String)))
This is a super-type of (-> (U Boolean Integer) (U Integer String)). It's a super-type because both (-> Boolean (U Integer String)) and (-> Integer (U Integer String)) are super-types. It's not equivalent under the current sub-typing rules though, because you can't pass a value of type (U Integer Boolean) to it.
Alex Knauth
Stephen Chang
unread,
Aug 8, 2016, 10:48:56 PM8/8/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Alex Knauth, dev
Thanks, that makes sense.
I guess I was wondering if it would be sound to treat U inputs
specially and convert the function type to a case-> first, and then
compute the return type of each case individually, to get the more
precise type.
As I'm typing this out, I realize that my suggestion would introduce
an ordering. But could intersection types help here?