Skip to main content

Builtin

Enum Builtin 

Source
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

Source

pub const ALL: &'static [Builtin]

Every nameable builtin in declaration order; the source of truth for tooling enumerating the __ namespace. Keep in sync with the enum.

ObjNew and ObjValue are omitted as no name resolves to them; they only render via name.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn name(self) -> &'static str

The reserved __-name for this builtin. Module members are dotted (e.g. __Int.add).

Trait Implementations§

Source§

impl Clone for Builtin

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Builtin

Source§

impl Debug for Builtin

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Builtin

Source§

impl Hash for Builtin

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Builtin

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Builtin

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Builtin

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Builtin

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.