Skip to content

Latest commit

 

History

History
108 lines (77 loc) · 3.06 KB

File metadata and controls

108 lines (77 loc) · 3.06 KB

Language builtins

Builtins are part of the type system — not modules and not prelude bindings.

Primitive types

Type Description
int Machine integer
float Floating point
bool true / false
string UTF-8 string (Go string; indexing via prelude is by byte)
unit Unit type ()
bytes Byte sequence
rune Unicode code point
'a ref Mutable reference cell

Optional import-style constructor: std.ref (make). ! / := are language syntax.

Prelude string ops: string_concat, String.length, String.sub — see prelude. Optional import-style access: std.string.

Lists

Syntax Meaning
'a list Polymorphic list type
[] Empty list
x :: xs Cons
[a; b; c] List literal

Prelude: list_length, list_append, List.filter / map / fold / find. std.list re-exports Filter / Map / Fold.

Arrays

Syntax Meaning
'a array OCaml-style dynamic array (lowers to Go slice)
Array.make n default Allocate and initialize (prelude)
Array.length arr Element count (prelude)
arr.(i) Index read
arr.(i) <- v In-place write

Optional import-style access: std.array.

Maps

Syntax Meaning
map[K] V First-class map (lowers to Go map[K]V)
Map.make () Empty map (prelude)
Map.get / add / remove / mem / size Prelude ops

See prelude and 29-maps.md. Optional re-export: std.map.

Option

Constructor Type
None 'a option
Some x 'a option

Optional predicates: std.option.

Result

Constructor Type
Ok x ('ok, 'err) result
Error e ('ok, 'err) result

Optional predicates: std.result. Propagate with match (no ?).

Channels

Type Created via
'a chan Chan.make (prelude)
'a owned_chan OwnedChan.make (prelude, linear)

Optional import-style access: std.chan.

FFI types

Type / syntax Meaning
'a go_slice Go slice at the FFI boundary
error Go error interface
any / obj Empty interface (obj is gosig spelling)
spread Expand a go_slice in a variadic Go call

See 27-ffi-boundary.md and prelude FFI helpers.

Lazy

Syntax / binding Meaning
'a lazy Deferred computation
lazy e Language syntax
Lazy.force / Lazy.from_val Prelude only (no std.lazy yet)

Type-level features

  • Refinements — where clauses on parameters/returns; optional Z3 SMT
  • Branding — single-constructor ADT (+ optional private); no newtype
  • Linear types — type handle : 1 for quantity-1 resources
  • Effects — effect / perform / handlers (CPS-lowered); no with { io } rows

See type system and syntax.