The Big Table

After walking through the individual type chapters, it’s useful to have one compact place where the main constructions and destructions sit side by side.

This chapter is a cheat sheet, not a replacement for the explanations in the earlier chapters. The first table summarizes the expression syntax you’ve already seen.

The second table does the same from the point of view of process syntax. If you haven’t read the next section on process syntax yet, feel free to skip that table for now and come back to it later.

Expression syntax

Type Construction Destruction
type Unit = !
let value = !
let ! = value
type Either = either {
  .left String,
  .right Int,
}
let value: Either = .left "Hello!"
let result = value.case {
  .left str => String.Length(str),
  .right num => Int.Mul(num, 5),
}
type Pair = (String) Int
let value = ("Hello!") 42
let (str) num = value
type Function = [Int] String
let value = [num: Int] Int.ToString(num)
let str = value(42)
type Choice = choice {
  .left => String,
  .right => Int,
}
let value: Choice = case {
  .left => "Hello!",
  .right => 42,
}
let num = value.right
type Continuation = ?
No expression syntax No expression syntax

Process syntax

Type Construction Destruction
type Unit = !
let value = chan c {
  c!
}
value?
type Either = either {
  .left String,
  .right Int,
}
let value: Either = chan c {
  c.left
  c <> "Hello!"
}
value.case {
  .left => {
    let result = String.Length(value)
  }
  .right => {
    let result = Int.Mul(value, 5)
  }
}
// `result` is in scope here
type Pair = (String) Int
let value = chan c {
  c("Hello!")
  c <> 42
}
value[str]
let num = value
type Function = [Int] String
let value = chan c {
  c[num: Int]
  c <> Int.ToString(num)
}
value(42)
let result = value
type Choice = choice {
  .left => String,
  .right => Int,
}
let value = chan c {
  c.case {
    .left  => { c <> "Hello!" }
    .right => { c <> 42 }
  }
}
value.right
let num = value
type Continuation = ?
let outer: ! = chan break {
  let value: ? = chan c {
    c?     // construction
    break!
  }
  value!   // destruction
}
Shown on the left