File: Tree.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 (19 lines) | stat: -rw-r--r-- 493 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Some examples for the use of CurryCheck with user-defined data

import Test.Prop

-- A general tree type:
data Tree a = Leaf a | Node [Tree a]

leaves (Leaf x) = [x]
leaves (Node ts) = concatMap leaves ts

mirror (Leaf x) = Leaf x
mirror (Node ts) = Node (reverse (map mirror ts))


-- Property: double mirroring is the identity
mirror_mirror t = mirror (mirror t) -=- t

-- Property: the leaves of a mirrored are in reverse order
leaves_mirror t = leaves t -=- reverse (leaves (mirror t))