ErlangShapes¶
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").
Constructors¶
create¶
Returns¶
- ErlangShapes val^
Public Functions¶
pair¶
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.
Parameters¶
- term: (ErlangTerm | None val)
Returns¶
- ((ErlangTerm | None val) , (ErlangTerm | None val))
triple¶
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¶
- term: (ErlangTerm | None val)
Returns¶
- ((ErlangTerm | None val) , (ErlangTerm | None val) , (ErlangTerm | None val))
eq¶
Parameters¶
- that: ErlangShapes val
Returns¶
- Bool val
ne¶
Parameters¶
- that: ErlangShapes val
Returns¶
- Bool val