1{-# OPTIONS -fglasgow-exts #-}
2
3module Paradise (tests) where
4
5{-
6
7This test runs the infamous PARADISE benchmark,
8which is the HELLO WORLD example of generic programming,
9i.e., the "increase salary" function is applied to
10a typical company just as shown in the boilerplate paper.
11
12-}
13
14import Test.HUnit
15
16import Data.Generics
17import CompanyDatatypes
18
19-- Increase salary by percentage
20increase :: Float -> Company -> Company
21increase k = everywhere (mkT (incS k))
22
23-- "interesting" code for increase
24incS :: Float -> Salary -> Salary
25incS k (S s) = S (s * (1+k))
26
27tests = increase 0.1 genCom ~=? output
28
29output = C [D "Research" (E (P "Laemmel" "Amsterdam") (S 8800.0)) [PU (E (P "Joost" "Amsterdam") (S 1100.0)),PU (E (P "Marlow" "Cambridge") (S 2200.0))],D "Strategy" (E (P "Blair" "London") (S 110000.0)) []]
30