-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexamples.tel
30 lines (25 loc) · 1.07 KB
/
examples.tel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- File for small illustrative telomare programs and for testing
-- Hello World example.
main = \input -> ("Hello, World!", 0)
-- -- refinement fail
-- main : (\x -> if x then "fail" else 0) = 1
-- Ad hoc user defined types example:
-- MyInt = let wrapper = \h -> ( \i -> if not i
-- then abort "MyInt cannot be 0"
-- else i
-- , \i -> if dEqual (left i) h
-- then 0
-- else abort "Not a MyInt"
-- )
-- in wrapper (# wrapper)
-- aux = \x -> if dEqual x 8 then "Success" else "Failure"
-- main = \i -> (aux ((left MyInt) 8), 0)
-- Case example
-- main =
-- let toCase = (("a string", 99),(8,"pattern-match"))
-- caseTest =
-- case toCase of
-- (0,(8,2)) -> "Failure 1"
-- ("a string",(8,x)) -> concat [x, " failure 2"]
-- (("a string", 99),(8,x)) -> concat [x, " success with ints, strings and variables"]
-- in \input -> (caseTest, 0)