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))
|