这是indexloc提供的服务,不要输入任何密码
Skip to content

change type of partition #139

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 1 commit into from
May 20, 2015
Merged

change type of partition #139

merged 1 commit into from
May 20, 2015

Conversation

AlexKnauth
Copy link
Member

This change allows partition to accept a predicate that only takes the types that are in the list (or some super-set of that), and allows these predicates to return Any instead of Boolean, and it only cares about the positive side of the filter.

@samth
Copy link
Member

samth commented May 19, 2015

Can you add a test of the new functionality?

@AlexKnauth
Copy link
Member Author

I tried adding this test to typecheck-tests.rkt

        [tc-e (let ([pos-not-5? : [-> Real (U Positive-Real #f) : #:+ Positive-Real]
                                (λ (x) (and (positive? x) (not (= x 5)) x))])
                (partition pos-not-5? '(1 2 -3 4 5 -6)))
              (-values (list -PosReal -Real))]

But I got a failure including this error:

. . ../../../../../../../../../../Applications/Racket/2015-05-17/Racket v6.2.0.3/collects/racket/private/for.rkt:585:2: in-list: contract violation
  expected: list?
  given: (values (U 1 Byte-Larger-Than-One Positive-Index-Not-Byte Positive-Fixnum-Not-Index Positive-Integer-Not-Fixnum Positive-Rational-Not-Integer Float-Nan Positive-Float-No-NaN Single-Flonum-Nan Positive-Single-Flonum-No-Nan) (U 0 1 Byte-Larger-Than-...

What am I doing wrong?

@AlexKnauth
Copy link
Member Author

Ok, I figured out that I'm not supposed to use -values for this. I also realized that I put -PosReal and -Real where I should have put (-lst -PosReal) and (-lst -Real).

@AlexKnauth
Copy link
Member Author

I also had to switch the order of the cases in the type of partition to get it to infer the right type without an explicit annotation.

@samth
Copy link
Member

samth commented May 19, 2015

Looks good to me.

When committing this, try to avoid creating a merge commit (usually done by rebasing before pushing).

@AlexKnauth
Copy link
Member Author

I don't think rebasing first helps, does it? That's what I've done before for pull requests (and that's also what I did for this one) and it still creates the merge commit. I can try pushing directly to the racket/typed-racket repo though.

@AlexKnauth AlexKnauth merged commit e075523 into racket:master May 20, 2015
@AlexKnauth AlexKnauth deleted the partition branch May 20, 2015 00:19
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.

2 participants