Hi,
(Relatively new to Haskell here ..)

So I have the following:

data MyVal =  Atom String
                        | Bool Bool

And I want to do something like this

check :: (Bool -> MyVal) -> MyVal -> True
check f (f x) = True
check _ _ = False

What that means is I want to pass a MyVal constructor and a MyVal, and return True if the second argument was constructed with the first. More generally, I'd like to be able to do

genCheck :: (* -> MyVal) -> MyVal -> True
genCheck f (f x) = True
genCheck _ _ = False

So that I can pass in _any_ MyVal constructor and let the function just check if the second argument was constructed with the first, without caring which constructor it is.

What is the preferred way to do this, since neither of those functions compile?

Cheers,
- Dan
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to