pub enum Builtin {
Show 78 variants
Bool,
BoolAnd,
BoolFalse,
BoolNot,
BoolOr,
BoolTrue,
Eq,
Err,
ErrCatch,
ErrRaise,
Fun,
Int,
IntAdd,
IntCount,
IntDivrem,
IntEq,
IntGe,
IntGt,
IntLe,
IntLt,
IntMul,
IntParse,
IntPow,
IntRange,
IntStr,
IntSub,
IntUpto,
Iter,
IterBreak,
IterContinue,
IterEach,
IterEmpty,
IterEq,
IterFold,
IterFor,
IterGet,
IterIndex,
IterNext,
IterOf,
IterReturn,
IterRun,
IterYield,
IterZip,
List,
ListAppend,
ListFrom,
ListGet,
ListIter,
ListSize,
ListSplit,
ListWith,
Map,
MapCat,
MapFrom,
MapGet,
MapGets,
MapIter,
MapMerge,
MapNil,
MapSize,
MapWith,
MapWithout,
MapZip,
Match,
Mod,
ModExports,
ModName,
ObjNew,
ObjValue,
Proto,
Repr,
Str,
StrFrom,
StrIter,
Sym,
SymFrom,
SymStr,
Unit,
}Expand description
A native builtin operation in the reserved __ namespace. All are curried.
Variants§
Bool
The builtin module Bool: the iotas Bool.false / Bool.true and their logic.
BoolAnd
Bool.and : (Bool, Bool) -> Bool
BoolFalse
Bool.false : Bool, also the bare __false.
BoolNot
Bool.not : Bool -> Bool
BoolOr
Bool.or : (Bool, Bool) -> Bool
BoolTrue
Bool.true : Bool, also the bare __true.
Eq
__eq : (a, b, () -> c, () -> c) -> c: the first thunk if a == b, else the second.
Structural for data, by identity for callables and iterators.
Err
The builtin module Err: raising and catching.
ErrCatch
Err.catch : (e -> a, () -> a) -> a: runs the thunk; a raised e goes to the handler.
Step signals pass through.
ErrRaise
Err.raise : e -> a
Fun
The builtin module Fun, the prototype of every callable kind. No items yet.
Int
The builtin module Int, the prototype of integers.
IntAdd
Int.add : (Int, Int) -> Int
IntCount
Int.count : iterable -> Int: drains it, counting the elements.
IntDivrem
Int.divrem : (Int, Int) -> #[Int, Int]: Euclidean #[quotient, remainder].
Raises .div_by_zero.
IntEq
Int.eq : (Int, Int) -> Bool
IntGe
Int.ge : (Int, Int) -> Bool
IntGt
Int.gt : (Int, Int) -> Bool
IntLe
Int.le : (Int, Int) -> Bool
IntLt
Int.lt : (Int, Int) -> Bool
IntMul
Int.mul : (Int, Int) -> Int
IntParse
Int.parse : Str -> Int: decimal, 0x or 0b, with _ separators.
Raises .cannot_parse_int.
IntPow
Int.pow : (Int, Int) -> Int: raises .negative_exponent.
IntRange
Int.range : (Int, Int) -> Iter Int: m … n - 1.
IntStr
Int.str : Int -> Str: signed decimal.
IntSub
Int.sub : (Int, Int) -> Int
IntUpto
Int.upto : Int -> Iter Int: Int.range(0, n).
Iter
The builtin module Iter, the prototype of iterators: the cursor
methods, the loops, the drains and the step signals.
IterBreak
it.__break : Iter a -> b: ends it’s loop.
IterContinue
it.__continue : Iter a -> b: ends the step, producing nothing.
IterEach
Iter.each : (a -> b, iterable a) -> Iter b: lazy.
IterEmpty
Iter.empty : iterable -> Bool
IterEq
Iter.eq : (iterable, iterable) -> Bool: same length and __eq elements.
IterFold
Iter.fold : (s, (Iter a, s) -> s, iterable a) -> s: eager.
IterFor
Iter.for : (Iter a -> b, iterable a) -> Iter b: the step gets a cursor; lazy.
IterGet
Iter.get : Iter a -> a: raises .iter_end.
IterIndex
Iter.index : iterable a -> Iter #[Int, a]
IterNext
Iter.next : Iter a -> Iter a: raises .iter_end.
IterOf
__iter : iterable a -> Iter a: a list, string, map, integer, Bool or iterator.
IterReturn
it.__return : (Iter a, b) -> c: ends the step with b.
IterRun
Iter.run : iterable -> (): drains it for its effects.
IterYield
it.__yield : (Iter a, iterable b) -> c: ends the step, producing each
element of the iterable.
Raises .yield_in_fold in a fold.
IterZip
Iter.zip : (iterable a, iterable b) -> Iter #[a, b]: ends with the shorter.
List
The builtin module List, the prototype of lists.
ListAppend
List.append : (List a, List a) -> List a
ListFrom
List.from : iterable a -> List a
ListGet
List.get : (List a, Int) -> a: raises .projection_out_of_range.
ListIter
List.iter : List a -> Iter a
ListSize
List.size : List a -> Int
ListSplit
List.split : (Int, List a) -> #[List a, List a]: the first n, and the rest.
ListWith
List.with : (List a, Int, a) -> List a: replaces one element.
Map
The builtin module Map, the prototype of maps.
MapCat
Map.cat : (Map, Map) -> Map: the second wins on a shared key.
MapFrom
Map.from : iterable #[k, v] -> Map: raises .not_a_pair.
MapGet
Map.get : (Map, k) -> v: raises .missing_key.
MapGets
Map.gets : (Map, List k) -> List v: raises .missing_key.
MapIter
Map.iter : Map -> Iter #[k, v]: in unspecified order.
MapMerge
Map.merge : (Map, Map, (k, #[] | #[v], #[] | #[v]) -> #[] | #[v]) -> Map
Over the union of keys; #[] is absent.
MapNil
Map.nil : Map: the empty map.
MapSize
Map.size : Map -> Int
MapWith
Map.with : (Map, k, v) -> Map
MapWithout
Map.without : (Map, k) -> Map
MapZip
Map.zip : (iterable k, iterable v) -> Map: Map.from(Iter.zip(ks, vs)).
Match
__match : (List (a -> b), a) -> b: the first clause that does not refute.
Mod
The builtin module Mod: reflection on modules.
ModExports
Mod.exports : Mod -> List Sym: exported item names, sorted.
Raises .not_a_module.
ModName
Mod.name : Mod -> Str
ObjNew
Desugaring of #Self <value>, not a user-visible builtin.
ObjValue
Desugaring of <expr>.Self or Self <pat>, not a user-visible builtin.
Raises .foreign_object on an object of another prototype, so a
module unwraps only its own objects.
Proto
__proto : a -> Mod: the prototype of any value.
Repr
__repr : a -> Str: the display string of any value.
Matches to_display.
Str
The builtin module Str, the prototype of strings.
StrFrom
Str.from : iterable Int -> Str: from codepoints.
Raises .not_an_int or .bad_codepoint.
StrIter
Str.iter : Str -> Iter Int, also Str.chars: the codepoints.
Sym
The builtin module Sym, the prototype of symbols.
SymFrom
Sym.from : Str -> Sym: raises .bad_symbol unless one Muon <sym> segment.
SymStr
Sym.str : Sym -> Str: the name without the dot.
Unit
The builtin module __Unit, the prototype of (). No items.
Implementations§
Source§impl Builtin
impl Builtin
Sourcepub fn from_name(name: &str) -> Option<Builtin>
pub fn from_name(name: &str) -> Option<Builtin>
Resolves a __-name to its builtin: a bare name (__eq), a builtin
module (__Int), or a module member in dotted form (__Int.add).
Since Muon symbols cannot contain dots, the parser reaches members via
member after folding. This method is used by tooling and
the Builtin::ALL round-trip.
Sourcepub fn from_alias(name: Sym) -> Option<Builtin>
pub fn from_alias(name: Sym) -> Option<Builtin>
The builtin module this bare alias names (e.g. Int → __Int).
Aliases are the resolver’s bottom tier (the prelude), consulted last to
ensure they are shadowed by lexical bindings.
Sourcepub fn member(self, name: Sym) -> Option<Builtin>
pub fn member(self, name: Sym) -> Option<Builtin>
The item of this builtin module matching name, if any. Returns None
if the name is not held or the builtin is not a module. Safe to call on
any callee of a call spine.
Sourcepub fn proto_kind(self) -> Option<TyKind>
pub fn proto_kind(self) -> Option<TyKind>
The value kind this builtin module is the prototype of, enabling as <Proto>
patterns to compile to discriminant tests. Returns None if not a module
or for __Err (no value has __Err as its prototype).