Intrinsics

Wipple uses intrinsics to give the compiler special knowledge of certain types, traits and constants. For example, whenever the + operator is used, Wipple calls the function defined by the add intrinsic — in the standard library, this is the Add trait.

To define an intrinsic, use the intrinsic keyword, followed by the type of value (type, trait, or constant) and its name:

intrinsic "trait" "add" : Add

The compiler assumes that the associated type, trait, or constant has the correct shape and behavior; if it doesn’t, the compiler may produce invalid code, strange type errors, or crash.

Here’s a list of the intrinsics used in Wipple:

NameTypeValueUsed By
addtraitAddThe + operator
andtraitAndThe and operator
astraitAsThe as operator
booleantypeBooleanThe runtime
build-collectionconstantBuild-CollectionThe , operator
bytraitByThe by operator
dividetraitDivideThe / operator
equaltraitEqualThe = operator
errortraitErrorCustom error messages
falseconstantFalseThe runtime
greater-than-or-equaltraitGreater-Than-Or-EqualThe >= operator
greater-thantraitGreater-ThanThe > operator
hashertypeHasherThe runtime
initial-collectionconstantinitial-collectionThe , operator
is-equal-toconstantIs-Equal-ToThe runtime
is-greater-thanconstantIs-Greater-ThanThe runtime
is-less-thanconstantIs-Less-ThanThe runtime
less-than-or-equaltraitLess-Than-Or-EqualThe <= operator
less-thantraitLess-ThanThe < operator
listtypeListThe runtime
maybetypeMaybeThe runtime
multiplytraitMultiplyThe * operator
noneconstantNoneThe runtime
not-equaltraitNot-EqualThe /= operator
numbertypeNumberType of number literals
ortraitOrThe or operator
orderingtypeOrderingThe runtime
powertraitPowerThe ^ operator
remaindertraitRemainderThe % operator
showconstantDescribe_ in text literals
someconstantSomeThe runtime
subtracttraitSubtractThe - operator
task-grouptypeTask-GroupThe runtime
texttypeTextType of text literals
totraitToThe to operator
trueconstantTrueThe runtime

The runtime also exposes many functions that are called with intrinsic; see the runtime source code.