Skip to content

Commit

Permalink
add comment about top-level pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
GoNZooo committed May 31, 2021
1 parent d43e4b5 commit c61489f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions basics/01-values-and-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ data DivisionResult
| DivisionByZero
deriving (Show)

-- Note that we are using something called "top-level pattern matching" here: We have two clauses
-- for our `safeDivide` function; one if the divisor is the number `0` where we will always return
-- `DivisionByZero` and one case for all other divisors where we do the actual calculation.
safeDivide :: Int -> Int -> DivisionResult
safeDivide _x 0 = DivisionByZero
safeDivide x divisor =
Expand Down

0 comments on commit c61489f

Please sign in to comment.