Quantcast
Channel: User Bartek Banachewicz - Code Review Stack Exchange
Viewing all articles
Browse latest Browse all 14

Answer by Bartek Banachewicz for Find labels in string in Haskell

$
0
0

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.


Viewing all articles
Browse latest Browse all 14

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>