Always look for patterns
One of the things that I always try to remember when I'm resolving a problem in Haskell is: Lazyness.
Take this code for example:
module Alarm where
setAlarm :: Bool -> Bool -> Bool
setAlarm True False = True
setAlarm False False = False
setAlarm False True = False
setAlarm True True = False
You can clearly note a pattern where the second argument doesn't matter, so use wildcards in these scenarios:
setAlarm :: Bool -> Bool -> Bool
setAlarm True False = True
setAlarm _ _ = False
Written by maldad
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Haskell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#