Course map
Haskell // 21

let, where and local definitions

Read

where

A where clause attaches definitions to an equation. They can see the equation's parameters and each other, in any order. It is the idiomatic place for helpers that only one function needs.

bmi :: Double -> Double -> String
bmi weight height
  | value < 18.5 = "under"
  | value < 25   = "normal"
  | otherwise    = "over"
  where
    value = weight / (height * height)

app = component model update view
  where
    model = 0
    update Increment = this += 1
    view n = H.p_ [] [ text (ms n) ]

The second example is how most miso components are written: component with its three parts named just below.

01 / 05