Find labels in string in Haskell
Perhaps something can be done shorter


A trick that I often use to avoid creating "filled" objects is simply matching on Just:

isIdentical:: Variable -&gt; String -&gt; String -&gt; Bool
isIdentical (Variable (Just n) (Just u)) n' u' = n == n' &amp;&amp; u == u'
isIdentical _ _ _ = False


You can even do the actual check inside the pattern guard:

(Variable (Just n) (Just u)) n' u' | n == n' &amp;&amp; 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.