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
411a2ab0
Commit
411a2ab0
authored
Dec 06, 2014
by
Kim Nguyễn
Browse files
re-organise the test files and add new typing tests.
parent
9d34f8a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/poly/p
art2
.cd
→
tests/poly/p
oly-ok
.cd
View file @
411a2ab0
let pretty (x : Int) : String = string_of x
;;
let pretty (x : Int) : String = string_of x;;
let even (Int -> Bool; ('a\Int) -> ('a\Int))
| x & Int -> (x mod 2) = 0
| x -> x
;;
let mmap (f : 'a -> 'b) (l : [ ('a) *] ) : [ ('b) *] =
match l with
[] -> []
| (e, ll) -> (f e, mmap f ll)
;;
let map_even = mmap even
;;
let g ( (Int -> Int) -> Int -> Int;
(Bool -> Bool) -> Bool -> Bool) x -> x
;;
let id ('a -> 'a) x -> x;;
let gid = g id;;
let id2g = id (id g);;
let churchtrue (x : 'a) (
y
: 'b) : 'a = x in churchtrue 42;;
let churchtrue (x : 'a) (
_
: 'b) : 'a = x in churchtrue 42;;
let max (x : 'a) (y : 'a) : 'a = if x >> y then x else y;;
...
...
@@ -40,20 +45,21 @@ let apply_to_3 (f: Int -> 'a): 'a = f 3 in
mmap apply_to_3 twisted
;;
type A('a) = <a>'a
type A('a) = <a>('a)
type B('a) = <b>[(A('a)|B('a))];;
let f (_ : 'a -> 'a -> 'a)(z : 'a)(_ : A('a)|B('a)) : A('a) = <a>z;;
let sum (x : Int) (y : Int) : Int = x + y;;
let x = f sum;;
let sum (x : Int) (y : Int) : Int = x + y;;
(* Some expressions that are ill typed *)
let x = f sum;;
let id ('a -> 'a)
Int -> "foo"
| x -> x
;;
let apply ( f : 'a -> 'b) (x : 'a ) : 'b =
f (x,x)
let f ( x : B('a) ) : 'a =
match x with
<b>[ <a>i ] -> i
|<b>[ y ] -> f y
;;
let v = f <b>[<b>[<a>32]]
;;
\ No newline at end of file
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