You do not have permission to delete messages in this group
Copy link
Report message
Sign in to 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 Racket Users, Sam Tobin-Hochstadt
I was somewhat surprised to see today that I can’t use a predicate with both positive and negative propositions in the way I would expect with partition:
> (:print-type partition)
(All (a b)
(case->
(-> (-> b Any : #:+ a) (Listof b) (values (Listof a) (Listof b)))
(-> (-> a Any) (Listof a) (values (Listof a) (Listof a)))))
Specifically, I would have expected the type to be something like this:
(All (a b c)
(case->
(-> (-> b Any : #:+ a) (Listof b) (values (Listof a) (Listof b)))
;; the second list must consist of 'c's:
(-> (-> b Any : #:+ a #:- c) (Listof b) (values (Listof a) (Listof c)))
(-> (-> a Any) (Listof a) (values (Listof a) (Listof a)))))
… so that if, say, I had a list of Elephants and Emus, that I could use elephant? to split it into two lists: one of type (Listof Elephant) and one of type (Listof Emu).
I tried to roll my own, and got pretty close:
(: my-partition
(All (a b c)
(case->
;; the second list must consist of 'c's:
(-> (-> b Any : #:+ a #:- c) (Listof b) (values (Listof a) (Listof c)))
)))
That is, I can do it for the case-> clause that I care about. Putting the other two back in there causes it to fail type-checking. Is that the problem, that TR can’t accommodate both flavors in the same type?
John
Ben Greenman
unread,
Oct 5, 2021, 7:45:31 PM10/5/21
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
Sign in to 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 John Clements, Racket Users, Sam Tobin-Hochstadt