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
31
32
33
34
35
36
37
|
import Test.Feat
import Data.Typeable
data AnyExpr = AnyAddSub AddSub
| AnyMulDiv MulDiv
| AnyVar
deriving Typeable
data MulDiv = MDOp Bool AddSub AnyExpr
| MDOpVar Bool AnyExpr
deriving Typeable
data AddSub = ASOp Bool MulDiv AnyExpr
| ASOpVar Bool AnyExpr
deriving Typeable
deriveEnumerable ''AnyExpr
deriveEnumerable ''AddSub
deriveEnumerable ''MulDiv
allExpressions = values :: [(Integer,[AnyExpr])]
nvars n = allExpressions !! ((n1)*3+1)
instance Show AnyExpr where
showsPrec d (AnyAddSub e) = showsPrec d e
showsPrec d (AnyMulDiv e) = showsPrec d e
showsPrec _ (AnyVar) = ("X"++)
instance Show AddSub where
showsPrec d (ASOpVar b e) = showParen (d > 6) $ ("X"++) . ((if b then "+" else "-")++) . showsPrec 6 e
showsPrec d (ASOp b e1 e2) = showParen (d > 6) $ showsPrec 6 e1 . ((if b then "+" else "-")++) . showsPrec 6 e2
instance Show MulDiv where
showsPrec d (MDOpVar b e) = showParen (d > 7) $ ("X"++) . ((if b then "*" else "/")++) . showsPrec 7 e
showsPrec d (MDOp b e1 e2) = showParen (d > 7) $ showsPrec 7 e1 . ((if b then "*" else "/")++) . showsPrec 7 e2 |