Expressions

case .. of

The case expression in Hamler is the same as Haskell.

Hamler:

  1. data RGB = Red | Green | Blue
  2. color = Green
  3. case color of
  4. Red -> "Red"
  5. Green -> "Green"
  6. Blue -> "Blue"

case expression in Erlang ends with an end keyword.

Erlang:

  1. Color = green.
  2. case Color of
  3. red -> "Red";
  4. green -> "Green";
  5. blue -> "Blue"
  6. end.

if .. then .. else

Hamler:

  1. -- Every `then` must have a corresponding `else`
  2. max x y = if x > y then x else y

Erlang:

  1. max(X, Y) -> if X > Y -> X; true -> Y end.

let and where bindings

There are no let and where bindings in Erlang

Hamler:

  1. let n = 1 + 2
  2. z = let x = 3
  3. y = 2 * x
  4. in x * y
  5. -- or
  6. z = x * y
  7. where
  8. x = 3
  9. y = 5