Perhaps something can be done shorter
A trick that I often use to avoid creating "filled" objects is simply matching on Just
:
isIdentical:: Variable -> String -> String -> BoolisIdentical (Variable (Just n) (Just u)) n' u' = n == n'&& u == u'isIdentical _ _ _ = False
You can even do the actual check inside the pattern guard:
(Variable (Just n) (Just u)) n' u' | n == n'&& u == u' = True
But that seems like an overkill.
Not saying that this change is particularly warranted in this specific case, but it's a nice tool to have, I think.