Commit 7fedc432 authored by Giuseppe Castagna's avatar Giuseppe Castagna

Added few twisted examples

parent 8ff33414
...@@ -41,9 +41,34 @@ let balance ( Unbal ->Rtree ; ('b \ Unbal) ->('b \ Unbal) ) ...@@ -41,9 +41,34 @@ let balance ( Unbal ->Rtree ; ('b \ Unbal) ->('b \ Unbal) )
-> <red (y)>[ <blk (x)>[ a b ] <blk (z)>[ c d ] ] -> <red (y)>[ <blk (x)>[ a b ] <blk (z)>[ c d ] ]
| x -> x | x -> x
;; ;;
let r = balance <blk elem=1>[ <red elem=1>[ <red elem=1>[ 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 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>'a
type B = <b>[(A|B)];;
let f (_ : 'a -> 'a -> 'a)(z : 'a)(_ : A|B) : A = <a>z;;
let x = f sum;;
(* Some expressions that are ill typed *)
let balance (Unbal ->Rtree ; 'a -> 'a ) let balance (Unbal ->Rtree ; 'a -> 'a )
| <blk (z)>[ <red (y)>[ <red (x)>[ a b ] c ] d ] | <blk (z)>[ <red (y)>[ <red (x)>[ a b ] c ] d ]
| <blk (z)>[ <red (x)>[ a <red (y)>[ b c ] ] d ] | <blk (z)>[ <red (x)>[ a <red (y)>[ b c ] ] d ]
...@@ -52,12 +77,10 @@ let balance (Unbal ->Rtree ; 'a -> 'a ) ...@@ -52,12 +77,10 @@ let balance (Unbal ->Rtree ; 'a -> 'a )
-> <red (y)>[ <blk (x)>[ a b ] <blk (z)>[ c d ] ] -> <red (y)>[ <blk (x)>[ a b ] <blk (z)>[ c d ] ]
| x -> x | x -> x
;; ;;
let r = balance <blk elem=1>[ <red elem=1>[ <red elem=1>[ 1 2] 3 ]4];;
let id ('a -> 'a) let id ('a -> 'a)
Int -> "foo" Int -> "foo"
| x -> x | x -> x
;; ;;
id 42;;
let apply ( f : 'a -> 'b) (x : 'a ) : 'b = let apply ( f : 'a -> 'b) (x : 'a ) : 'b =
f (x,x) f (x,x)
;; ;;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment