OK, I figured it out. For sake of other novices like me here is what you need
to do to make it work.
0. Need to import Data.Generics 1. Compile with '-fglasgow-exts' flag 2. When deriving from Data you also need to derive from Typeable.
It slightly bothers me that this solution seems to be using non-standard GHC extensions.
Vadim
On Mar 5, 2004, at 12:41, Brandon Michael Moore wrote:
At the lower level of remimplementing your functions I can suggest a few
things.
Brandon,
Thanks for great suggestions! Following them, here is how I redone the code:
...
import Data.Maybe import Data.Either import Data.Typeable
...
data Flag = Verbose | Input String | Output String | Filter String deriving Show Data
instance Eq Flag where x == y = toConstr x == toConstr y
findFlag :: Flag -> [Flag] -> Flag findFlag f fs = fromMaybe f (find (==f) fs)
The only problem is my GHC does not seems to find 'Data' class and I am getting following errors:
Type constructor or class not in scope: `Data' Variable not in scope: `toConstr' Variable not in scope: `toConstr'
Also I have style question: What is the best way to define equality test in this example:
1. Via instantiating EQ class
2. via standalone function (I can define sameConstr Flag -> Flag -> Bool)
3. inline lambda expression passed to find
I am leaning towards #2 or #3.
Vadim
-- "La perfection est atteinte non quand il ne reste rien a ajouter, mais quand il ne reste rien a enlever." (Antoine de Saint-Exupery)
_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
-- "La perfection est atteinte non quand il ne reste rien a ajouter, mais quand il ne reste rien a enlever." (Antoine de Saint-Exupery)
smime.p7s
Description: S/MIME cryptographic signature_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe