Created
May 25, 2014 00:27
-
-
Save laser/3a37ffbfd73ec21ba399 to your computer and use it in GitHub Desktop.
debugging the div' function using guards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Debug.Trace | |
div' :: Integer -> Integer -> Integer | |
div' x y | |
| trace ("x is: " ++ (show x) ++ " and y is: " ++ (show y)) False = undefined | |
| otherwise = x `div` y | |
-- guards are evaluated from top to bottom until a match is found, so we fire off | |
-- our call to trace (which returns False) and move on to the next guard (which is | |
-- our real implementation). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@erantapaa I really enjoy that syntax. Thanks for the tip!