Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
7fedc432
Commit
7fedc432
authored
Jul 15, 2014
by
Giuseppe Castagna
Browse files
Added few twisted examples
parent
8ff33414
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/poly/part2.cd
View file @
7fedc432
...
@@ -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)
;;
;;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment