type

A type declaration inside a lib declares a kind of C typedef, but stronger:

  1. lib X
  2. type MyInt = Int32
  3. end

Unlike C, Int32 and MyInt are not interchangeable:

  1. lib X
  2. type MyInt = Int32
  3. fun some_fun(value : MyInt)
  4. end
  5. X.some_fun 1 # Error: argument 'value' of 'X#some_fun' must be X::MyInt, not Int32

Thus, a type declaration is useful for opaque types that are created by the C library you are wrapping. An example of this is the C FILE type, which you can obtain with fopen.

Refer to the type grammar for the notation used in typedef types.