Skip to content

ErlangShapes

[Source]

Reads the leading elements of a tuple so that one match binds all of them with their types.

Pony matches on types and not on values, so a message shape is checked by naming the types its elements must have. A term that is not that shape comes back as Nones and falls to the else clause:

match ErlangShapes.pair(term)
| (let kind: ErlangAtom, let body: ErlangBinary) => handle(kind, body)
else not_this_message()
end

The tag of a tagged tuple is a value, so it is read and compared after the shape is known: ErlangTerms.is_atom(kind_term, "reply").

primitive val ErlangShapes

Constructors

create

[Source]

new val create()
: ErlangShapes val^

Returns


Public Functions

pair

[Source]

Both elements of a two element tuple, and two Nones for anything else, including no term at all, so a decoded message goes straight in.

fun box pair(
  term: (ErlangTerm | None val))
: ((ErlangTerm | None val) , (ErlangTerm | None val))

Parameters

Returns


triple

[Source]

All three elements of a three element tuple, and three Nones for anything else, including no term at all.

fun box triple(
  term: (ErlangTerm | None val))
: ((ErlangTerm | None val) , (ErlangTerm | None val) , (ErlangTerm | None val))

Parameters

Returns


eq

[Source]

fun box eq(
  that: ErlangShapes val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: ErlangShapes val)
: Bool val

Parameters

Returns