From 7fedc4323196d4422ea2b1afc3a8cfa800a71eaf Mon Sep 17 00:00:00 2001 From: Giuseppe Castagna Date: Tue, 15 Jul 2014 00:33:31 +0200 Subject: [PATCH] Added few twisted examples --- tests/poly/part2.cd | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/poly/part2.cd b/tests/poly/part2.cd index 8cdde78c..098f13f8 100644 --- a/tests/poly/part2.cd +++ b/tests/poly/part2.cd @@ -41,9 +41,34 @@ let balance ( Unbal ->Rtree ; ('b \ Unbal) ->('b \ Unbal) ) -> [ [ a b ] [ c d ] ] | x -> x ;; +let r = balance [ [ [ 1 2] 3 ]4];; +let id ('a -> 'a) + Int -> "foo" + | x -> x +;; + +(* some tricky examples *) let f (_ : ('a | 'b | 'c)) (_ : (Int&'d&'e \1--3 )) : Any = raise "123";; +let x = id even (even mmap) even;; (* same type as map_even *) + +let twisted = id even (even mmap) even (mmap max [1 2 3 4 5 6]);; + +let apply_to_3 (f: Int -> 'a): 'a = f 3 in + mmap apply_to_3 twisted +;; + +type A = 'a +type B = [(A|B)];; + +let f (_ : 'a -> 'a -> 'a)(z : 'a)(_ : A|B) : A = z;; + +let x = f sum;; + + +(* Some expressions that are ill typed *) + let balance (Unbal ->Rtree ; 'a -> 'a ) | [ [ [ a b ] c ] d ] | [ [ a [ b c ] ] d ] @@ -52,12 +77,10 @@ let balance (Unbal ->Rtree ; 'a -> 'a ) -> [ [ a b ] [ c d ] ] | x -> x ;; -let r = balance [ [ [ 1 2] 3 ]4];; let id ('a -> 'a) Int -> "foo" | x -> x ;; -id 42;; let apply ( f : 'a -> 'b) (x : 'a ) : 'b = f (x,x) ;; -- GitLab