Skip to content

Instantly share code, notes, and snippets.

@esttorhe esttorhe/where.hs
Created Dec 30, 2014

Embed
What would you like to do?
`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

This comment has been minimized.

Copy link
Owner Author

commented Dec 30, 2014

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
You can’t perform that action at this time.