add small test to result.mlish

This commit is contained in:
Stephen Chang 2016-03-23 11:59:24 -04:00
parent ea3ed2a762
commit 06bed29150

View File

@ -26,11 +26,25 @@
: (Option Int)
-> (None {Int}))
;; args inferred in order, L-to-R, currently no backtracking
(check-type
(find (Nil {Int}) (λ ([x : Int]) (<= 2 x)))
: (Option Int)
-> (None {Int}))
;; reversing arg order leads to successful inference
(define (find2 [pred : (→ X Bool)] [lst : (List X)] → (Option X))
(match lst with
[Nil -> None]
[Cons fst rst ->
(cond [(pred fst) (Some fst)]
[else (find2 pred rst)])]))
(check-type
(find2 (λ ([x : Int]) (<= 2 x)) Nil)
: (Option Int)
-> (None {Int}))
(define (find-min/max [lst : (List X)] [<? : (→ Y Y Bool)] [extract-key : (→ X Y)]
→ (Option (× X X)))
(match lst with