File: lpar99_ex5.curry

package info (click to toggle)
curry-tools 1.0.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,492 kB
  • ctags: 121
  • sloc: makefile: 470; sh: 421
file content (28 lines) | stat: -rw-r--r-- 538 bytes parent folder | download
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
-- This example has been taken from:
--   Elvira Albert and Mar{\'{\i}}a Alpuente and Michael Hanus and Germ{\'{a}}n Vidal
--   A Partial Evaluation Framework for {C}urry Programs
--   LPAR'99

-- Example 5 of LPAR'99 paper:

data ABC = A | B | C

-- f eval flex
-- f A B = C
f a b = fcase a of
  A -> fcase b of
    B -> C

-- g eval rigid
-- g B C = B
g b c = case b of
  B -> case c of
    C -> B

-- h eval flex
-- h C = C
h c = fcase c of C -> C

goal x y z = PEVAL (f x (g y (h z)))

main = (goal x y z, x, y, z) where x, y, z free