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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to