
27 Jul
2007
27 Jul
'07
10:03 a.m.
Hi Why not:
data Flag = Filter String | DateFormat String | DocStart String | DocEnd String
Becomes: data Flag = Flag Key String data Key = Filter | DateFormat | DocStart | DocEnd getString :: Flag -> Key -> String getString (Flag x y) key = if key == x then y else "" You can easily extend this to defaults: defaults = [(DocStart,"1")] then lookup, instead of just "" as the else clause. If you have to use Data/Typeable you will no longer be writing portable Haskell, and while they are great, they aren't the thing to use here. Thanks Neil