Skip to content

Instantly share code, notes, and snippets.

@laser
Created May 25, 2014 00:27
Show Gist options
  • Save laser/3a37ffbfd73ec21ba399 to your computer and use it in GitHub Desktop.
Save laser/3a37ffbfd73ec21ba399 to your computer and use it in GitHub Desktop.
debugging the div' function using guards
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).
@laser
Copy link
Author

laser commented Aug 25, 2014

@erantapaa I really enjoy that syntax. Thanks for the tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment