[Haskell-cafe] Eq macro which matches anything

frantisek kocun frantisek.kocun at gmail.com
Fri Dec 4 22:02:37 UTC 2015

Hi guys,

I'm doing Write yourself Scheme tutorial. And for testing it would be cool
to have some kind of macro.

-- My data type with Eq derived
data LispError = NumArgs Integer [LispVal]
               | TypeMismatch String LispVal
               | Parser ParseError
               | BadSpecialForm String LispVal
               | NotFunction String String
               | UnboundVar String String
               | Default String
               deriving (Eq)

-- I can call ==
NumArgs 1 [] == NumArgs 1 []

-- but sometimes I want to do (I know I can implement my own Eq, but I want
to use both forms)
NumArgs 1 [] == NumArgs 1 _

where I omit second parameter. I think derived Eq where it matches all the
args is fine I just need to do macro which will get whateverType by
compiler and always return True in Equality check. Do you think it is
possible to do? I use Mockito library in java but java is OO, so completely
different beast.

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151204/fc7b47d8/attachment.html>

More information about the Haskell-Cafe mailing list