I'm not sure how to phrase this exactly so if someone has a good name for it please let me know.
I'm trying to write a typeclass called Matchable
. The idea is a couple different types of regular expressions that I have (RegExp a
, ComplexRegex a
) should be able to match on input.
So I tried this:
class Matchable a where
-- regex, input, success
match :: a -> b -> Bool
But what I really want is to deconstruct the constructor in the typeclass with a type constructor variable or something:
class Matchable a where
-- regex, input, success
match :: (B a) -> [a] -> Bool
That way I can have a RegExp Char
and a ComplexRegex Char
both match on a String
. Is there any way to do this? Thanks.
match
you'd like to abstract? e.g.matchRegExp :: RegExp Char -> [Char] -> Bool
,matchComplexReg :: ComplexRegex ...
etc. – jberryman