Skip to content

Instantly share code, notes, and snippets.

@esttorhe
Created December 30, 2014 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esttorhe/19d485ae19956aafabc6 to your computer and use it in GitHub Desktop.
Save esttorhe/19d485ae19956aafabc6 to your computer and use it in GitHub Desktop.
`where` expressions in `Haskell` fails if 2nd one has more than one `tab`
-- This compiles
bmiTell :: Double -> Double -> String
bmiTell weight height
| bmi <= skinny = "You are underweight. Eat more! "
| bmi <= normal = "Looking good!! "
| bmi <= fat = "You are a little fat. Start eating better."
| otherwise = "You are obese. Go see a doctor!."
where bmi = weight / height ^ 2
skinny = 18.5
normal = 25.0
fat = 30.0
-- This fails
bmiTell' :: Double -> Double -> String
bmiTell' weight height
| bmi <= skinny = "You are underweight. Eat more! "
| bmi <= normal = "Looking good!! "
| bmi <= fat = "You are a little fat. Start eating better."
| otherwise = "You are obese. Go see a doctor!."
where bmi = weight / height ^ 2
skinny = 18.5
normal = 25.0
fat = 30.0
@esttorhe
Copy link
Author

Pasting the code as a gist makes the alignment issue pretty evident but on sublime it looks exactly the same:

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