Package COALTON
Public interface to COALTON.
Types
Arrow [TYPE]
A named constructor for function types. Arrow :a :b is equivalent to :a -> :b.
Bit [TYPE] · src
A single bit, equal to 0 or 1. Uses cl:bit.
Instances
Bits BitBounded BitDefault BitEq BitHash BitIntegral BitInto Bit F32Into Bit F64Into Bit FractionInto Bit I16Into Bit I32Into Bit I64Into Bit I8Into Bit IFixInto Bit IntegerInto Bit U16Into Bit U32Into Bit U64Into Bit U8Into Bit UFixNum BitOrd BitQuantizable BitRational BitReal BitRemainder BitRuntimeRepr BitShow BitTryInto I16 BitTryInto I32 BitTryInto I64 BitTryInto I8 BitTryInto IFix BitTryInto Integer BitTryInto U16 BitTryInto U32 BitTryInto U64 BitTryInto U8 BitTryInto UFix Bit
Boolean [TYPE]
False- Boolean
False
- Boolean
True- Boolean
True
- Boolean
Either true or false, internally represented by cl:t and cl:nil respectively.
Instances
Char [TYPE]
A character represented by a Common Lisp cl:character.
Instances
Double-Float [TYPE] · src
Deprecated name for F64. This is provided for backward compatibility.
F32 [TYPE]
Single-precision floating point number (32 bits in size). Represented by a Common Lisp cl:single-float.
Instances
ComplexComponent F32Default F32Dividable Integer F32Elementary F32Eq F32Exponentiable F32Hash F32Into Bit F32Into F32 Big-FloatInto F32 CRealInto F32 F64Into F32 StringInto I16 F32Into I8 F32Into U16 F32Into U8 F32Num F32Ord F32Polar F32Quantizable F32Radical F32Rational F32Real F32Reciprocable F32Remainder F32RuntimeRepr F32Show F32Transfinite F32Trigonometric F32TryInto F32 FractionTryInto I32 F32TryInto I64 F32TryInto IFix F32TryInto Integer F32TryInto U32 F32TryInto U64 F32TryInto UFix F32
F64 [TYPE]
Double-precision floating point number (64 bits in size). Represented by a Common Lisp cl:double-float.
Instances
ComplexComponent F64Default F64Dividable Integer F64Elementary F64Eq F64Exponentiable F64Hash F64Into Bit F64Into F32 F64Into F64 Big-FloatInto F64 CRealInto F64 StringInto I16 F64Into I32 F64Into I8 F64Into U16 F64Into U32 F64Into U8 F64Num F64Ord F64Polar F64Quantizable F64Radical F64Rational F64Real F64Reciprocable F64Remainder F64RuntimeRepr F64Show F64Transfinite F64Trigonometric F64TryInto F64 FractionTryInto I64 F64TryInto IFix F64TryInto Integer F64TryInto U64 F64TryInto UFix F64
Fraction [TYPE]
A ratio of integers always in reduced form. Represented by a Common Lisp cl:rational.
Instances
ComplexComponent FractionDividable Integer FractionEq FractionInto Bit FractionInto Dyadic FractionInto Fraction Big-FloatInto Fraction CRealInto Fraction RealAlgebraicInto Fraction StringInto I16 FractionInto I32 FractionInto I64 FractionInto I8 FractionInto IFix FractionInto Integer FractionInto U16 FractionInto U32 FractionInto U64 FractionInto U8 FractionInto UFix FractionNum FractionOrd FractionQuantizable FractionRational FractionReal FractionReciprocable FractionRemainder FractionRuntimeRepr FractionShow FractionTryInto F32 FractionTryInto F64 FractionTryInto RealAlgebraic Fraction
I16 [TYPE] · src
Signed 16-bit integer capable of storing values in [-32768, 32767]. Uses (signed-byte 16).
Instances
%FileByte I16Bits I16Bounded I16Default I16Eq I16File I16Hash I16Integral I16Into Bit I16Into I16 CRealInto I16 F32Into I16 F64Into I16 FractionInto I16 I32Into I16 I64Into I16 IFixInto I16 IntegerInto I16 StringInto I8 I16Into U8 I16Num I16Ord I16Remainder I16RuntimeRepr I16Show I16TryInto I16 BitTryInto I16 I8TryInto I16 U16TryInto I16 U32TryInto I16 U64TryInto I16 U8TryInto I16 UFixTryInto I32 I16TryInto I64 I16TryInto IFix I16TryInto Integer I16TryInto U16 I16TryInto U32 I16TryInto U64 I16TryInto UFix I16
I32 [TYPE] · src
Signed 32-bit integer capable of storing values in [-2147483648, 2147483647]. Uses (signed-byte 32).
Instances
%FileByte I32Bits I32Bounded I32Default I32Eq I32File I32Hash I32Integral I32Into Bit I32Into I16 I32Into I32 CRealInto I32 F64Into I32 FractionInto I32 I64Into I32 IFixInto I32 IntegerInto I32 StringInto I8 I32Into U16 I32Into U8 I32Num I32Ord I32Quantizable I32Rational I32Real I32Remainder I32RuntimeRepr I32Show I32TryInto I32 BitTryInto I32 F32TryInto I32 I16TryInto I32 I8TryInto I32 U16TryInto I32 U32TryInto I32 U64TryInto I32 U8TryInto I32 UFixTryInto I64 I32TryInto IFix I32TryInto Integer I32TryInto U32 I32TryInto U64 I32TryInto UFix I32
I64 [TYPE] · src
Signed 64-bit integer capable of storing values in [-9223372036854775808, 9223372036854775807]. Uses (signed-byte 64).
Instances
%FileByte I64Bits I64Bounded I64Default I64Eq I64File I64Hash I64Integral I64Into Bit I64Into I16 I64Into I32 I64Into I64 CRealInto I64 FractionInto I64 IntegerInto I64 StringInto I8 I64Into IFix I64Into U16 I64Into U32 I64Into U8 I64Into UFix I64Num I64Ord I64Quantizable I64Rational I64Real I64Remainder I64RuntimeRepr I64Show I64TryInto I64 BitTryInto I64 F32TryInto I64 F64TryInto I64 I16TryInto I64 I32TryInto I64 I8TryInto I64 IFixTryInto I64 U16TryInto I64 U32TryInto I64 U64TryInto I64 U8TryInto I64 UFixTryInto Integer I64TryInto U64 I64
I8 [TYPE] · src
Signed 8-bit integer capable of storing values in [-128, 127]. Uses (signed-byte 8).
Instances
%FileByte I8Bits I8Bounded I8Default I8Eq I8File I8Hash I8Integral I8Into Bit I8Into I8 CRealInto I8 F32Into I8 F64Into I8 FractionInto I8 I16Into I8 I32Into I8 I64Into I8 IFixInto I8 IntegerInto I8 StringNum I8Ord I8Quantizable I8Rational I8Real I8Remainder I8RuntimeRepr I8Show I8TryInto I16 I8TryInto I32 I8TryInto I64 I8TryInto I8 BitTryInto I8 U16TryInto I8 U32TryInto I8 U64TryInto I8 U8TryInto I8 UFixTryInto IFix I8TryInto Integer I8TryInto U16 I8TryInto U32 I8TryInto U64 I8TryInto U8 I8TryInto UFix I8
IFix [TYPE] · src
Non-allocating tagged integer; range is platform-dependent. Does not error on overflow. Uses fixnum.
Instances
%FileByte IFixBits IFixBounded IFixDefault IFixEq IFixFile IFixHash IFixIntegral IFixInto Bit IFixInto I16 IFixInto I32 IFixInto I8 IFixInto IFix CRealInto IFix FractionInto IFix I64Into IFix IntegerInto IFix StringInto U16 IFixInto U32 IFixInto U8 IFixInto UFix IFixNum IFixOrd IFixQuantizable IFixRational IFixReal IFixRemainder IFixRuntimeRepr IFixShow IFixTryInto I64 IFixTryInto IFix BitTryInto IFix F32TryInto IFix F64TryInto IFix I16TryInto IFix I32TryInto IFix I8TryInto IFix U16TryInto IFix U32TryInto IFix U64TryInto IFix U8TryInto IFix UFixTryInto Integer IFixTryInto U64 IFix
Integer [TYPE]
Integer of unbounded size. Represented by a Common Lisp cl:integer.
Instances
Bits IntegerComplexComponent IntegerDefault IntegerDividable Integer Big-FloatDividable Integer CRealDividable Integer F32Dividable Integer F64Dividable Integer FractionDividable Integer RealAlgebraicEq IntegerHash IntegerIntegral IntegerInto Bit IntegerInto I16 IntegerInto I32 IntegerInto I64 IntegerInto I8 IntegerInto IFix IntegerInto Integer Big-FloatInto Integer CRealInto Integer DyadicInto Integer FractionInto Integer RealAlgebraicInto Integer StringInto U16 IntegerInto U32 IntegerInto U64 IntegerInto U8 IntegerInto UFix IntegerNum IntegerOrd IntegerQuantizable IntegerRational IntegerReal IntegerRemainder IntegerRuntimeRepr IntegerShow IntegerTryInto Integer BitTryInto Integer F32TryInto Integer F64TryInto Integer I16TryInto Integer I32TryInto Integer I64TryInto Integer I8TryInto Integer IFixTryInto Integer U16TryInto Integer U32TryInto Integer U64TryInto Integer U8TryInto Integer UFixTryInto String Integer
List [TYPE]
NilNilrepresents an emptyList.
(Cons :A List :A)Consrepresents aListcontaining a first element (car) and a nestedCons(cdr).
Homogeneous list of objects. Represented as a typical Common Lisp chain of cl:cons (or cl:nil).
Instances
Alternative ListApplicative ListDefault (List :A)Eq :A ⇒ Eq (List :A)Foldable ListFromAssociationComprehension (List (Tuple :KEY :VALUE)) :KEY :VALUE (List (Tuple :KEY :VALUE))FromCollectionComprehension (List :ELT) :ELT (List :ELT)FromItemizedAssociation (List (Tuple :KEY :VALUE)) :KEY :VALUE (List (Tuple :KEY :VALUE))FromItemizedCollection (List :ELT) :ELT (List :ELT)FromIterator (List :ELT) :ELTFunctor ListHash :A ⇒ Hash (List :A)Into (LispArray :T) (List :T)Into (List :A) (Vector :A)Into (List Char) StringInto (Optional :A) (List :A)Into (Seq :A) (List :A)Into (Vector :A) (List :A)Into String (List Char)IntoIterator (List :ELT) :ELTIso (List Char) StringIso (Vector :A) (List :A)Monad ListMonoid (List :A)Ord :ELT ⇒ Ord (List :ELT)RuntimeRepr (List :A)RuntimeRepr :T ⇒ Into (List :T) (LispArray :T)RuntimeRepr :T ⇒ Iso (LispArray :T) (List :T)Semigroup (List :A)Show :A ⇒ Show (List :A)Terminator (List :A)Traversable ListYielder List
Optional [TYPE]
(Some :A)Someexpresses the presence of a meaningful value.
NoneNoneexpresses the absence of a meaningful value.
A type that allows indicating the presence or absence of a value. The underlying representation does not allocate when a value is present (i.e., with Some).
Instances
Alternative OptionalApplicative OptionalDefault (Optional :A)Eq :A ⇒ Eq (Optional :A)FromIterator :CONTAINER :ELT ⇒ FromIterator (Optional :CONTAINER) (Optional :ELT)Functor OptionalInto (Optional :A) (List :A)Into (Optional :B) (Result Unit :B)Into (Result :A :B) (Optional :B)IntoIterator (Optional :A) :AIso (Result Unit :A) (Optional :A)Monad OptionalMonadFail OptionalMonoid :A ⇒ Monoid (Optional :A)Ord :A ⇒ Ord (Optional :A)RuntimeRepr (Optional :A)Semigroup :A ⇒ Semigroup (Optional :A)Show :A ⇒ Show (Optional :A)Terminator (Optional :A)Traversable OptionalUnwrappable OptionalYielder Optional
Single-Float [TYPE] · src
Deprecated name for F32. This is provided for backward compatibility.
String [TYPE]
String of characters. Represented by Common Lisp cl:string.
Instances
Default StringEq StringFromIterator String CharHash StringInto (List Char) StringInto (Vector Char) StringInto :A String ⇒ Into (Cell :A) StringInto Char StringInto F32 StringInto F64 StringInto Fraction StringInto I16 StringInto I32 StringInto I64 StringInto I8 StringInto IFix StringInto Integer StringInto Pathname StringInto String (List Char)Into String (Vector Char)Into String PathnameInto U16 StringInto U32 StringInto U64 StringInto U8 StringInto UFix StringIntoIterator String CharIso (List Char) StringMonoid StringOrd StringRuntimeRepr StringSemigroup StringShow StringSignalable StringTryInto String Integer
U16 [TYPE] · src
Unsigned 16-bit integer capable of storing values in [0, 65535]. Uses (unsigned-byte 16).
Instances
%FileByte U16Bits U16Bounded U16Default U16Eq U16File U16Hash U16Integral U16Into Bit U16Into U16 CRealInto U16 F32Into U16 F64Into U16 FractionInto U16 I32Into U16 I64Into U16 IFixInto U16 IntegerInto U16 StringInto U16 U32Into U16 U64Into U16 UFixInto U8 U16Num U16Ord U16Remainder U16ReverseBits U16RuntimeRepr U16Show U16TryInto I16 U16TryInto I32 U16TryInto I64 U16TryInto I8 U16TryInto IFix U16TryInto Integer U16TryInto U16 BitTryInto U16 I16TryInto U16 I8TryInto U16 U8TryInto U32 U16TryInto U64 U16TryInto UFix U16
U32 [TYPE] · src
Unsigned 32-bit integer capable of storing values in [0, 4294967295]. Uses (unsigned-byte 32).
Instances
%FileByte U32Bits U32Bounded U32Default U32Eq U32File U32Hash U32Integral U32Into Bit U32Into U16 U32Into U32 CRealInto U32 F64Into U32 FractionInto U32 I64Into U32 IFixInto U32 IntegerInto U32 StringInto U32 U64Into U32 UFixInto U8 U32Num U32Ord U32Quantizable U32Rational U32Real U32Remainder U32ReverseBits U32RuntimeRepr U32Show U32TryInto I16 U32TryInto I32 U32TryInto I64 U32TryInto I8 U32TryInto IFix U32TryInto Integer U32TryInto U32 BitTryInto U32 F32TryInto U32 I16TryInto U32 I32TryInto U32 I8TryInto U32 U16TryInto U32 U8TryInto U64 U32TryInto UFix U32
U64 [TYPE] · src
Unsigned 64-bit integer capable of storing values in [0, 18446744073709551615]. Uses (unsigned-byte 64).
Instances
%FileByte U64Bits U64Bounded U64Default U64Eq U64File U64Hash U64Integral U64Into Bit U64Into U16 U64Into U32 U64Into U64 CRealInto U64 FractionInto U64 IntegerInto U64 StringInto U8 U64Into UFix U64Num U64Ord U64Quantizable U64Rational U64Real U64Remainder U64ReverseBits U64RuntimeRepr U64Show U64TryInto I16 U64TryInto I32 U64TryInto I64 U64TryInto I8 U64TryInto IFix U64TryInto Integer U64TryInto U64 BitTryInto U64 F32TryInto U64 F64TryInto U64 I16TryInto U64 I32TryInto U64 I64TryInto U64 I8TryInto U64 IFixTryInto U64 U16TryInto U64 U32TryInto U64 U8TryInto U64 UFix
U8 [TYPE] · src
Unsigned 8-bit integer capable of storing values in [0, 255]. Uses (unsigned-byte 8).
Instances
%FileByte U8Bits U8Bounded U8Default U8Eq U8File U8Hash U8Integral U8Into Bit U8Into U8 CRealInto U8 F32Into U8 F64Into U8 FractionInto U8 I16Into U8 I32Into U8 I64Into U8 IFixInto U8 IntegerInto U8 StringInto U8 U16Into U8 U32Into U8 U64Into U8 UFixNum U8Ord U8Quantizable U8Rational U8Real U8Remainder U8ReverseBits U8RuntimeRepr U8Show U8TryInto I16 U8TryInto I32 U8TryInto I64 U8TryInto I8 U8TryInto IFix U8TryInto Integer U8TryInto U16 U8TryInto U32 U8TryInto U64 U8TryInto U8 BitTryInto U8 I8TryInto UFix U8
UFix [TYPE] · src
Non-allocating tagged non-negative integer; range is platform-dependent. Uses (and fixnum unsigned-byte).
Instances
%FileByte UFixBits UFixBounded UFixDefault UFixEq UFixFile UFixHash UFixIntegral UFixInto Bit UFixInto U16 UFixInto U32 UFixInto U8 UFixInto UFix CRealInto UFix FractionInto UFix I64Into UFix IFixInto UFix IntegerInto UFix StringInto UFix U64Num UFixOrd UFixQuantizable UFixRational UFixReal UFixRemainder UFixReverseBits UFixRuntimeRepr UFixShow UFixTryInto I16 UFixTryInto I32 UFixTryInto I64 UFixTryInto I8 UFixTryInto IFix UFixTryInto Integer UFixTryInto U64 UFixTryInto UFix BitTryInto UFix F32TryInto UFix F64TryInto UFix I16TryInto UFix I32TryInto UFix I8TryInto UFix U16TryInto UFix U32TryInto UFix U8
Unit [TYPE]
UnitUnitis the explicit one-value unit type, distinct from zero-value returns().
The “unit” type whose only member is the value Unit.
Values
(CONS X XS) [FUNCTION] · src
(INLINE APPLICATION) [FUNCTION] · src
∀ :A. :A → :A
Try to inline application. It will only attempt to inline
application written syntactically as a function application.
(LIKELY PREDICATE) [FUNCTION] · src
Hint to the compiler that predicate is likely True.
(NOINLINE APPLICATION) [FUNCTION] · src
∀ :A. :A → :A
Prevent application from being inlined. It will prevent
inlining when the argument is syntactically a function application.
(SOME X) [FUNCTION] · src
∀ :A. :A → Optional :A
A constructor for the type, Optional. This constructor can be used
like any other algebraic data type constructor, including for pattern
matching, as in the following example.
(match x
((Some value)
value)
(_ (error "Oh, no!")))
(UNLIKELY PREDICATE) [FUNCTION] · src
Hint to the compiler that predicate is likely False.
False [VALUE] · src
Nil [VALUE] · src
∀ :A. List :A
None [VALUE] · src
∀ :A. Optional :A
A constructor for the type, Optional. This constructor can be used
like any other algebraic data type constructor, including for pattern
matching, as in the following example.
(match x
((None)
"Fantastic!")
(_ (error "Oh, no!")))
True [VALUE] · src
Unit [VALUE] · src
Macros
.< (&REST ITEMS) [MACRO]
Right associative compose operator. Creates a new functions that will run the
functions right to left when applied. This is the same as the nest macro without supplying
the value. The composition is thus the same order as compose.
(.< f g h) creates the function (fn (x) (f (g (h x)))).
.> (&REST ITEMS) [MACRO]
Left associative compose operator. Creates a new functions that will run the
functions left to right when applied. This is the same as the pipe macro without supplying
the value. The composition is thus the reverse order of compose.
(.> f g h) creates the function (fn (x) (h (g (f x)))).
AS (TYPE &OPTIONAL (EXPR NIL EXPR-SUPPLIED-P)) [MACRO]
A syntactic convenience for type casting.
(as <type> <expr>)
is equivalent to
(the <type> (into <expr>))
and
(as <type>)
is equivalent to
(fn (expr) (the <type> (into expr))).
Note that this may copy the object or allocate memory.
ASSERT (DATUM &OPTIONAL (FORMAT-STRING "") &REST FORMAT-DATA) [MACRO]
Signal an error unless datum is True.
If the assertion fails, the signaled error will apply the format-data
to the format-string via cl:format to produce an error message.
MAKE-LIST (&REST FORMS) [MACRO]
Create a heterogeneous Coalton List of objects. This macro is
deprecated; use coalton/list:make.
NEST (&REST ITEMS) [MACRO]
A syntactic convenience for function application. Transform
(nest f g h x)
to
(f (g (h x))).
PIPE (&REST ITEMS) [MACRO]
A syntactic convenience for function application, sometimes called a “threading macro”. Transform
(pipe x h g f)
to
(f (g (h x))).
TRY-AS (TYPE &OPTIONAL (EXPR NIL EXPR-SUPPLIED-P)) [MACRO]
A syntactic convenience for type casting.
(try-as <type> <expr>)
is equivalent to
(the (Optional <type>) (tryInto <expr>))
and
(try-as <type>)
is equivalent to
(fn (expr) (the (Optional <type>) (tryInto expr))).
Note that this may copy the object or allocate memory.
UNWRAP-AS (TYPE &OPTIONAL (EXPR NIL EXPR-SUPPLIED-P)) [MACRO]
A syntactic convenience for type casting.
(unwrap-as <type> <expr>)
is equivalent to
(the <type> (uwrap (tryInto <expr>)))
and
(unwrap-as <type>)
is equivalent to
(fn (expr) (the <type> (unwrap (tryInto expr)))).
Note that this may copy the object or allocate memory.
Package COALTON/BITS
Classes
Bits [CLASS] · src
Operations on the bits of twos-complement integers
Methods:
AND :: :INT * :INT → :INT
The bitwise logicalandof two integersOR :: :INT * :INT → :INT
The bitwise logicalorof two integersXOR :: :INT * :INT → :INT
The bitwise logical exclusiveorof two integersNOT :: :INT → :INT
The bitwise logicalnotof two integersSHIFT :: Integer * :INT → :INT
The arithmetic left-shift of an integer by an integer number of bits
Instances
ReverseBits [CLASS] · src
ReverseBits :T
A type class for number types that support bit reversal.
Methods:
REVERSE-BITS :: :T → :T
Reverse the bits ofx.REVERSE-N-BITS :: UFix * :T → :T
Reverse the firstnbits ofxand set the rest to 0.
Instances
Values
(DPB NEWBYTE SIZE POSITION BITSTRING) [FUNCTION] · src
∀ :A. Bits :A ⇒ :A * UFix * UFix * :A → :A
Deposits a byte newbyte of size size into a bitstring bitstring at a position position.
(LDB SIZE POSITION BITSTRING) [FUNCTION] · src
∀ :A. Bits :A ⇒ UFix * UFix * :A → :A
Deposits a byte of size size into a bitstring at a position position.
Package COALTON/BUILTIN
Values
(BOOLEAN-AND X Y) [FUNCTION] · src
Are both x and y true? Note that this is a function which means both x and y will be evaluated. Use the and macro for short-circuiting behavior.
(BOOLEAN-NOT X) [FUNCTION] · src
The logical negation of x. Is x false?
(BOOLEAN-OR X Y) [FUNCTION] · src
Is either x or y true? Note that this is a function which means both x and y will be evaluated. Use the or macro for short-circuiting behavior.
(BOOLEAN-XOR X Y) [FUNCTION] · src
Are x or y true, but not both?
(NOT X) [FUNCTION] · src
Synonym for boolean-not.
(UNDEFINED _) [FUNCTION] · src
∀ :A :B. :A → :B
A function which can be used in place of any value, throwing an error at runtime.
(XOR X Y) [FUNCTION] · src
Synonym for boolean-xor.
Macros
UNREACHABLE (&OPTIONAL (DATUM "Unreachable") &REST ARGUMENTS) [MACRO]
Signal an error with CL format string DATUM and optional format arguments ARGUMENTS.
Package COALTON/CELL
Types
Cell [TYPE] · src
Internally mutable cell
Instances
Values
(DECREMENT! CEL) [FUNCTION] · src
∀ :COUNTER. Num :COUNTER ⇒ Cell :COUNTER → :COUNTER
Subtract one from the contents of cel, storing and returning the new
value.
(INCREMENT! CEL) [FUNCTION] · src
∀ :COUNTER. Num :COUNTER ⇒ Cell :COUNTER → :COUNTER
Add one to the contents of cel, storing and returning the new value.
(NEW DATA) [FUNCTION] · src
∀ :A. :A → Cell :A
Create a new mutable cell containing data.
(POP! CEL) [FUNCTION] · src
∀ :ELT. Cell (List :ELT) → Optional :ELT
Remove and return the first element of the list in cel.
(PUSH! CEL NEW-ELT) [FUNCTION] · src
∀ :ELT. Cell (List :ELT) * :ELT → List :ELT
Push new-elt onto the start of the list in cel.
(READ CEL) [FUNCTION] · src
∀ :A. Cell :A → :A
Read the value of a mutable cell cel.
(SWAP! CEL DATA) [FUNCTION] · src
∀ :A. Cell :A * :A → :A
Replace the value of a mutable cell cel with a new value data,
then return the old value.
(UPDATE! F CEL) [FUNCTION] · src
∀ :A. (:A → :A) * Cell :A → :A
Apply f to the contents of cel, storing and returning the result.
(UPDATE-SWAP! F CEL) [FUNCTION] · src
∀ :A. (:A → :A) * Cell :A → :A
Apply f to the contents of cel, swapping the result for the old
value.
(WRITE! CEL DATA) [FUNCTION] · src
∀ :A. Cell :A * :A → :A
Set the value of a mutable cell cel to data, returning the new
value.
Package COALTON/CHAR
Values
(ALPHA? C) [FUNCTION] · src
Is c an alphabetic character?
(ASCII-ALPHA? C) [FUNCTION] · src
Is c an ASCII alphabetic character?
(ASCII-ALPHANUMERIC? C) [FUNCTION] · src
Is c an ASCII alphanumeric character?
(ASCII-DIGIT? C) [FUNCTION] · src
Is c an ASCII digit character?
(ASCII-LOWERCASE? C) [FUNCTION] · src
Is c an ASCII lowercase character?
(ASCII-UPPERCASE? C) [FUNCTION] · src
Is c an ASCII uppercase character?
(CHAR-CODE CHAR) [FUNCTION] · src
Convert a character to its ASCII representation.
(CODE-CHAR CODE) [FUNCTION] · src
Convert a number to its ASCII character, returning None on failure.
(DIGIT? C) [FUNCTION] · src
Is c a digit character?
(DOWNCASE C) [FUNCTION] · src
Returns the downcased version of c, returning c when there is none.
(LOWERCASE? C) [FUNCTION] · src
Is c a lowercase character?
(RANGE START END) [FUNCTION] · src
An inclusive range of characters from start to end by char-code.
(UPCASE C) [FUNCTION] · src
Returns the upcased version of c, returning c when there is none.
(UPPERCASE? C) [FUNCTION] · src
Is c an uppercase character?
Package COALTON/CLASSES
Types
Hash [TYPE] · src
Implementation dependent hash code.
Ordering [TYPE] · src
LT- Less than
GT- Greater than
EQ- Equal to
The result of an ordered comparison.
Result [TYPE] · src
(Err :A)(Ok :A)
Represents something that may have failed.
Instances
(Eq :A) (Eq :B) ⇒ Eq (Result :A :B)(Ord :A) (Ord :B) ⇒ Ord (Result :A :B)Applicative (Result :A)Bifunctor ResultFromIterator :CONTAINER :ELT ⇒ FromIterator (Result :ERR :CONTAINER) (Result :ERR :ELT)Functor (Result :A)Into (Optional :B) (Result Unit :B)Into (Result :A :B) (Optional :B)IntoIterator (Result :ERR :ELT) :ELTIso (Result Unit :A) (Optional :A)Monad (Result :A)Monoid :B ⇒ Monoid (Result :A :B)RuntimeRepr (Result :|0| :|1|)Semigroup :B ⇒ Semigroup (Result :A :B)Terminator (Result :E :A)Traversable (Result :A)Unwrappable (Result :A)Yielder (Result :E)
Structs
Tuple #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :B> [STRUCT] · src
A heterogeneous collection of items.
Instances
(Default :A) (Default :B) ⇒ Default (Tuple :A :B)(Eq :A) (Eq :B) ⇒ Eq (Tuple :A :B)(Hash :A) (Hash :B) ⇒ Hash (Tuple :A :B)(Ord :A) (Ord :B) ⇒ Ord (Tuple :A :B)Bifunctor TupleHash :K ⇒ FromIterator (HashMap :K :V) (Tuple :K :V)Hash :KEY ⇒ FromIterator (HashTable :KEY :VALUE) (Tuple :KEY :VALUE)Into (MapPair :KEY :VALUE) (Tuple :KEY :VALUE)Into (Tuple :A :B) (Tuple :B :A)IntoIterator (HashMap :K :V) (Tuple :K :V)IntoIterator (HashTable :KEY :VALUE) (Tuple :KEY :VALUE)IntoIterator (OrdMap :KEY :VALUE) (Tuple :KEY :VALUE)Iso (Tuple :A :B) (Tuple :B :A)Ord :KEY ⇒ FromIterator (OrdMap :KEY :VALUE) (Tuple :KEY :VALUE)RuntimeRepr (Tuple :|0| :|1|)Traversable (Tuple :A)
Classes
Alternative [CLASS] · src
Applicative :F ⇒ Alternative :F
Types which are monoids on applicative functors.
Methods:
ALT :: :F :A * :F :A → :F :AEMPTY :: :F :A
Instances
Monad :M ⇒ Alternative (OptionalT :M)Alternative ListAlternative Optional
Applicative [CLASS] · src
Functor :F ⇒ Applicative :F
Types which are a functor which can embed pure expressions and sequence operations.
Methods:
PURE :: :A → :F :ALIFTA2 :: (:A * :B → :C) * :F :A * :F :B → :F :C
Instances
Monad :M ⇒ Applicative (LoopT :M)(Functor :F) (Monad :M) ⇒ Applicative (FreeT :F :M)Functor :F ⇒ Applicative (Free :F)Monad :M ⇒ Applicative (OptionalT :M)Monad :M ⇒ Applicative (ResultT :ERR :M)Applicative :M ⇒ Applicative (EnvT :ENV :M)Applicative (Env :ENV)Applicative :M ⇒ Applicative (StateT :S :M)Applicative (ST :STATE)Applicative IdentityApplicative ListApplicative (Result :A)Applicative OptionalApplicative CellApplicative (Arrow :A)
Bifunctor [CLASS] · src
Bifunctor :F
Types which take two type arguments and are functors on both.
Methods:
BIMAP :: (:A → :B) * (:C → :D) * :F :A :C → :F :B :D
Default [CLASS] · src
Default :A
Types which have default values.
Methods:
DEFAULT :: Void → :A
Instances
RuntimeRepr :A ⇒ Default (Seq :A)Default (Queue :A)Hash :KEY ⇒ Default (HashTable :KEY :VALUE)Default StringDefault (Vector :A)Default (List :A)Default (Optional :A)(Default :A) (Default :B) (Default :C) (Default :D) (Default :E) ⇒ Default (Tuple5 :A :B :C :D :E)(Default :A) (Default :B) (Default :C) (Default :D) ⇒ Default (Tuple4 :A :B :C :D)(Default :A) (Default :B) (Default :C) ⇒ Default (Tuple3 :A :B :C)(Default :A) (Default :B) ⇒ Default (Tuple :A :B)Default :A ⇒ Default (Cell :A)Default F64Default F32Default IntegerDefault UFixDefault IFixDefault U64Default U32Default U16Default I64Default I32Default I16Default U8Default I8Default BitDefault SymbolDefault BooleanDefault Hash
Eq [CLASS] · src
Eq :A
Types which have equality defined.
Methods:
== :: :A * :A → Boolean
Instances
Eq RealAlgebraicEq CRealEq Big-FloatEq :T ⇒ Eq (Hyperdual :T)Eq :T ⇒ Eq (Dual :T)
Note: Eq only compares the primal component.Eq DyadicEq PathnameEq :A ⇒ Eq (Seq :A)(Eq :KEY) (Eq :VALUE) ⇒ Eq (OrdMap :KEY :VALUE)Eq :KEY ⇒ Eq (MapPair :KEY :VALUE)Eq :ELT ⇒ Eq (OrdTree :ELT)Eq :A ⇒ Eq (Queue :A)(Eq :K) (Eq :V) (Hash :K) ⇒ Eq (HashMap :K :V)(Hash :KEY) (Eq :VALUE) ⇒ Eq (HashTable :KEY :VALUE)Eq :A ⇒ Eq (Slice :A)Eq StringEq CharEq :A ⇒ Eq (Vector :A)Eq :A ⇒ Eq (List :A)Eq :T ⇒ Eq (LispArray :T)(Eq :A) (Eq :B) ⇒ Eq (Result :A :B)Eq :A ⇒ Eq (Optional :A)(Eq :A) (Eq :B) (Eq :C) (Eq :D) (Eq :E) ⇒ Eq (Tuple5 :A :B :C :D :E)(Eq :A) (Eq :B) (Eq :C) (Eq :D) ⇒ Eq (Tuple4 :A :B :C :D)(Eq :A) (Eq :B) (Eq :C) ⇒ Eq (Tuple3 :A :B :C)(Eq :A) (Eq :B) ⇒ Eq (Tuple :A :B)Eq :A ⇒ Eq (Cell :A)ComplexComponent :A ⇒ Eq (Complex :A)Eq FractionEq F64Eq F32Eq U64Eq I64Eq U32Eq I32Eq U16Eq I16Eq U8Eq I8Eq BitEq UFixEq IFixEq IntegerEq SymbolEq BooleanEq HashEq OrderingEq UnitEq LispType
Foldable [CLASS] · src
Foldable :CONTAINER
Types which can be folded into a single element.
Methods:
FOLD :: (:ACCUM * :ELT → :ACCUM) * :ACCUM * :CONTAINER :ELT → :ACCUM
A left tail-recursive fold.FOLDR :: (:ELT * :ACCUM → :ACCUM) * :ACCUM * :CONTAINER :ELT → :ACCUM
A right non-tail-recursive fold.
Instances
FromAssociationComprehension [CLASS] · src
FromAssociationComprehension :ASSOCIATION :KEY :VALUE :BUILDER
Types which can be built from association comprehension syntax like [key => value :for ...].
These methods form a streaming builder protocol:
begin-association-comprehensioncreates the initial builder state. It receives an advisory size hint when the compiler can cheaply determine one.adjoin-to-association-comprehensionis called once per emitted key/value pair, left to right. Duplicate keys should be kept or discarded consistently; the standard association instances keep the first occurrence.finalize-association-comprehensionconverts the builder state into the final association.
When no concrete type is specified, the compiler defaults to Seq (Tuple :key :value).
Methods:
BEGIN-ASSOCIATION-COMPREHENSION :: Proxy :ASSOCIATION * Optional UFix → :BUILDER
Return the initial builder state. SIZE-HINT is an advisory initial capacity hint:Some nwhen the compiler can cheaply approximate a useful starting size, andNoneotherwise.ADJOIN-TO-ASSOCIATION-COMPREHENSION :: Proxy :ASSOCIATION * :BUILDER * :KEY * :VALUE → :BUILDER
Add one emitted key/value pair to the builder state. Duplicate keys keep the first occurrence.FINALIZE-ASSOCIATION-COMPREHENSION :: Proxy :ASSOCIATION * :BUILDER → :ASSOCIATION
Convert the finished builder state into the target association.
Instances
RuntimeRepr (Tuple :KEY :VALUE) ⇒ FromAssociationComprehension (Seq (Tuple :KEY :VALUE)) :KEY :VALUE (Seq (Tuple :KEY :VALUE))Ord :KEY ⇒ FromAssociationComprehension (OrdMap :KEY :VALUE) :KEY :VALUE (OrdMap :KEY :VALUE)Hash :KEY ⇒ FromAssociationComprehension (HashMap :KEY :VALUE) :KEY :VALUE (HashMap :KEY :VALUE)Hash :KEY ⇒ FromAssociationComprehension (HashTable :KEY :VALUE) :KEY :VALUE (HashTable :KEY :VALUE)FromAssociationComprehension (List (Tuple :KEY :VALUE)) :KEY :VALUE (List (Tuple :KEY :VALUE))
FromCollectionComprehension [CLASS] · src
FromCollectionComprehension :COLLECTION :ELEMENT :BUILDER
Types which can be built from collection comprehension syntax like [expr :for ...].
These methods form a streaming builder protocol:
begin-collection-comprehensioncreates the initial builder state. It receives an advisory size hint when the compiler can cheaply determine one.adjoin-to-collection-comprehensionis called once per emitted element, left to right.finalize-collection-comprehensionconverts the builder state into the final collection.
When no concrete type is specified, the compiler defaults to Seq.
Methods:
BEGIN-COLLECTION-COMPREHENSION :: Proxy :COLLECTION * Optional UFix → :BUILDER
Return the initial builder state. SIZE-HINT is an advisory initial capacity hint:Some nwhen the compiler can cheaply approximate a useful starting size, andNoneotherwise.ADJOIN-TO-COLLECTION-COMPREHENSION :: Proxy :COLLECTION * :BUILDER * :ELEMENT → :BUILDER
Add one emitted comprehension element to the builder state.FINALIZE-COLLECTION-COMPREHENSION :: Proxy :COLLECTION * :BUILDER → :COLLECTION
Convert the finished builder state into the target collection.
Instances
RuntimeRepr :A ⇒ FromCollectionComprehension (Seq :A) :A (Seq :A)FromCollectionComprehension (Queue :A) :A (Queue :A)FromCollectionComprehension (Vector :A) :A (Vector :A)FromCollectionComprehension (List :ELT) :ELT (List :ELT)RuntimeRepr :T ⇒ FromCollectionComprehension (LispArray :T) :T (LispArrayBuilder :T)
FromItemizedAssociation [CLASS] · src
FromItemizedAssociation :ASSOCIATION :KEY :VALUE :BUILDER
Types which can be built from association builder syntax [k1 => v1 k2 => v2],
where the entries are explicitly and finitely itemized in source.
These methods form an exact indexed builder protocol:
begin-association-buildercreates the initial builder state. It receives the exact number of source entries in the builder syntax.adjoin-to-association-builderis called once per key/value pair, left to right, with the zero-based source index of that entry. Duplicate keys should be kept or discarded consistently; the standard instances keep the first occurrence.finalize-association-builderconverts the builder state into the final association.
Use this class for converting a finite, explicitly itemized sequence of source entries into a target association.
When no concrete type is specified, the compiler defaults to Seq (Tuple :key :value).
Methods:
BEGIN-ASSOCIATION-BUILDER :: Proxy :ASSOCIATION * UFix → :BUILDER
Return the initial builder state for a builder with exactly SIZE source entries.ADJOIN-TO-ASSOCIATION-BUILDER :: Proxy :ASSOCIATION * :BUILDER * UFix * :KEY * :VALUE → :BUILDER
Add one key/value pair to the builder state. INDEX is the zero-based source position of the entry. Duplicate keys keep the first occurrence.FINALIZE-ASSOCIATION-BUILDER :: Proxy :ASSOCIATION * :BUILDER → :ASSOCIATION
Convert the completed builder state into the final association.
Instances
RuntimeRepr (Tuple :KEY :VALUE) ⇒ FromItemizedAssociation (Seq (Tuple :KEY :VALUE)) :KEY :VALUE (Seq (Tuple :KEY :VALUE))Ord :KEY ⇒ FromItemizedAssociation (OrdMap :KEY :VALUE) :KEY :VALUE (OrdMap :KEY :VALUE)Hash :KEY ⇒ FromItemizedAssociation (HashMap :KEY :VALUE) :KEY :VALUE (HashMap :KEY :VALUE)Hash :KEY ⇒ FromItemizedAssociation (HashTable :KEY :VALUE) :KEY :VALUE (HashTable :KEY :VALUE)FromItemizedAssociation (List (Tuple :KEY :VALUE)) :KEY :VALUE (List (Tuple :KEY :VALUE))
FromItemizedCollection [CLASS] · src
FromItemizedCollection :COLLECTION :ELEMENT :BUILDER
Types which can be built from collection builder syntax [a b c], where the
elements are explicitly and finitely itemized in source.
These methods form an exact indexed builder protocol:
begin-collection-buildercreates the initial builder state. It receives the exact number of source items in the builder syntax.adjoin-to-collection-builderis called once per element, left to right, with the zero-based source index of that element.finalize-collection-builderconverts the builder state into the final collection.
Use this class for converting a finite, explicitly itemized sequence of source elements into a target collection.
When no concrete type is specified, the compiler defaults to Seq.
Methods:
BEGIN-COLLECTION-BUILDER :: Proxy :COLLECTION * UFix → :BUILDER
Return the initial builder state for a builder with exactly SIZE source elements.ADJOIN-TO-COLLECTION-BUILDER :: Proxy :COLLECTION * :BUILDER * UFix * :ELEMENT → :BUILDER
Add one evaluated builder element to the builder state. INDEX is the zero-based source position of ITEM.FINALIZE-COLLECTION-BUILDER :: Proxy :COLLECTION * :BUILDER → :COLLECTION
Convert the completed builder state into the final collection.
Instances
RuntimeRepr :A ⇒ FromItemizedCollection (Seq :A) :A (Seq :A)FromItemizedCollection (Queue :A) :A (Queue :A)FromItemizedCollection (Vector :A) :A (Vector :A)FromItemizedCollection (List :ELT) :ELT (List :ELT)RuntimeRepr :T ⇒ FromItemizedCollection (LispArray :T) :T (LispArray :T)
Functor [CLASS] · src
Functor :F
Types which can map an inner type where the mapping adheres to the identity and composition laws.
Methods:
MAP :: (:A → :B) * :F :A → :F :B
Instances
Functor SeqFunctor (OrdMap :KEY)Functor :M ⇒ Functor (LoopT :M)(Functor :F) (Functor :M) ⇒ Functor (FreeT :F :M)Functor :F ⇒ Functor (FreeF :F :A)Functor :F ⇒ Functor (Free :F)Functor :M ⇒ Functor (OptionalT :M)Functor :M ⇒ Functor (ResultT :ERR :M)Functor :M ⇒ Functor (EnvT :ENV :M)Functor (Env :ENV)Functor :M ⇒ Functor (StateT :S :M)Functor (ST :STATE)Functor IdentityFunctor QueueFunctor (HashMap :KEY)Functor VectorFunctor ListFunctor (Result :A)Functor OptionalFunctor IteratorFunctor CellFunctor (Arrow :A)
Hash [CLASS] · src
Types which can be hashed for storage in hash tables.
The hash function must satisfy the invariant that (== left right) implies (== (hash left) (hash right)).
Methods:
HASH :: :A → Hash
Instances
Hash :T ⇒ Hash (Hyperdual :T)Hash :T ⇒ Hash (Dual :T)
Note: Hash only considers the primal component in order to be consistent with Eq.(Hash :KEY) (Hash :VALUE) ⇒ Hash (OrdMap :KEY :VALUE)Hash :ELT ⇒ Hash (OrdTree :ELT)(Hash :K) (Hash :V) ⇒ Hash (HashMap :K :V)(Hash :KEY) (Hash :VALUE) ⇒ Hash (HashTable :KEY :VALUE)Hash StringHash CharHash :A ⇒ Hash (List :A)(Hash :A) (Hash :B) (Hash :C) (Hash :D) (Hash :E) ⇒ Hash (Tuple5 :A :B :C :D :E)(Hash :A) (Hash :B) (Hash :C) (Hash :D) ⇒ Hash (Tuple4 :A :B :C :D)(Hash :A) (Hash :B) (Hash :C) ⇒ Hash (Tuple3 :A :B :C)(Hash :A) (Hash :B) ⇒ Hash (Tuple :A :B)Hash F64Hash F32Hash UFixHash IFixHash U64Hash U32Hash U16Hash U8Hash BitHash I64Hash I32Hash I16Hash I8Hash IntegerHash BooleanHash Hash
Into [CLASS] · src
Into :A :B
Into :a :b implies every element of :a can be represented by an element of :b. This conversion might not be bijective (i.e., there may be elements in :b that don’t correspond to any in :a).
Methods:
INTO :: :A → :B
Instances
Into Fraction RealAlgebraicInto Integer RealAlgebraicInto I8 CRealInto U8 CRealInto I16 CRealInto U16 CRealInto I32 CRealInto U32 CRealInto I64 CRealInto U64 CRealInto IFix CRealInto UFix CRealInto Integer CRealInto Fraction CRealInto F64 CRealInto F32 CReal(ComplexComponent :A) (Into :A CReal) ⇒ Into (Complex :A) (Complex CReal)Into F64 Big-FloatInto F32 Big-FloatInto Fraction Big-FloatInto Integer Big-Float(ComplexComponent :T) (Into :T (Hyperdual :T)) ⇒ Into (Complex :T) (Complex (Hyperdual :T))Num :T ⇒ Into :T (Hyperdual :T)Into Integer DyadicInto Dyadic FractionInto Pathname StringInto String PathnameInto (Seq :A) (Vector :A)Into (Seq :A) (List :A)(Foldable :F) (RuntimeRepr :A) ⇒ Into (:F :A) (Seq :A)Into (MapPair :KEY :VALUE) (Tuple :KEY :VALUE)Into (Vector :A) (Slice :A)Into (Slice :A) (Vector :A)Into F64 StringInto F32 StringInto Fraction StringInto U64 StringInto I64 StringInto U32 StringInto I32 StringInto U16 StringInto I16 StringInto U8 StringInto I8 StringInto UFix StringInto IFix StringInto Integer StringInto (Vector Char) StringInto (List Char) StringInto Char StringInto String (Vector Char)Into String (List Char)Into (Vector :A) (List :A)Into (List :A) (Vector :A)Into (Optional :A) (List :A)Into (LispArray :T) (List :T)RuntimeRepr :T ⇒ Into (List :T) (LispArray :T)Into (Optional :B) (Result Unit :B)Into (Result :A :B) (Optional :B)Into (Tuple :A :B) (Tuple :B :A)Into :A String ⇒ Into (Cell :A) StringInto (Cell :A) :AInto :A (Cell :A)ComplexComponent :A ⇒ Into :A (Complex :A)Into UFix FractionInto U64 FractionInto U32 FractionInto U16 FractionInto U8 FractionInto Bit FractionInto IFix FractionInto I64 FractionInto I32 FractionInto I16 FractionInto I8 FractionInto Integer FractionInto F32 F64Into I32 F64Into U32 F64Into I16 F64Into U16 F64Into I8 F64Into U8 F64Into Bit F64Into I16 F32Into U16 F32Into I8 F32Into U8 F32Into Bit F32Into IFix IntegerInto IFix I64Into UFix IntegerInto UFix IFixInto UFix I64Into UFix U64Into I64 IntegerInto U64 IntegerInto I32 IntegerInto I32 IFixInto I32 I64Into U32 IntegerInto U32 IFixInto U32 UFixInto U32 I64Into U32 U64Into I16 IntegerInto I16 IFixInto I16 I64Into I16 I32Into U16 IntegerInto U16 IFixInto U16 UFixInto U16 I64Into U16 U64Into U16 I32Into U16 U32Into I8 IntegerInto I8 IFixInto I8 I64Into I8 I32Into I8 I16Into U8 IntegerInto U8 IFixInto U8 UFixInto U8 I64Into U8 U64Into U8 I32Into U8 U32Into U8 I16Into U8 U16Into Bit IntegerInto Bit IFixInto Bit UFixInto Bit I64Into Bit U64Into Bit I32Into Bit U32Into Bit I16Into Bit U16Into Bit I8Into Bit U8Into :A :A
Iso [CLASS] · src
(Into :A :B) (Into :B :A) ⇒ Iso :A :B
Opting into this marker typeclass implies that the instances for (Into :a :b) and (Into :b :a) form a bijection.
Methods:
Instances
Monad [CLASS] · src
Applicative :M ⇒ Monad :M
Types which are monads as defined in Haskell. See https://wiki.haskell.org/Monad for more information.
Methods:
>>= :: :M :A * (:A → :M :B) → :M :B
Instances
Monad :M ⇒ Monad (LoopT :M)(Functor :F) (Monad :M) ⇒ Monad (FreeT :F :M)Functor :F ⇒ Monad (Free :F)Monad :M ⇒ Monad (OptionalT :M)Monad :M ⇒ Monad (ResultT :ERR :M)Monad :M ⇒ Monad (EnvT :ENV :M)Monad (Env :ENV)Monad :M ⇒ Monad (StateT :S :M)Monad (ST :STATE)Monad IdentityMonad ListMonad (Result :A)Monad OptionalMonad (Arrow :A)
MonadFail [CLASS] · src
Methods:
FAIL :: String → :M :A
MonadTransformer [CLASS] · src
Types which are monads that wrap another monad, allowing you to use - for example - State and Result together.
Methods:
LIFT :: Monad :M ⇒ :M :A → :T :M :A
Instances
MonadTransformer LoopTFunctor :F ⇒ MonadTransformer (FreeT :F)MonadTransformer OptionalTMonadTransformer (ResultT :ERR)MonadTransformer (EnvT :ENV)MonadTransformer (StateT :S)
Monoid [CLASS] · src
Types with an associative binary operation and identity defined.
Methods:
MEMPTY :: :A
Instances
Num [CLASS] · src
Types which have numeric operations defined.
Methods:
+ :: :A * :A → :A- :: :A * :A → :A* :: :A * :A → :AFROMINT :: Integer → :A
Instances
Ord [CLASS] · src
Types whose values can be ordered. Requires Eq.
Methods:
<=> :: :A * :A → Ordering
Given two objects, return their comparison (as anOrderingobject).
Instances
Ord RealAlgebraicOrd CRealOrd Big-FloatOrd :T ⇒ Ord (Hyperdual :T)Ord :T ⇒ Ord (Dual :T)
Note: Ord only compares the primal component.Ord DyadicOrd PathnameOrd :KEY ⇒ Ord (MapPair :KEY :VALUE)Ord StringOrd CharOrd :ELT ⇒ Ord (List :ELT)(Ord :A) (Ord :B) ⇒ Ord (Result :A :B)Ord :A ⇒ Ord (Optional :A)(Ord :A) (Ord :B) ⇒ Ord (Tuple :A :B)Ord :A ⇒ Ord (Cell :A)Ord FractionOrd F64Ord F32Ord U64Ord I64Ord U32Ord I32Ord U16Ord I16Ord U8Ord I8Ord BitOrd UFixOrd IFixOrd IntegerOrd BooleanOrd HashOrd Ordering
Semigroup [CLASS] · src
Semigroup :A
Types with an associative binary operation defined.
Methods:
<> :: :A * :A → :A
Instances
Semigroup PathnameRuntimeRepr :A ⇒ Semigroup (Seq :A)Ord :KEY ⇒ Semigroup (OrdMap :KEY :VALUE)Semigroup (Queue :A)Hash :K ⇒ Semigroup (HashMap :K :V)Semigroup StringSemigroup (Vector :A)Semigroup (List :A)Semigroup :B ⇒ Semigroup (Result :A :B)Semigroup :A ⇒ Semigroup (Optional :A)Semigroup :A ⇒ Semigroup (Cell :A)Semigroup Hash
Signalable [CLASS] · src
Signalable :A
Signals errors or warnings by calling their respective lisp conditions.
Methods:
ERROR :: :A → :B
Signal an error with a type-specific error string.
Instances
Traversable [CLASS] · src
Traversable :T
Methods:
TRAVERSE :: Applicative :F ⇒ (:A → :F :B) * :T :A → :F (:T :B)
Instances
(Monad :M) (Traversable :M) (Traversable :F) ⇒ Traversable (FreeT :F :M)Traversable :F ⇒ Traversable (FreeF :F :A)Traversable :T ⇒ Traversable (Free :T)Traversable ListTraversable (Result :A)Traversable OptionalTraversable (Tuple :A)
TryInto [CLASS] · src
TryInto :A :B
TRY-INTO implies some elements of :a can be represented exactly by an element of :b, but sometimes not. Failed conversions return None.
Methods:
TRYINTO :: :A → Optional :B
Instances
TryInto RealAlgebraic FractionTryInto String IntegerTryInto UFix F64TryInto IFix F64TryInto U64 F64TryInto I64 F64TryInto I32 F32TryInto U32 F32TryInto UFix F32TryInto IFix F32TryInto U64 F32TryInto I64 F32TryInto Integer F64TryInto Integer F32TryInto Integer IFixTryInto Integer UFixTryInto Integer I64TryInto Integer U64TryInto Integer I32TryInto Integer U32TryInto Integer I16TryInto Integer U16TryInto Integer I8TryInto Integer U8TryInto Integer BitTryInto IFix UFixTryInto IFix U64TryInto IFix I32TryInto IFix U32TryInto IFix I16TryInto IFix U16TryInto IFix I8TryInto IFix U8TryInto IFix BitTryInto UFix I32TryInto UFix U32TryInto UFix I16TryInto UFix U16TryInto UFix I8TryInto UFix U8TryInto UFix BitTryInto I64 IFixTryInto I64 UFixTryInto I64 U64TryInto I64 I32TryInto I64 U32TryInto I64 I16TryInto I64 U16TryInto I64 I8TryInto I64 U8TryInto I64 BitTryInto U64 IFixTryInto U64 UFixTryInto U64 I64TryInto U64 I32TryInto U64 U32TryInto U64 I16TryInto U64 U16TryInto U64 I8TryInto U64 U8TryInto U64 BitTryInto I32 UFixTryInto I32 U64TryInto I32 U32TryInto I32 I16TryInto I32 U16TryInto I32 I8TryInto I32 U8TryInto I32 BitTryInto U32 I32TryInto U32 I16TryInto U32 U16TryInto U32 I8TryInto U32 U8TryInto U32 BitTryInto I16 UFixTryInto I16 U64TryInto I16 U32TryInto I16 U16TryInto I16 I8TryInto I16 U8TryInto I16 BitTryInto U16 I16TryInto U16 I8TryInto U16 U8TryInto U16 BitTryInto I8 UFixTryInto I8 U64TryInto I8 U32TryInto I8 U16TryInto I8 U8TryInto I8 BitTryInto U8 I8TryInto U8 BitTryInto F64 FractionTryInto F32 Fraction
Unwrappable [CLASS] · src
Unwrappable :CONTAINER
Containers which can be unwrapped to get access to their contents.
(unwrap-or-else succeed fail container) should invoke the succeed continuation on the unwrapped contents of
container when successful, or invoke the fail continuation with no arguments (i.e., with Unit as an argument)
when unable to unwrap a value.
The succeed continuation will often, but not always, be the identity function. as-optional passes Some to
construct an Optional.
Typical fail continuations are:
- Return a default value, or
- Signal an error.
Methods:
UNWRAP-OR-ELSE :: (:ELT → :RESULT) * (Void → :RESULT) * :CONTAINER :ELT → :RESULT
Instances
Values
(< X Y) [FUNCTION] · src
∀ :A. Ord :A ⇒ :A * :A → Boolean
Is x less than y?
(<= X Y) [FUNCTION] · src
∀ :A. Ord :A ⇒ :A * :A → Boolean
Is x less than or equal to y?
(> X Y) [FUNCTION] · src
∀ :A. Ord :A ⇒ :A * :A → Boolean
Is x greater than y?
(>= X Y) [FUNCTION] · src
∀ :A. Ord :A ⇒ :A * :A → Boolean
Is x greater than or equal to y?
(>> A B) [FUNCTION] · src
∀ :M :A :B. Monad :M ⇒ :M :A * :M :B → :M :B
Equivalent to (>>= a (fn (_) b)).
(AS-OPTIONAL CONTAINER) [FUNCTION] · src
∀ :CONTAINER :ELT. Unwrappable :CONTAINER ⇒ :CONTAINER :ELT → Optional :ELT
Convert any Unwrappable container into an Optional, constructing Some on a successful unwrap and None on a failed unwrap.
(DEFAULT? X) [FUNCTION] · src
∀ :A. (Default :A) (Eq :A) ⇒ :A → Boolean
Is x the default item of its type?
(DEFAULTING-UNWRAP CONTAINER) [FUNCTION] · src
∀ :CONTAINER :ELEMENT. (Unwrappable :CONTAINER) (Default :ELEMENT) ⇒ :CONTAINER :ELEMENT → :ELEMENT
Unwrap an unwrappable, returning (default) of the wrapped type on failure.
(EXPECT REASON CONTAINER) [FUNCTION] · src
∀ :CONTAINER :ELEMENT. Unwrappable :CONTAINER ⇒ String * :CONTAINER :ELEMENT → :ELEMENT
Unwrap container, signaling an error with the description reason on failure.
(JOIN M) [FUNCTION] · src
∀ :M :A. Monad :M ⇒ :M (:M :A) → :M :A
Equivalent to (>>= m id).
(MAP-FST F B) [FUNCTION] · src
∀ :A :B :F :C. Bifunctor :F ⇒ (:A → :B) * :F :A :C → :F :B :C
Map over the first argument of a Bifunctor.
(MAP-SND F B) [FUNCTION] · src
∀ :B :C :F :A. Bifunctor :F ⇒ (:B → :C) * :F :A :B → :F :A :C
Map over the second argument of a Bifunctor.
(MAX X Y) [FUNCTION] · src
∀ :A. Ord :A ⇒ :A * :A → :A
Returns the greater element of x and y.
(MCOMMUTE? A B) [FUNCTION] · src
∀ :A. (Eq :A) (Semigroup :A) ⇒ :A * :A → Boolean
Does a <> b equal b <> a?
(MCONCAT A) [FUNCTION] · src
∀ :F :A. (Foldable :F) (Monoid :A) ⇒ :F :A → :A
Fold a container of monoids into a single element.
(MCONCATMAP F A) [FUNCTION] · src
∀ :B :A :F. (Foldable :F) (Monoid :A) ⇒ (:B → :A) * :F :B → :A
Map a container to a container of monoids, and then fold that container into a single element.
(MEMPTY? A) [FUNCTION] · src
∀ :A. (Eq :A) (Monoid :A) ⇒ :A → Boolean
Does a equal (the Type mempty)?
(MIN X Y) [FUNCTION] · src
∀ :A. Ord :A ⇒ :A * :A → :A
Returns the lesser element of x and y.
(SEQUENCE X) [FUNCTION] · src
∀ :T :F :B. (Traversable :T) (Applicative :F) ⇒ :T (:F :B) → :F (:T :B)
(UNWRAP CONTAINER) [FUNCTION] · src
∀ :CONTAINER :ELEMENT. Unwrappable :CONTAINER ⇒ :CONTAINER :ELEMENT → :ELEMENT
Unwrap container, signaling an error on failure.
(UNWRAP-INTO X) [FUNCTION] · src
∀ :A :B. TryInto :A :B ⇒ :A → :B
Same as tryInto followed by unwrap.
(WITH-DEFAULT DEFAULT CONTAINER) [FUNCTION] · src
∀ :ELEMENT :CONTAINER. Unwrappable :CONTAINER ⇒ :ELEMENT * :CONTAINER :ELEMENT → :ELEMENT
Unwrap container, returning default on failure.
Package COALTON/EXPERIMENTAL/DO-CONTROL-CORE
Values
(FLATMAP-SUCCESS) [FUNCTION] · src
∀ :Y :A :M :B. (Monad :M) (Yielder :Y) ⇒ :Y :A * (:A → :M (:Y :B)) → :M (:Y :B)
(FLATMAP-SUCCESSM MVAL? F->MVAL?B) [FUNCTION] · src
∀ :M :Y :A :B. (Monad :M) (Yielder :Y) ⇒ :M (:Y :A) * (:A → :M (:Y :B)) → :M (:Y :B)
Evaluate MVAL?, and if the result yields a value, then flatmap F->MVAL?B over the value.
(IF* VAL? M-TRUE M-FALSE) [FUNCTION] · src
∀ :T :M :B. (Monad :M) (Terminator :T) ⇒ :T * :M :B * :M :B → :M :B
Choose between M-TRUE and M-FALSE based on VAL?. If (ended? VAL?) is true, run M-TRUE, else run M-FALSE.
(IF-VAL VAL? F-MVAL M-NONE) [FUNCTION] · src
∀ :Y :A :M :B. (Monad :M) (Yielder :Y) ⇒ :Y :A * (:A → :M :B) * :M :B → :M :B
If VAL? yields a value, apply F-MVAL to it. Otherwise, run M-NONE.
(IF-VALM MVAL? F-MVAL M-NONE) [FUNCTION] · src
∀ :M :Y :A :B. (Monad :M) (Yielder :Y) ⇒ :M (:Y :A) * (:A → :M :B) * :M :B → :M :B
Evaluate MVAL? and dispatch to F-MVAL if the result yields a value. Otherwise evaluate M-NONE.
(IF-VAL_ VAL? F-MVAL M-NONE) [FUNCTION] · src
∀ :Y :A :M :B :C. (Monad :M) (Yielder :Y) ⇒ :Y :A * (:A → :M :B) * :M :C → :M Unit
Like if-val, but discards the branch result and returns Unit.
(MAP-SUCCESS VAL? F->MB) [FUNCTION] · src
∀ :Y :A :M :B. (Monad :M) (Yielder :Y) ⇒ :Y :A * (:A → :M :B) → :M (:Y :B)
Map F->MB over the successful/available value(s) of VAL? within the monad.
(MAP-SUCCESSM MVAL? F->MB) [FUNCTION] · src
∀ :M :Y :A :B. (Monad :M) (Yielder :Y) ⇒ :M (:Y :A) * (:A → :M :B) → :M (:Y :B)
Evaluate MVAL? and map F->MB over the successful value(s) from inside the monad.
(WHEN-VAL VAL? F->M) [FUNCTION] · src
∀ :Y :A :M :Z. (Monad :M) (Yielder :Y) ⇒ :Y :A * (:A → :M :Z) → :M Unit
If VAL? yields a value, apply F->M to it. If not, do nothing. Always returns Unit.
(WHEN-VALM MVAL? F->M) [FUNCTION] · src
∀ :M :Y :A :Z. (Monad :M) (Yielder :Y) ⇒ :M (:Y :A) * (:A → :M :Z) → :M Unit
Evaluate MVAL?, and if it yields, run F->M on the value. Otherwise, do nothing.
(WHENM MTERM? MOP) [FUNCTION] · src
∀ :M :T :Z. (Monad :M) (Terminator :T) ⇒ :M :T * :M :Z → :M Unit
Evaluate MTERM?, and if it indicates completion, run MOP, or do nothing.
(WHEN_ TERM? M) [FUNCTION] · src
∀ :T :M :Z. (Monad :M) (Terminator :T) ⇒ :T * :M :Z → :M Unit
Run the monadic operation M when the terminator TERM? indicates completion, or do nothing.
Package COALTON/EXPERIMENTAL/DO-CONTROL-LOOPS
Values
(COLLECT INTO-ITR FA->M) [FUNCTION] · src
∀ :I :A :M :Z. (Monad :M) (IntoIterator :I :A) ⇒ :I * (:A → :M :Z) → :M (List :Z)
Apply FA->M to each element produced by INTO-ITR and run the resulting monadic action. Collect the results.
(COLLECT-VAL M-OPERATION) [FUNCTION] · src
∀ :M :Y :A. (Monad :M) (Yielder :Y) ⇒ :M (:Y :A) → :M (List :A)
Repeatedly run M-OPERATION, collecting each yielded value into a list until no value is yielded.
(FOREACH INTO-ITR FA->M) [FUNCTION] · src
∀ :I :A :M :Z. (Monad :M) (IntoIterator :I :A) ⇒ :I * (:A → :M :Z) → :M Unit
Apply FA->M to each element produced by INTO-ITR and run the resulting monadic action. Discards the return values and returns Unit.
(LOOP-DO-WHILE M-TERM? BODY) [FUNCTION] · src
∀ :M :T :A. (Monad :M) (Terminator :T) ⇒ :M :T * :M :A → :M Unit
Before each iteration, evaluate M-TERM?. If it indicates completion, stop; otherwise run BODY. Returns Unit.
(LOOP-TIMES N M-OPERATION) [FUNCTION] · src
∀ :M :A. Monad :M ⇒ UFix * (UFix → :M :A) → :M Unit
Repeat M-OPERATION N times. Passes the current index (starting at 0) to M-OPERATION. Returns Unit.
(LOOP-WHILE M-OPERATION) [FUNCTION] · src
∀ :M :T. (Monad :M) (Terminator :T) ⇒ :M :T → :M Unit
Repeat M-OPERATION until it returns a terminated value. Returns Unit.
(LOOP-WHILE-VALM M-OPERATION F) [FUNCTION] · src
∀ :M :Y :A :B. (Monad :M) (Yielder :Y) ⇒ :M (:Y :A) * (:A → :M :B) → :M Unit
Repeat M-OPERATION while it yields a value, running the yielded value applied to F. Returns Unit.
Macros
DO-COLLECT ((SYM INTO-ITR) &BODY BODY) [MACRO]
Apply FA->M to each element produced by INTO-ITR and run the resulting monadic action. Collect the results.
DO-LOOP-DO-WHILE (M-TERM? &BODY BODY) [MACRO]
Before each iteration, evaluate M-TERM?. If it indicates completion, stop; otherwise run BODY. Wraps BODY in a ‘do’ block. Returns Unit.
Package COALTON/EXPERIMENTAL/DO-CONTROL-LOOPS-ADV
Types
LoopT [TYPE] · src
(LoopT :A (Step :B))
Instances
Functor :M ⇒ Functor (LoopT :M)Monad :M ⇒ Applicative (LoopT :M)Monad :M ⇒ Monad (LoopT :M)MonadEnvironment :E :M ⇒ MonadEnvironment :E (LoopT :M)MonadState :S :M ⇒ MonadState :S (LoopT :M)MonadTransformer LoopTRuntimeRepr (LoopT :|0| :|1|)
Values
(COLLECT BODY) [FUNCTION] · src
∀ :M :A. Monad :M ⇒ LoopT :M :A → :M (List :A)
Run BODY in a loop, collecting each value it produces into a list in encounter order. Stops when BODY breaks. Continues skip the rest of the iteration. Returns the collected list.
(COLLECT-VAL BODY) [FUNCTION] · src
∀ :M :Y :A. (Monad :M) (Yielder :Y) ⇒ LoopT :M (:Y :A) → :M (List :A)
Run BODY in a loop, adding each available value it yields to a list. Stops when BODY yields no value or breaks. Continue skips the rest of the iteration. Returns the collected list.
(FOREACH LST FA->LPT-M) [FUNCTION] · src
∀ :A :M :Z. Monad :M ⇒ List :A * (:A → LoopT :M :Z) → :M Unit
For each element of LST, run FA->LPT-M on it. Break stops the iteration. Continue skips to the next element. Discards return values and returns Unit.
(LOOP-DO-WHILE M-TERM? BODY) [FUNCTION] · src
∀ :M :T :A. (Monad :M) (Terminator :T) ⇒ :M :T * LoopT :M :A → :M Unit
Before each iteration, evaluate M-TERM?. If it indicates completion, stop; otherwise run BODY. Respects break and continue within BODY. Returns Unit.
(LOOP-TIMES N BODY) [FUNCTION] · src
∀ :M :A. Monad :M ⇒ UFix * (UFix → LoopT :M :A) → :M Unit
Repeat BODY N times. Passes the current index (starting at 0) to BODY. Returns Unit.
(LOOP-WHILE BODY) [FUNCTION] · src
∀ :M :T. (Monad :M) (Terminator :T) ⇒ LoopT :M :T → :M Unit
Run BODY repeatedly until it returns a terminated value. Returns Unit.
(LOOP_ BODY) [FUNCTION] · src
∀ :M :A. Monad :M ⇒ LoopT :M :A → :M Unit
Run BODY forever, until it signals a break. Any produced values are ignored. Returns Unit.
(ONCE LP-M) [FUNCTION] · src
∀ :M :A. Monad :M ⇒ LoopT :M :A → :M Unit
Run an operation exactly once. Continue or break will both immediately end execution in the operation. Returns Unit.
(UNWRAP-LOOP (LOOPT M-STP)) [FUNCTION] · src
∀ :M :A. LoopT :M :A → :M (Step :A)
Advance a LoopT computation by one step, returning whether it asked to continue, break, or produced a value.
BREAK-LOOP [VALUE] · src
∀ :M :A. Monad :M ⇒ LoopT :M :A
Signal that the loop should terminate immediately.
CONTINUE-LOOP [VALUE] · src
∀ :M :A. Monad :M ⇒ LoopT :M :A
Signal that the current iteration should be skipped and the loop should continue.
Package COALTON/EXPERIMENTAL/LOOPS
A Coalton package of loop macros.
Note: (return), (break), and (continue) do not work inside any of these loop macros.
Macros
ARGBESTTIMES ((VARIABLE COUNT BETTER?) &BODY BODY) [MACRO]
The UFix in [0, count) which, when variable is bound to it, results in the evaluation of body which is better than the same for the rest of the UFixs in [0, count).
BESTTIMES ((VARIABLE COUNT BETTER?) &BODY BODY) [MACRO]
The result of evaluating body with variable bound to a UFix in [0, count) that is better? than the result of evaluating body with variable bound to the rest of the UFixs in [0, count).
COLLECTTIMES ((VARIABLE COUNT) &BODY BODY) [MACRO]
Collect the results of evaluating body for variable bound to every UFix in [0, count) as a List.
DOLIST ((VARIABLE LIS) &BODY BODY) [MACRO]
Perform body with variable bound to every element of lis.
DOLIST-ENUMERATED ((INDEX-VARIABLE ELEMENT-VARIABLE LIS) &BODY BODY) [MACRO]
Perform body with element-variable bound to the elements of lis and index-variable bound to their indices.
DOLISTS (VARIABLES-AND-LISTS &BODY BODY) [MACRO]
Perform body with the variables bound to the elements of the lists. See the example below.
Example:
> (coalton (dolists ((x (make-list 1 2 3))
(y (make-list 10 20 30))
(z (make-list 100 200 300 400)))
(print (+ x (+ y z))))
111
222
333
COALTON::UNIT/UNIT
DORANGE ((VARIABLE START-OR-STOP &OPTIONAL STOP STEP) &BODY BODY) [MACRO]
Perform body with variable bound to elements of a discrete range.
If only start-or-stop is supplied, then the range is from 0 (inclusive) to start-or-stop (exclusive) by increments or decrements of 1.
> (coalton (dorange (x 3) (print x)))
0
1
2
COALTON::UNIT/UNIT
> (coalton (dorange (x -3) (print x)))
0
-1
-2
COALTON::UNIT/UNIT
If only start-or-stop and stop are supplied, then the range is from start-or-stop (inclusive) to stop (exclusive) by increments or decrements of 1.
> (coalton (dorange (x -2 2) (print x)))
-2
-1
0
1
COALTON::UNIT/UNIT
> (coalton (dorange (x 0.5 -2) (print x)))
0.5
-0.5
-1.5
COALTON::UNIT/UNIT
Otherwise, the range is from start-or-stop (inclusive) to stop (exclusive) by step. step must be the correct sign, or dorange does nothing.
> (coalton (dorange -2 2 2) (print x))
-2
0
COALTON::UNIT/UNIT
> (coalton (dorange -2 2 -1) (print x))
COALTON::UNIT/UNIT
DOTIMES ((VARIABLE COUNT) &BODY BODY) [MACRO]
Perform body with variable bound to every UFix in [0, count) sequentially.
EVERYTIMES ((VARIABLE COUNT) &BODY BODY) [MACRO]
Does body evaluate to True for variable bound to every UFix in [0, count). Returns True if (zero? count).
PRODTIMES ((VARIABLE COUNT) &BODY BODY) [MACRO]
The product of body for variable bound to every UFix in [0, count).
REPEAT ((COUNT) &BODY BODY) [MACRO]
Perform body count times.
SOMETIMES ((VARIABLE COUNT) &BODY BODY) [MACRO]
Does body evaluate to True for variable bound to some UFix in [0, count). Returns False if (zero? count).
SUMTIMES ((VARIABLE COUNT) &BODY BODY) [MACRO]
The sum of body for variable bound to every UFix in [0, count).
Package COALTON/FILE
This is Coalton’s library for directory utilities and file IO.
Most functions return outputs of type (Result FileError :a), ensuring that errors can be assessed and handled.
File IO is handled using keyword options, for instance:
(with-open-file file
(fn (stream)
(write-string stream "Hello World!")
(read-file-to-vector stream))
:direction Bidirectional
:if-exists EError)
Input, Output, and Bidirectional select the stream direction. IfExists
controls what happens when an output or bidirectional stream opens an existing
file.
Common Lisp makes a distinction between file and directory paths. Directory paths are always terminated with a trailing slash, file paths must never have a trailing slash.
Types
FileError [TYPE] · src
(PathError String Pathname)(LispError LispCondition)(FileError String)EOF
Errors for file functions.
Instances
FileStream [TYPE] · src
Represents a file stream, using cl:file-stream.
Instances
RuntimeRepr (FileStream :|0|)
IfExists [TYPE] · src
SupersedeOverwriteEErrorAppend
Possible options for opening a stream when the file exists.
Instances
OpenDirection [TYPE] · src
BidirectionalOutputInput
Possible directions for opening a stream.
Instances
Pathname [TYPE] · src
Pathname object. Equivalent to cl:pathname
Instances
Classes
File [CLASS] · src
File :A
A class of types which are able to be written to or read from a file.
Methods:
OPEN :: Into :PATH Pathname ⇒ :PATH &key (:direction OpenDirection) (:if-exists IfExists) → Result FileError (FileStream :A)READ :: FileStream :A → Result FileError :AWRITE :: FileStream :A * :A → Result FileError Unit
Instances
Values
(ABORT STREAM) [FUNCTION] · src
∀ :A :B. FileStream :A → Result FileError :B
Closes a FileStream and aborts all operations..
(APPEND-TO-FILE! PATH DATA) [FUNCTION] · src
∀ :P :A. (RuntimeRepr :A) (Into :P Pathname) (File :A) ⇒ :P * Vector :A → Result FileError Unit
Opens and appends a file with data of type :a.
(CLOSE STREAM) [FUNCTION] · src
∀ :A :B. FileStream :A → Result FileError :B
Closes a FileStream.
(COPY! INPUT OUTPUT) [FUNCTION] · src
∀ :A :B. (Into :A Pathname) (Into :B Pathname) ⇒ :A * :B → Result FileError Unit
Copies a file to a new location.
(CREATE-DIRECTORY! PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError Pathname
This is equivalent to mkdir -p. Creates a directory and its parents. The pathname must be a valid directory pathname.
(CREATE-TEMP-DIRECTORY!) [FUNCTION] · src
Void → Result FileError Pathname
This configures a default temporary directory for use.
(CREATE-TEMP-FILE!) [FUNCTION] · src
&key (:extension String) → Result FileError Pathname
Create a temporary file path, optionally ending in EXTENSION.
(DELETE-FILE! PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError Unit
Deletes a given file if the file exists.
(DIRECTORY-EXISTS? PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError Boolean
Returns True if a pathname names a directory that exists.
(DIRECTORY-FILES PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError (List Pathname)
Returns all files within the directory. Returns an error if the pathname is not a directory pathname.
(DIRECTORY-PATHNAME? PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Boolean
Returns True if a pathname has no file component.
(EMPTY? PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError Boolean
Checks whether a directory is empty.
(EXISTS? PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError Boolean
Returns whether a file or directory exists.
(FILE-EXISTS? PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError Boolean
Returns True if a pathname names a file that exists.
(FILE-PATHNAME? PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Boolean
Returns True if a pathname has a file component.
(FILE-POSITION STREAM) [FUNCTION] · src
∀ :A. FileStream :A → Result FileError UFix
Finds the file-position of a file stream.
(FLUSH STREAM) [FUNCTION] · src
∀ :A :B. FileStream :A → Result FileError :B
Blocks until stream has been flushed. Calls cl:finish-output.
(MERGE PATH1 PATH2) [FUNCTION] · src
∀ :A :B. (Into :A Pathname) (Into :B Pathname) ⇒ :A * :B → Pathname
Merges two pathnames together. The directory pathname should be the first argument.
(READ-CHAR STREAM) [FUNCTION] · src
FileStream Char → Result FileError Char
Reads a character from an FileStream.
(READ-FILE-LINES PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError (List String)
Reads a file into lines, given a pathname or string.
(READ-FILE-TO-STRING PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError String
Reads a file into a string, given a pathname string.
(READ-FILE-TO-VECTOR STREAM) [FUNCTION] · src
∀ :A. File :A ⇒ FileStream :A → Result FileError (Vector :A)
Reads a file into a vector of type :a.
(READ-LINE STREAM) [FUNCTION] · src
FileStream Char → Result FileError String
Reads a line of characters from a FileStream.
(READ-VECTOR STREAM CHUNK-SIZE) [FUNCTION] · src
∀ :A. File :A ⇒ FileStream :A * UFix → Result FileError (Vector :A)
Reads a chunk of a file into a vector of type :a.
(REMOVE-DIRECTORY! PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError :A
Deletes an empty directory.
(REMOVE-DIRECTORY-RECURSIVE! PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError Unit
Deletes a target directory recursively. Equivalent to rm -r. Errors if the path is not a directory.
(SET-FILE-POSITION STREAM I) [FUNCTION] · src
∀ :A. FileStream :A * UFix → Result FileError Unit
Sets the file position of a file stream.
(SUBDIRECTORIES PATH) [FUNCTION] · src
∀ :A. Into :A Pathname ⇒ :A → Result FileError (List Pathname)
Returns all subdirectories within the directory. Returns an error if the pathname is not a directory pathname.
(SYSTEM-RELATIVE-PATHNAME SYSTEM-NAME NAME) [FUNCTION] · src
∀ :A. Into :A String ⇒ :A * String → Result FileError Pathname
Generates a system-relative-pathname for a given filename or path. This is a wrapper for asdf:system-relative-pathname. Name will likely be an empty string unless a subdirectory or filename is specified.
(WITH-OPEN-FILE PATH THUNK) [FUNCTION] · src
∀ :PATH :A :B. (File :A) (Into :PATH Pathname) ⇒ :PATH * (FileStream :A → Result FileError :B) &key (:direction OpenDirection) (:if-exists IfExists) → Result FileError :B
Open PATH, run THUNK on the stream, and then close it.
(WITH-TEMP-DIRECTORY THUNK) [FUNCTION] · src
∀ :A. (Pathname → Result FileError :A) → Result FileError :A
Performs an operation thunk inside a temporary directory.
(WITH-TEMP-FILE THUNK) [FUNCTION] · src
∀ :A :B. File :A ⇒ (FileStream :A → Result FileError :B) &key (:extension String) → Result FileError :B
Perform THUNK on a temporary file, optionally ending in EXTENSION.
(WRITE-CHAR STREAM DATA) [FUNCTION] · src
FileStream Char * Char → Result FileError Unit
Writes a Char to the stream.
(WRITE-LINE STREAM S) [FUNCTION] · src
FileStream Char * String → Result FileError Unit
Writes a string with an appended newline to a filestream of type Char.
(WRITE-STRING FS S) [FUNCTION] · src
FileStream Char * String → Result FileError Unit
Writes a string to a FileStream of type Char.
(WRITE-TO-FILE! PATH DATA) [FUNCTION] · src
∀ :P :A. (RuntimeRepr :A) (Into :P Pathname) (File :A) ⇒ :P * Vector :A &key (:if-exists IfExists) → Result FileError Unit
Open PATH and write DATA using the requested IF-EXISTS policy.
(WRITE-VECTOR STREAM V) [FUNCTION] · src
∀ :A. (RuntimeRepr :A) (File :A) ⇒ FileStream :A * Vector :A → Result FileError Unit
Writes elements of an vector of type :a to a stream of type :a.
Package COALTON/FUNCTIONS
Values
(/= A B) [FUNCTION] · src
∀ :A. Eq :A ⇒ :A * :A → Boolean
Is a not equal to b?
(ASUM XS) [FUNCTION] · src
∀ :T :F :A. (Alternative :F) (Foldable :T) ⇒ :T (:F :A) → :F :A
Fold over a list using alt.
(BRACKET INIT EXIT BODY) [FUNCTION] · src
∀ :M :A :B :C. Monad :M ⇒ :M :A * (:A → :M :B) * (:A → :M :C) → :M :C
Bracket takes an initial state, performs a body of operations, and then forces a safe exit.
This wraps cl:unwind-protect.
Modeled after Haskell: https://wiki.haskell.org/Bracket_pattern
(COMPLEMENT F X) [FUNCTION] · src
∀ :A. (:A → Boolean) * :A → Boolean
Compute the complement of a unary Boolean function.
(COMPOSE F G) [FUNCTION] · src
∀ :B :C :A. (:B → :C) * (:A → :B) → :A → :C
Equivalent to (f (g x)).
(CONJOIN F G X) [FUNCTION] · src
∀ :A. (:A → Boolean) * (:A → Boolean) * :A → Boolean
Compute the conjunction of two unary Boolean functions.
(CONST A) [FUNCTION] · src
∀ :A :B. :A → :B → :A
A function that always returns its first argument.
(CURRY FUNC) [FUNCTION] · src
∀ :LEFT :RIGHT :RESULT. (Tuple :LEFT :RIGHT → :RESULT) → :LEFT * :RIGHT → :RESULT
Adapt a function on (Tuple left right) into a two-argument function.
(DISJOIN F G X) [FUNCTION] · src
∀ :A. (:A → Boolean) * (:A → Boolean) * :A → Boolean
Compute the disjunction of two unary Boolean functions.
(FIX F) [FUNCTION] · src
∀ :A :B. ((:A → :B) * :A → :B) → :A → :B
Compute the fixed point of a unary function. This is equivalent to the Y-combinator of the lambda calculus. This combinator allows recursion without specific assignment of names. For example, the factorial function can be written
(define fact
(fix
(fn (f n)
(if (== n 0)
1
(* n (f (- n 1)))))))
(FLIP F) [FUNCTION] · src
∀ :A :B :C. (:A * :B → :C) → :B * :A → :C
Returns a function that takes its arguments in reverse order.
(ID X) [FUNCTION] · src
∀ :A. :A → :A
A function that always returns its argument.
(MSUM XS) [FUNCTION] · src
∀ :T :A. (Monoid :A) (Foldable :T) ⇒ :T :A → :A
Fold over a list using <>.
(PAIR-WITH FUNC LEFT) [FUNCTION] · src
∀ :LEFT :RIGHT. (:LEFT → :RIGHT) * :LEFT → Tuple :LEFT :RIGHT
Create a Tuple of the form (Tuple left (func left)).
(PRINT ITEM) [FUNCTION] · src
∀ :A. Into :A String ⇒ :A → Void
Print the String representation of item to cl:*standard-output*.
(REDUCE F Y XS) [FUNCTION] · src
∀ :A :B :F. Foldable :F ⇒ (:A * :B → :B) * :B * :F :A → :B
The same as fold but with the argument order swapped to match cl:reduce
(TRACE STR) [FUNCTION] · src
String → Void
Deprecated: Use show.
Print a line to cl:*standard-output*.
(TRACEOBJECT STR ITEM) [FUNCTION] · src
∀ :A. String * :A → Void
Deprecated: Use show or explicit formatting.
Print a line to cl:*standard-output* in the form “{STR}: {ITEM}”.
(UNCURRY FUNC) [FUNCTION] · src
∀ :LEFT :RIGHT :RESULT. (:LEFT * :RIGHT → :RESULT) → Tuple :LEFT :RIGHT → :RESULT
Adapt a two-argument function into one that accepts a single Tuple.
(UNSAFE-POINTER-EQ? A B) [FUNCTION] · src
∀ :A. :A * :A → Boolean
Macros
CONJOIN* (&REST PREDICATES) [MACRO]
Compute the conjuction of predicates.
For example, the following expressions are equivalent.
(conjoin* f g h)
(fn (x) (and (f x) (g x) (h x)))
DISJOIN* (&REST PREDICATES) [MACRO]
Compute the disjunction of predicates.
For example, the following expressions are equivalent.
(disjoin* f g h)
(fn (x) (or (f x) (g x) (h x)))
Package COALTON/HASH
Values
(COMBINE-HASHES LHS RHS) [FUNCTION] · src
(COMBINE-HASHES-ORDER-INDEPENDENT LHS RHS) [FUNCTION] · src
Package COALTON/HASHMAP
Immutable hash array mapped trie maps from keys to values.
Types
HashMap [TYPE] · src
(HashMap HmNode :A :B)
Immutable map (also known as a dictionary or dict) using hashes. Implemented as a hash array mapped trie data structure.
Instances
(Eq :K) (Eq :V) (Hash :K) ⇒ Eq (HashMap :K :V)(Hash :K) (Hash :V) ⇒ Hash (HashMap :K :V)(Hash :K) (Show :K) (Show :V) ⇒ Show (HashMap :K :V)Functor (HashMap :KEY)Hash :K ⇒ FromIterator (HashMap :K :V) (Tuple :K :V)Hash :K ⇒ Monoid (HashMap :K :V)Hash :K ⇒ Semigroup (HashMap :K :V)Hash :KEY ⇒ FromAssociationComprehension (HashMap :KEY :VALUE) :KEY :VALUE (HashMap :KEY :VALUE)Hash :KEY ⇒ FromItemizedAssociation (HashMap :KEY :VALUE) :KEY :VALUE (HashMap :KEY :VALUE)IntoIterator (HashMap :K :V) (Tuple :K :V)RuntimeRepr (HashMap :|0| :|1|)
Values
(ADJOIN HM KEY VAL) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * :K * :V → HashMap :K :V
Returns a hashmap that has a new entry of (key, val) added to hm.
If hm alreay contains an entry with key, however, hm is returned as is.
(COUNT HM) [FUNCTION] · src
∀ :K :V. HashMap :K :V → Integer
Returns the number of entries in HM.
(DIFFERENCE A B) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * HashMap :K :V → HashMap :K :V
Returns a HashMap that contains mappings in a but not in b.
(EMPTY? HM) [FUNCTION] · src
∀ :K :V. HashMap :K :V → Boolean
Returns True if a hashmap HM is empty, False if not.
(ENTRIES HM) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V → Iterator (Tuple :K :V)
Returns an iterator over all entries in hashmap hm.
(INSERT HM KEY VAL) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * :K * :V → HashMap :K :V
Returns a hashmap that has a new entry of (KEY, VAL) added to HM. If HM contains an entry with KEY, the new hashmap replaces it for the new entry.
(INTERSECTION A B) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * HashMap :K :V → HashMap :K :V
Construct a HashMap containing all the mappings whose key is in both A and B.
The entries from A remains in the result.
(KEYS HM) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V → Iterator :K
Returns an iterator over all the keys in a hashmap hm.
(LOOKUP HM KEY) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * :K → Optional :V
Returns a value associated with KEY in the hashmap HM.
(MODIFY HM KEY F) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * :K * (:V → :V) → HashMap :K :V
Modify the value at KEY with F. Returns the modified HashMap.
(MODIFY-GET HM KEY F) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * :K * (:V → :V) → HashMap :K :V * Optional :V
Modify the value at KEY with F. Returns the modified HashMap and the
new value, if the key was found.
(REMOVE HM KEY) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * :K → HashMap :K :V
Returns a hashmap that is identical to HM except the entry with KEY is removed. If HM does not contain an entry with KEY, HM is returned as is.
(REPLACE HM KEY VAL) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * :K * :V → HashMap :K :V
Returns a hashmap where the value associated with key is replaced
with val. If hm does not contain an entry with key, hm is
returned as is.
(UNION A B) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * HashMap :K :V → HashMap :K :V
Construct a HashMap containing all the mappings from A and B.
If A and B contain mappings X -> A’ and X -> B’, the former mapping is kept.
The operation is associative, but not commutative.
(UPDATE HM KEY F) [FUNCTION] · src
∀ :K :V :A. Hash :K ⇒ HashMap :K :V * :K * (Optional :V → Optional :V * :A) → HashMap :K :V * :A
Generic update/filter function. Takes a KEY and a F. F is passed
NONE if KEY is not found, (Some KEY) if it is found. F returns two values:
an (Optional :v) replacement value and an auxiliary result :a. If the
first return value is NONE, then the KEY entry is cleared from the hashmap.
If it is (SOME v), then the KEY entry is updated to V. The second return
value, :a, is returned from update along with the modified HashMap.
(VALUES-ITER HM) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V → Iterator :V
Returns an iterator over all the values in a hashmap hm.
(XOR A B) [FUNCTION] · src
∀ :K :V. Hash :K ⇒ HashMap :K :V * HashMap :K :V → HashMap :K :V
Returns a HashMap that contains mappings either in a or in b,
but not in both.
EMPTY [VALUE] · src
∀ :K :V. HashMap :K :V
An empty HashMap
Package COALTON/HASHTABLE
Mutable hash tables keyed by Coalton Hash and Eq instances.
Types
HashTable [TYPE] · src
A mutable hash table.
Instances
(Hash :KEY) (Eq :VALUE) ⇒ Eq (HashTable :KEY :VALUE)(Hash :KEY) (Hash :VALUE) ⇒ Hash (HashTable :KEY :VALUE)(Show :KEY) (Show :VALUE) ⇒ Show (HashTable :KEY :VALUE)Hash :KEY ⇒ Default (HashTable :KEY :VALUE)Hash :KEY ⇒ FromAssociationComprehension (HashTable :KEY :VALUE) :KEY :VALUE (HashTable :KEY :VALUE)Hash :KEY ⇒ FromItemizedAssociation (HashTable :KEY :VALUE) :KEY :VALUE (HashTable :KEY :VALUE)Hash :KEY ⇒ FromIterator (HashTable :KEY :VALUE) (Tuple :KEY :VALUE)IntoIterator (HashTable :KEY :VALUE) (Tuple :KEY :VALUE)RuntimeRepr (HashTable :|0| :|1|)
Values
(COUNT TABLE) [FUNCTION] · src
∀ :KEY :VALUE. HashTable :KEY :VALUE → Integer
Returns the number of entries in TABLE
(ENTRIES TABLE) [FUNCTION] · src
∀ :KEY :VALUE. HashTable :KEY :VALUE → Iterator (Tuple :KEY :VALUE)
Returns the key-values pairs as a list.
(EXTEND! TABLE ITER) [FUNCTION] · src
∀ :KEY :VALUE :CONTAINER. (Hash :KEY) (IntoIterator :CONTAINER (Tuple :KEY :VALUE)) ⇒ HashTable :KEY :VALUE * :CONTAINER → Void
Insert all of the key value pairs from ITER into TABLE, overwriting duplicate keys.
(GET TABLE KEY) [FUNCTION] · src
∀ :KEY :VALUE. Hash :KEY ⇒ HashTable :KEY :VALUE * :KEY → Optional :VALUE
Lookup KEY in TABLE
(KEYS TABLE) [FUNCTION] · src
∀ :KEY :VALUE. HashTable :KEY :VALUE → Iterator :KEY
Returns the keys in TABLE as a list
(NEW) [FUNCTION] · src
∀ :KEY :VALUE. Hash :KEY ⇒ Void → HashTable :KEY :VALUE
Create a new empty hashtable
(REMOVE! TABLE KEY) [FUNCTION] · src
∀ :KEY :VALUE. Hash :KEY ⇒ HashTable :KEY :VALUE * :KEY → Void
Remove the entry at KEY from TABLE
(SET! TABLE KEY VALUE) [FUNCTION] · src
∀ :KEY :VALUE. Hash :KEY ⇒ HashTable :KEY :VALUE * :KEY * :VALUE → Void
Set KEY to VALUE in TABLE
(VALUES-ITER TABLE) [FUNCTION] · src
∀ :KEY :VALUE. HashTable :KEY :VALUE → Iterator :VALUE
Returns the values in TABLE as a list
(WITH-CAPACITY CAPACITY) [FUNCTION] · src
∀ :KEY :VALUE. Hash :KEY ⇒ Integer → HashTable :KEY :VALUE
Create a new empty hashtable with a given capacity
Package COALTON/ITERATOR
Types
Iterator [TYPE] · src
A forward-moving pointer into an ordered sequence of :ELTs
Instances
Functor IteratorIntoIterator (Iterator :ELT) :ELTRuntimeRepr (Iterator :|0|)
Classes
FromIterator [CLASS] · src
FromIterator :CONTAINER :ELT
Methods:
COLLECT! :: Iterator :ELT → :CONTAINER
Instances
RuntimeRepr :A ⇒ FromIterator (Seq :A) :AOrd :KEY ⇒ FromIterator (OrdMap :KEY :VALUE) (Tuple :KEY :VALUE)Ord :ELT ⇒ FromIterator (OrdTree :ELT) :ELTFromIterator (Queue :A) :AHash :K ⇒ FromIterator (HashMap :K :V) (Tuple :K :V)Hash :KEY ⇒ FromIterator (HashTable :KEY :VALUE) (Tuple :KEY :VALUE)FromIterator (Slice :A) :AFromIterator String CharFromIterator (Vector :A) :AFromIterator (List :ELT) :ELTFromIterator :CONTAINER :ELT ⇒ FromIterator (Result :ERR :CONTAINER) (Result :ERR :ELT)FromIterator :CONTAINER :ELT ⇒ FromIterator (Optional :CONTAINER) (Optional :ELT)
IntoIterator [CLASS] · src
IntoIterator :CONTAINER :ELT
Containers which can be converted into iterators.
INTO-ITER must not mutate its argument, only produce a “view” into it.
Methods:
INTO-ITER :: :CONTAINER → Iterator :ELT
Instances
IntoIterator (Seq :A) :AIntoIterator (OrdMap :KEY :VALUE) (Tuple :KEY :VALUE)IntoIterator (OrdTree :ELT) :ELTIntoIterator (Queue :A) :AIntoIterator (HashMap :K :V) (Tuple :K :V)IntoIterator (HashTable :KEY :VALUE) (Tuple :KEY :VALUE)IntoIterator (Slice :A) :AIntoIterator String CharIntoIterator (Vector :A) :AIntoIterator (List :ELT) :ELTIntoIterator (Result :ERR :ELT) :ELTIntoIterator (Optional :A) :AIntoIterator (Iterator :ELT) :ELT
Values
(AND! ITER) [FUNCTION] · src
Returns True if all iterator elements are True. May not consume the entire iterator. Returns True on an empty iterator.
(ANY! GOOD? ITER) [FUNCTION] · src
∀ :ELT. (:ELT → Boolean) * Iterator :ELT → Boolean
Return True as soon as any element of ITER is GOOD?, or False if none of them are.
Returns False if ITER is empty.
(CHAIN! ITER1 ITER2) [FUNCTION] · src
∀ :ELT. Iterator :ELT * Iterator :ELT → Iterator :ELT
Yield all the elements of ITER1 followed by all the elements from ITER2.
(COUNT! ITER) [FUNCTION] · src
Return the number of elements in ITER.
This operation could be called length!, but count! emphasizes the fact that it consumes ITER, and
afterwards, ITER will be exhausted.
(COUNT-FOREVER) [FUNCTION] · src
∀ :NUM. (Num :NUM) (Ord :NUM) ⇒ Void → Iterator :NUM
An infinite iterator which starts at 0 and counts upwards by 1.
(DOWN-FROM LIMIT) [FUNCTION] · src
∀ :NUM. (Num :NUM) (Ord :NUM) ⇒ :NUM → Iterator :NUM
An iterator which begins below the provided limit and counts down through and including zero.
(ELEMENTWISE-HASH! ITER) [FUNCTION] · src
∀ :ELT. Hash :ELT ⇒ Iterator :ELT → Hash
Hash an iterator by combining the hashes of all its elements.
The empty iterator will hash as 0.
(ELEMENTWISE-MATCH! SAME? LEFT RIGHT) [FUNCTION] · src
∀ :ELT. (:ELT * :ELT → Boolean) * Iterator :ELT * Iterator :ELT → Boolean
Are LEFT and RIGHT elementwise-identical under SAME?
True if, for every pair of elements (A B) in (LEFT RIGHT), (same? A B) is True, and LEFT and RIGHT have the same length.
(ELEMENTWISE==! LEFT RIGHT) [FUNCTION] · src
∀ :ELT. Eq :ELT ⇒ Iterator :ELT * Iterator :ELT → Boolean
Is every element of the first iterator `==’ to the corresponding element of the second?
True if two iterators have the same length, and for every N, the Nth element of the first iterator is `==’ to the Nth element of the second iterator.
(ENUMERATE! ITER) [FUNCTION] · src
∀ :ELT. Iterator :ELT → Iterator (Tuple UFix :ELT)
Pair successive zero-based incides with elements from ITER
(EVERY! GOOD? ITER) [FUNCTION] · src
∀ :ELT. (:ELT → Boolean) * Iterator :ELT → Boolean
Return True if every element of ITER is GOOD?, or False as soon as any element is not GOOD?.
Returns True if ITER is empty.
(FILTER! KEEP? ITER) [FUNCTION] · src
∀ :ELT. (:ELT → Boolean) * Iterator :ELT → Iterator :ELT
Return an iterator over the elements from ITER for which KEEP? returns true.
(FILTER-MAP! F ITER) [FUNCTION] · src
∀ :A :B. (:A → Optional :B) * Iterator :A → Iterator :B
Map an iterator, retaining only the elements where F returns SOME.
(FIND! THIS? ITER) [FUNCTION] · src
∀ :ELT. (:ELT → Boolean) * Iterator :ELT → Optional :ELT
Return the first element of ITER for which THIS? returns True, or None if no element matches.
(FIND-MAP! F ITER) [FUNCTION] · src
∀ :A :B. (:A → Optional :B) * Iterator :A → Optional :B
Return the first element of (map F ITER) for which F returns Some.
(FLAT-MAP! FUNC ITER) [FUNCTION] · src
∀ :A :B. (:A → Iterator :B) * Iterator :A → Iterator :B
Flatten! wrapped around map.
(FLATTEN! ITERS) [FUNCTION] · src
∀ :ELT. Iterator (Iterator :ELT) → Iterator :ELT
Yield all the elements from each of the ITERS in order.
(FOLD! FUNC INIT ITER) [FUNCTION] · src
∀ :STATE :ELT. (:STATE * :ELT → :STATE) * :STATE * Iterator :ELT → :STATE
Tail recursive in-order fold. Common Lisp calls this operation reduce.
If ITER is empty, returns INIT. Otherwise, calls (FUNC STATE ITEM) for each ITEM of ITER to produce a new STATE, using INIT as the first STATE.
(FOR-EACH! THUNK ITER) [FUNCTION] · src
∀ :ELT. (:ELT → Void) * Iterator :ELT → Void
Call THUNK on each element of ITER in order for side effects. Discard values returned by THUNK.
(INDEX-OF! THIS? ITER) [FUNCTION] · src
∀ :ELT. (:ELT → Boolean) * Iterator :ELT → Optional UFix
Return the zero-based index of the first element of ITER for which THIS? is True, or None if no element matches.
(INTERLEAVE! LEFT RIGHT) [FUNCTION] · src
∀ :A. Iterator :A * Iterator :A → Iterator :A
Return an iterator of interleaved elements from LEFT and RIGHT which terminates as soon as both LEFT and RIGHT do.
If one iterator terminates before the other, elements from the longer iterator will be yielded without interleaving. (interleave empty ITER) is equivalent to (id ITER).
(LAST! ITER) [FUNCTION] · src
∀ :A. Iterator :A → Optional :A
Yields the last element of ITER, completely consuming it.
(MAP-WHILE! F ITER) [FUNCTION] · src
∀ :A :B. (:A → Optional :B) * Iterator :A → Iterator :B
Map an iterator, stopping early if F returns NONE.
(MAX! ITER) [FUNCTION] · src
∀ :NUM. Ord :NUM ⇒ Iterator :NUM → Optional :NUM
Return the most-positive element of ITER, or None if ITER is empty.
(MAXIMIZE-BY! F ITER) [FUNCTION] · src
∀ :ELT :A. Ord :A ⇒ (:ELT → :A) * Iterator :ELT → Optional :ELT
For a function F, which maps the iterator, return the element of ITER where (F ELT) is the most-positive.
Return `None’ if ITER is empty.
(MCONCAT! ITER) [FUNCTION] · src
∀ :A. Monoid :A ⇒ Iterator :A → :A
Fold an iterator of monoids into a single element.
(MCONCATMAP! FUNC ITER) [FUNCTION] · src
∀ :B :A. Monoid :A ⇒ (:B → :A) * Iterator :B → :A
Map an iterator to an iterator of monoids, and then fold that iterator into a single element.
(MIN! ITER) [FUNCTION] · src
∀ :NUM. Ord :NUM ⇒ Iterator :NUM → Optional :NUM
Return the most-negative element of ITER, or None if ITER is empty.
(MINIMIZE-BY! F ITER) [FUNCTION] · src
∀ :ELT :A. Ord :A ⇒ (:ELT → :A) * Iterator :ELT → Optional :ELT
For a function F, which maps the iterator, return the element of ITER where (F ELT) is the most-negative.
Return `None’ if ITER is empty.
(NEW F) [FUNCTION] · src
∀ :ELT. (Void → Optional :ELT) → Iterator :ELT
Create a new iterator from a function that yields elements.
(NEXT! ITER) [FUNCTION] · src
∀ :ELT. Iterator :ELT → Optional :ELT
Advance ITER, returning its next yielded value, or None if the iterator is exhausted.
Behavior is undefined if two threads concurrently call next! on the same iterator without a lock. Note that
most of the operators defined on iterators call next! internally, or create new iterators which will call
next! on their inputs.
(ONCE ITEM) [FUNCTION] · src
∀ :ITEM. :ITEM → Iterator :ITEM
Yield item once.
(OPTIMIZE! BETTER? ITER) [FUNCTION] · src
∀ :ELT. (:ELT * :ELT → Boolean) * Iterator :ELT → Optional :ELT
For an order BETTER? which returns True if its first argument is better than its second argument, return the best element of ITER.
Return None if ITER is empty.
(OPTIMIZE-BY! BETTER? F ITER) [FUNCTION] · src
∀ :B :A. (:B * :B → Boolean) * (:A → :B) * Iterator :A → Optional :A
For an order BETTER? which returns True if its first argument is better than its second argument, return the element of ITER where (F ELT) is the best.
Return None if ITER is empty.
(OR! ITER) [FUNCTION] · src
Returns True if any iterator elements are True. May not consume the entire iterator. Returns False on an empty iterator.
(PAIR-WITH! FUNC KEYS) [FUNCTION] · src
∀ :KEY :VALUE. (:KEY → :VALUE) * Iterator :KEY → Iterator (Tuple :KEY :VALUE)
Returns an iterator over tuples whose FSTs are elements from KEYS, and whose SNDs are the results of applying FUNC to those KEYS.
(RANGE-DECREASING STEP START END) [FUNCTION] · src
∀ :NUM. (Num :NUM) (Ord :NUM) ⇒ :NUM * :NUM * :NUM → Iterator :NUM
A range which begins below START and counts down through and including END by STEP.
Equivalent to reversing range-increasing
(RANGE-INCREASING STEP START END) [FUNCTION] · src
∀ :NUM. (Num :NUM) (Ord :NUM) ⇒ :NUM * :NUM * :NUM → Iterator :NUM
An iterator which begins at START and yields successive elements spaced by STEP, stopping before END.
(RECURSIVE-ITER SUCC DONE? START) [FUNCTION] · src
∀ :ELT. (:ELT → :ELT) * (:ELT → Boolean) * :ELT → Iterator :ELT
An iterator which yields first START, then (SUCC START), then (SUCC (SUCC START)), and so on, stopping as soon as such a value is done?.
Beware off-by-one errors: the first value which is done? is not yielded. If `(done? start)’ is true, the
iterator is empty.
(REMOVE-DUPLICATES! ITER) [FUNCTION] · src
∀ :ELT. Hash :ELT ⇒ Iterator :ELT → Iterator :ELT
Yield unique elements from ITER in order of first appearance.
(REPEAT ITEM) [FUNCTION] · src
∀ :ITEM. :ITEM → Iterator :ITEM
Yield ITEM over and over, infinitely.
(REPEAT-FOR ITEM COUNT) [FUNCTION] · src
∀ :ITEM. :ITEM * UFix → Iterator :ITEM
Yield ITEM COUNT times, then stop.
(SIZE-HINT ITER) [FUNCTION] · src
∀ :ELT. Iterator :ELT → Optional UFix
(SUM! ITER) [FUNCTION] · src
∀ :NUM. Num :NUM ⇒ Iterator :NUM → :NUM
Add together all the elements of ITER.
(TAKE! COUNT ITER) [FUNCTION] · src
∀ :ELT. UFix * Iterator :ELT → Iterator :ELT
An Iterator which yields at most COUNT elements from ITER.
(UNWRAPPED! ITER) [FUNCTION] · src
∀ :WRAPPER :ELT. Unwrappable :WRAPPER ⇒ Iterator (:WRAPPER :ELT) → Iterator :ELT
(UP-THROUGH LIMIT) [FUNCTION] · src
∀ :NUM. (Num :NUM) (Ord :NUM) ⇒ :NUM → Iterator :NUM
An iterator which begins at zero and counts up through and including LIMIT.
(UP-TO LIMIT) [FUNCTION] · src
∀ :NUM. (Num :NUM) (Ord :NUM) ⇒ :NUM → Iterator :NUM
An iterator which begins at zero and counts up to, but not including, LIMIT.
(WITH-SIZE F SIZE) [FUNCTION] · src
∀ :ELT. (Void → Optional :ELT) * UFix → Iterator :ELT
(ZIP! LEFT RIGHT) [FUNCTION] · src
∀ :LEFT :RIGHT. Iterator :LEFT * Iterator :RIGHT → Iterator (Tuple :LEFT :RIGHT)
Return an iterator of tuples contining elements from two iterators.
(ZIP-WITH! F LEFT RIGHT) [FUNCTION] · src
∀ :LEFT :RIGHT :OUT. (:LEFT * :RIGHT → :OUT) * Iterator :LEFT * Iterator :RIGHT → Iterator :OUT
Return an iterator of elements from LEFT and RIGHT which terminates as soon as either LEFT or RIGHT does.
EMPTY [VALUE] · src
∀ :ANY. Iterator :ANY
Yields nothing; stops immediately
Package COALTON/LISPARRAY
Fixed-size one-dimensional Common Lisp arrays for interop and efficient storage.
Types
LispArray [TYPE] · src
A one-dimensional, non-resizable array of elements.
These arrays are represented as possibly specialized (cl:simple-array <type> (cl:*)) and are meant to be used as a tool either to interface with Lisp code or to implement efficient data structures. One should consult Vector or Seq for more general sequential data structure needs.
Whether or not the arrays are specialized depends on the underlying Lisp implementation. Consult cl:upgraded-array-element-type to determine whether LispArray may get specialized.
Instances
Eq :T ⇒ Eq (LispArray :T)Foldable LispArrayInto (LispArray :T) (List :T)RuntimeRepr :T ⇒ FromCollectionComprehension (LispArray :T) :T (LispArrayBuilder :T)RuntimeRepr :T ⇒ FromItemizedCollection (LispArray :T) :T (LispArray :T)RuntimeRepr :T ⇒ Into (List :T) (LispArray :T)RuntimeRepr :T ⇒ Iso (LispArray :T) (List :T)RuntimeRepr :T ⇒ RandomAccess (LispArray :T) :TRuntimeRepr :T ⇒ RuntimeRepr (LispArray :T)Show :A ⇒ Show (LispArray :A)
Values
(AREF V I) [FUNCTION] · src
∀ :T. LispArray :T * UFix → :T
Read the ith value of the LispArray v.
(COPY V) [FUNCTION] · src
∀ :T. LispArray :T → LispArray :T
Make a deep copy of the LispArray v.
(LENGTH V) [FUNCTION] · src
Return the length of the LispArray v.
(MAKE N X) [FUNCTION] · src
∀ :T. RuntimeRepr :T ⇒ UFix * :T → LispArray :T
Make a new LispArray of length n initialized to x.
If the type of x represents a specialized array
(MAKE-UNINITIALIZED N) [FUNCTION] · src
∀ :T. RuntimeRepr :T ⇒ UFix → LispArray :T
Make a new LispArray of length n that can store elements of type :t.
WARNING: The consequences are undefined if an uninitialized element is read before being set.
(SET! V I X) [FUNCTION] · src
∀ :T. LispArray :T * UFix * :T → Void
Set the ith value of the LispArray v to x.
Package COALTON/LIST
Immutable singly linked lists and list-processing utilities.
Values
(ALL F? XS) [FUNCTION] · src
∀ :A. (:A → Boolean) * List :A → Boolean
Returns True if every element in xs matches f?.
(ANY F? L) [FUNCTION] · src
∀ :A. (:A → Boolean) * List :A → Boolean
Returns True if at least one element in xs matches f?.
(APPEND XS YS) [FUNCTION] · src
∀ :A. List :A * List :A → List :A
Appends two lists together and returns a new list.
(CAR X) [FUNCTION] · src
∀ :A. List :A → :A
Return the traditional car of a list. This function is partial.
(CDR XS) [FUNCTION] · src
Return the traditional cdr of a list.
(COMBS L) [FUNCTION] · src
∀ :A. List :A → List (List :A)
Compute a list of all combinations of elements of l. This function sometimes goes by the name “power set” or “subsets”.
The ordering of elements of l is preserved in the ordering of elements in each list produced by this function.
(COMBSOF N L) [FUNCTION] · src
∀ :A. UFix * List :A → List (List :A)
Produce a list of size-N subsets of l.
The ordering of elements of l is preserved in the ordering of elements in each list produced by (combsOf n l).
This function is equivalent to all size-n elements of (combs l).
(CONCAT XS) [FUNCTION] · src
∀ :A. List (List :A) → List :A
Appends a list of lists together into a single new list.
(CONCATMAP F XS) [FUNCTION] · src
∀ :A :B. (:A → List :B) * List :A → List :B
Apply F to each element in XS and concatenate the results.
(CONS? XS) [FUNCTION] · src
Returns TRUE if XS is a non-empty list.
(COUNTBY F THINGS) [FUNCTION] · src
∀ :A. (:A → Boolean) * List :A → UFix
Count the number of items in THINGS that satisfy the predicate F.
(DIFFERENCE XS YS) [FUNCTION] · src
∀ :A. Eq :A ⇒ List :A * List :A → List :A
Returns a new list with the first occurrence of each element in ys removed from xs.
(DROP N XS) [FUNCTION] · src
∀ :A. UFix * List :A → List :A
Returns a list with the first N elements removed.
(ELEMINDEX X XS) [FUNCTION] · src
∀ :A. Eq :A ⇒ :A * List :A → Optional UFix
(EQUIVALENCE-CLASSES L) [FUNCTION] · src
∀ :A. Eq :A ⇒ List :A → List (List :A)
(EQUIVALENCE-CLASSES-BY F L) [FUNCTION] · src
∀ :A. (:A * :A → Boolean) * List :A → List (List :A)
Break a list into a list of equivalence classes according to an equivalence relation.
(FILTER F XS) [FUNCTION] · src
∀ :A. (:A → Boolean) * List :A → List :A
Returns a new list containing every element of XS that matches the predicate function F in the same order.
(FIND F XS) [FUNCTION] · src
∀ :A. (:A → Boolean) * List :A → Optional :A
Returns the first element in a list matching the predicate function F.
(FINDINDEX F XS) [FUNCTION] · src
∀ :A. (:A → Boolean) * List :A → Optional UFix
Returns the index of the first element matching the predicate function F.
(HEAD L) [FUNCTION] · src
Returns the first element of a list.
(INDEX I XS) [FUNCTION] · src
∀ :A. UFix * List :A → Optional :A
Returns the Ith element of a list.
(INIT L) [FUNCTION] · src
Returns every element except the last in a list.
(INSERT E LS) [FUNCTION] · src
∀ :A. Ord :A ⇒ :A * List :A → List :A
Inserts an element into a list at the first place it is less than or equal to the next element.
(INSERTBY CMP X YS) [FUNCTION] · src
∀ :A. (:A * :A → Ordering) * :A * List :A → List :A
Generic version of insert
(INSERTIONS A L) [FUNCTION] · src
∀ :A. :A * List :A → List (List :A)
Produce a list of copies of l, each with A inserted at a possible position.
(insertions 0 (make-list 1 2))
;; => ((0 1 2) (1 0 2) (1 2 0))
(INTERCALATE XS XSS) [FUNCTION] · src
∀ :A. List :A * List (List :A) → List :A
Intersperse xs into xss and then concatenate the result.
(INTERSECTION XS YS) [FUNCTION] · src
∀ :A. Eq :A ⇒ List :A * List :A → List :A
Returns elements which occur in both lists. Does not return duplicates and does not guarantee order.
(INTERSPERSE E XS) [FUNCTION] · src
Returns a new list by inserting e between every element of xs.
(LAST L) [FUNCTION] · src
Returns the last element of a list.
(LENGTH L) [FUNCTION] · src
Returns the length of a list.
(LOOKUP E XS) [FUNCTION] · src
∀ :A :B. Eq :A ⇒ :A * List (Tuple :A :B) → Optional :B
Returns the value of the first (key, value) tuple in XS where the key matches E.
(MAXIMUM L) [FUNCTION] · src
∀ :A. Ord :A ⇒ List :A → Optional :A
Returns a greatest element of a list, or None.
(MEMBER E XS) [FUNCTION] · src
∀ :A. Eq :A ⇒ :A * List :A → Boolean
Returns true if any element of XS is equal to E.
(MINIMUM L) [FUNCTION] · src
∀ :A. Ord :A ⇒ List :A → Optional :A
Returns a least element of a list, or None.
(NTH N L) [FUNCTION] · src
Like INDEX, but errors if the index is not found.
(NTH-CDR N L) [FUNCTION] · src
∀ :A. UFix * List :A → List :A
Returns the nth-cdr of a list.
(NULL? XS) [FUNCTION] · src
Returns TRUE if XS is an empty list.
(OPTIMUMBY F XS) [FUNCTION] · src
∀ :A. (:A * :A → Boolean) * List :A → Optional :A
Returns an optimum according to a total order.
(PARTITION F XS) [FUNCTION] · src
∀ :A. (:A → Boolean) * List :A → Tuple (List :A) (List :A)
Splits a list into two new lists. The first list contains elements matching predicate F.
(PERMS L) [FUNCTION] · src
∀ :A. List :A → List (List :A)
Produce all permutations of the list L.
(PRODUCT XS) [FUNCTION] · src
Returns the product of xs.
(RANGE START END) [FUNCTION] · src
∀ :INT. (Num :INT) (Ord :INT) ⇒ :INT * :INT → List :INT
Returns a list containing the numbers from START to END inclusive, counting by 1.
COALTON-USER> (coalton (range 1 5))
(1 2 3 4 5)
COALTON-USER> (coalton (range 5 2))
(5 4 3 2)
(REMOVE X YS) [FUNCTION] · src
∀ :A. Eq :A ⇒ :A * List :A → List :A
Return a new list with the first element equal to x removed.
(REMOVE-DUPLICATES XS) [FUNCTION] · src
∀ :A. Eq :A ⇒ List :A → List :A
Returns a new list without duplicate elements.
(REMOVE-IF PRED XS) [FUNCTION] · src
∀ :A. (:A → Boolean) * List :A → List :A
Return a new list with the first element for which PRED is True is removed.
(REPEAT N X) [FUNCTION] · src
Returns a list with the same value repeated multiple times.
(REVERSE XS) [FUNCTION] · src
Returns a new list containing the same elements in reverse order.
(SINGLETON X) [FUNCTION] · src
∀ :A. :A → List :A
Returns a list containing one element.
(SINGLETON? XS) [FUNCTION] · src
Is xs a list containing exactly one element?
(SORT XS) [FUNCTION] · src
∀ :A. Ord :A ⇒ List :A → List :A
Sort xs.
(SORTBY CMP XS) [FUNCTION] · src
∀ :A. (:A * :A → Ordering) * List :A → List :A
Sort xs by a custom comparison function cmp.
(SPLIT-AROUND N XS) [FUNCTION] · src
∀ :A. UFix * List :A → Tuple3 (List :A) (Optional :A) (List :A)
Splits a list around N into a Tuple of the first N elements, the element at index N, and a tail of all remaining elements. N must be a valid index.
(SPLIT-AT N XS) [FUNCTION] · src
∀ :A. UFix * List :A → Tuple (List :A) (List :A)
Splits a list into a Tuple of the first N elements and all remaining elements. The return value is equivalent to (Tuple (take n xs) (drop n xs).
(SUM XS) [FUNCTION] · src
Returns the sum of xs.
(TAIL L) [FUNCTION] · src
∀ :A. List :A → Optional (List :A)
Returns every element except the first in a list.
(TAKE N XS) [FUNCTION] · src
∀ :A. UFix * List :A → List :A
Returns the first N elements of a list.
(TRANSPOSE XS) [FUNCTION] · src
∀ :A. List (List :A) → List (List :A)
Transposes a matrix represented by a list of lists.
(UNION XS YS) [FUNCTION] · src
∀ :A. Eq :A ⇒ List :A * List :A → List :A
Returns a new list with the elements from both XS and YS and without duplicates.
(ZIP XS YS) [FUNCTION] · src
∀ :A :B. List :A * List :B → List (Tuple :A :B)
Builds a list of tuples with the elements of XS and YS.
(ZIPWITH F XS YS) [FUNCTION] · src
∀ :A :B :C. (:A * :B → :C) * List :A * List :B → List :C
Builds a new list by calling f with elements of xs and ys.
(ZIPWITH3 F XS YS ZS) [FUNCTION] · src
∀ :A :B :C :D. (:A * :B * :C → :D) * List :A * List :B * List :C → List :D
Build a new list by calling F with elements of XS, YS and ZS
(ZIPWITH4 F AS BS CS DS) [FUNCTION] · src
∀ :A :B :C :D :E. (:A * :B * :C * :D → :E) * List :A * List :B * List :C * List :D → List :E
Build a new list by calling F with elements of AS, BS, CS and DS
(ZIPWITH5 F AS BS CS DS ES) [FUNCTION] · src
∀ :A :B :C :D :E :F. (:A * :B * :C * :D * :E → :F) * List :A * List :B * List :C * List :D * List :E → List :F
Build a new list by calling F with elements of AS, BS, CS, DS and ES
Macros
MAKE (&REST ELEMENTS) [MACRO]
Make a homogeneous list of elements. Synonym for coalton:make-list.
Package COALTON/MATH/ARITH
Classes
Dividable [CLASS] · src
Dividable :ARG-TYPE :RES-TYPE
The representation of a type such that division within that type possibly results in another type. For instance,
(Dividable Integer Fraction)
establishes that division of two Integers can result in a Fraction, whereas
(Dividable F32 F32)
establishes that division of two F32s can result in a F32.
Note that Dividable does not establish a default result type; you must constrain the result type yourself.
The function general/ is partial, and will error produce a run-time error if the divisor is zero.
Methods:
GENERAL/ :: :ARG-TYPE * :ARG-TYPE → :RES-TYPE
Instances
Reciprocable [CLASS] · src
Num :A ⇒ Reciprocable :A
Any number with a multiplicative inverse (reciprocal) where:
1 = (* (reciprocal x) x) = (* x (reciprocal x))
(/ x y) = (* x (reciprocal y))
If no reciprocal exists for an element, produce a run-time error (e.g., zero).
Methods:
/ :: :A * :A → :ARECIPROCAL :: :A → :A
Instances
Reciprocable RealAlgebraicReciprocable CRealReciprocable Big-FloatReciprocable :T ⇒ Reciprocable (Hyperdual :T)Reciprocable :T ⇒ Reciprocable (Dual :T)(ComplexComponent :A) (Reciprocable :A) ⇒ Reciprocable (Complex :A)Reciprocable FractionReciprocable F64Reciprocable F32
Transfinite [CLASS] · src
Transfinite :A
Numeric type with a value for (positive) infinity and/or NaN.
Methods:
Instances
Values
(1+ NUM) [FUNCTION] · src
∀ :NUM. Num :NUM ⇒ :NUM → :NUM
Increment num.
(1- NUM) [FUNCTION] · src
∀ :NUM. Num :NUM ⇒ :NUM → :NUM
Decrement num.
(ABS X) [FUNCTION] · src
∀ :A. (Ord :A) (Num :A) ⇒ :A → :A
Absolute value of x.
(ASH X N) [FUNCTION] · src
Compute the “arithmetic shift” of x by n.
(FINITE? X) [FUNCTION] · src
∀ :A. Transfinite :A ⇒ :A → Boolean
Neither infinite or NaN.
(NEGATE X) [FUNCTION] · src
∀ :A. Num :A ⇒ :A → :A
The negation, or additive inverse, of x.
(NEGATIVE? X) [FUNCTION] · src
∀ :A. (Num :A) (Ord :A) ⇒ :A → Boolean
Is x negative?
(NONNEGATIVE? X) [FUNCTION] · src
∀ :A. (Num :A) (Ord :A) ⇒ :A → Boolean
Is x not negative?
(NONPOSITIVE? X) [FUNCTION] · src
∀ :A. (Num :A) (Ord :A) ⇒ :A → Boolean
Is x not positive?
(NONZERO? X) [FUNCTION] · src
Is x not zero?
(POSITIVE? X) [FUNCTION] · src
∀ :A. (Num :A) (Ord :A) ⇒ :A → Boolean
Is x positive?
(SIGN X) [FUNCTION] · src
∀ :A :B. (Ord :A) (Num :A) (Num :B) ⇒ :A → :B
The sign of x, where (sign 0) = 0.
(ZERO? X) [FUNCTION] · src
Is x zero?
NEGATIVE-INFINITY [VALUE] · src
∀ :A. (Transfinite :A) (Num :A) ⇒ :A
Package COALTON/MATH/BOUNDED
Classes
Bounded [CLASS] · src
Bounded :A
Types which have a maximum and minumum bound.
Methods:
MINBOUND :: :AMAXBOUND :: :A
Instances
Package COALTON/MATH/COMPLEX
Types
Complex [TYPE] · src
A complex number with a real and imaginary component.
This object does not have any public constructors. Instead, use the
function complex of the ComplexComponent type class.
A Complex object may either have a native or constructed
representation. See the ComplexComponent type class for allowed
component types.
Instances
(ComplexComponent :A) (Into :A CReal) ⇒ Into (Complex :A) (Complex CReal)(ComplexComponent :A) (Reciprocable :A) ⇒ Reciprocable (Complex :A)(ComplexComponent :T) (Into :T (Hyperdual :T)) ⇒ Into (Complex :T) (Complex (Hyperdual :T))(RuntimeRepr :T) (Show :T) ⇒ Show (Complex :T)ComplexComponent :A ⇒ Eq (Complex :A)ComplexComponent :A ⇒ Into :A (Complex :A)ComplexComponent :A ⇒ Num (Complex :A)Elementary :A ⇒ Exponentiable (Complex :A)Elementary :A ⇒ Radical (Complex :A)Elementary :A ⇒ Trigonometric (Complex :A)FFTCyclicGroup (Complex F32)FFTCyclicGroup (Complex F64)FFTField (Complex F32)FFTField (Complex F64)FFTGroup (Complex F32)FFTGroup (Complex F64)FFTRing (Complex F32)FFTRing (Complex F64)RuntimeRepr :T ⇒ RuntimeRepr (Complex :T)
Classes
ComplexComponent [CLASS] · src
Num :A ⇒ ComplexComponent :A
A type class for describing complex component types. This type class
also encodes the construction and projection of Complex data types.
Methods:
Instances
Values
(CONJUGATE Z) [FUNCTION] · src
∀ :A. ComplexComponent :A ⇒ Complex :A → Complex :A
The complex conjugate. If $z=a+bi$ then the conjugate $\bar z=a-bi$.
(SQUARE-MAGNITUDE Z) [FUNCTION] · src
∀ :A. ComplexComponent :A ⇒ Complex :A → :A
The squared length of a complex number: $$\vert z\vert^2=(\operatorname{Re} z)^2+(\operatorname{Im} z)^2.$$
II [VALUE] · src
∀ :A. ComplexComponent :A ⇒ Complex :A
The complex unit $i=\sqrt{-1}$. (The double ii represents a
blackboard-bold 𝕚.)
Package COALTON/MATH/ELEMENTARY
Classes
Elementary [CLASS] · src
(Reciprocable :A) (Polar :A) (Trigonometric :A) (Exponentiable :A) (Radical :A) ⇒ Elementary :A
Elementary is a marker class, providing Reciprocable, Polar, Trigonometric, Exponentiable, and Radical.
Methods:
Instances
Exponentiable [CLASS] · src
Exponential maps obeying:
(* (exp x) (exp y)) = (exp (+ x y))
(exp (ln x)) = x = (ln (exp x))
(log b x) = (/ (ln x) (ln b))
(pow x y) = (exp (* y (ln x)))
Methods:
EXP :: :A → :APOW :: :A * :A → :ALN :: :A → :ALOG :: :A * :A → :AEE :: :A
Instances
Exponentiable CRealExponentiable Big-Float(Exponentiable :T) (Reciprocable :T) ⇒ Exponentiable (Hyperdual :T)(Num :T) (Exponentiable :T) (Reciprocable :T) ⇒ Exponentiable (Dual :T)Elementary :A ⇒ Exponentiable (Complex :A)Exponentiable F64Exponentiable F32
Polar [CLASS] · src
(ComplexComponent :A) (Num :A) ⇒ Polar :A
This type class includes ComplexComponent types that admit a magnitude and phase.
For a complex number z = (complex x y), the following identities hold:
z = (* (magnitude z) (exp (* ii (phase z))))
(polar z) = (values (magnitude z) (phase z))
(phase z) = (atan2 y x)
Methods:
Radical [CLASS] · src
Radical :A
Obeys:
(^ (sqrt x) 2) = x = (^^ (nth-root n x) n)
Methods:
NTH-ROOT :: Integer * :A → :ASQRT :: :A → :A
Instances
Radical RealAlgebraicRadical CRealRadical Big-Float(Radical :T) (Reciprocable :T) (Exponentiable :T) ⇒ Radical (Hyperdual :T)(Num :T) (Radical :T) (Reciprocable :T) (Exponentiable :T) ⇒ Radical (Dual :T)Elementary :A ⇒ Radical (Complex :A)Radical F64Radical F32
Trigonometric [CLASS] · src
Standard circular functions and their inverses.
Methods:
SIN :: :A → :ACOS :: :A → :ATAN :: :A → :AASIN :: :A → :AACOS :: :A → :AATAN :: :A → :API :: :A
Instances
Trigonometric CRealTrigonometric Big-Float(Trigonometric :T) (Reciprocable :T) (Radical :T) ⇒ Trigonometric (Hyperdual :T)(Num :T) (Trigonometric :T) (Reciprocable :T) (Radical :T) ⇒ Trigonometric (Dual :T)Elementary :A ⇒ Trigonometric (Complex :A)Trigonometric F64Trigonometric F32
Values
(ACOSH X) [FUNCTION] · src
∀ :F. Elementary :F ⇒ :F → :F
(ASINH X) [FUNCTION] · src
∀ :F. Elementary :F ⇒ :F → :F
(ATAN2 Y X) [FUNCTION] · src
∀ :F. (Ord :F) (Trigonometric :F) (Reciprocable :F) ⇒ :F * :F → :F
Computes the two-argument arctangent of y and x, which is roughly the same
as (atan (/ y x)) when defined and accounting for the quadrant of
the point $(\mathtt{x},\mathtt{y})$.
(ATANH X) [FUNCTION] · src
∀ :F. Elementary :F ⇒ :F → :F
(CIS Z) [FUNCTION] · src
∀ :A. (Trigonometric :A) (ComplexComponent :A) ⇒ :A → Complex :A
A point on the complex unit circle:
(cis z) := (exp (complex 0 z))
= (complex (cos z) (sin z))
(COSH X) [FUNCTION] · src
∀ :F. Elementary :F ⇒ :F → :F
(MAGNITUDE Z) [FUNCTION] · src
∀ :A. (ComplexComponent :A) (Radical :A) ⇒ Complex :A → :A
The magnitude of a complex number. For z = x + yi,
(magnitude z) = (sqrt (+ (^ x 2) (^ y 2)))
(SINCOS X) [FUNCTION] · src
∀ :A. Trigonometric :A ⇒ :A → :A * :A
Computes the sine and cosine of X.
(SINH X) [FUNCTION] · src
∀ :F. Elementary :F ⇒ :F → :F
(TANH X) [FUNCTION] · src
∀ :F. Elementary :F ⇒ :F → :F
Package COALTON/MATH/FRACTION
Values
(DENOMINATOR Q) [FUNCTION] · src
The denominator of a fraction.
(MKFRACTION A B) [FUNCTION] · src
(NUMERATOR Q) [FUNCTION] · src
The numerator of a fraction.
Package COALTON/MATH/INTEGRAL
Classes
Integral [CLASS] · src
(Remainder :INT) (Ord :INT) ⇒ Integral :INT
Integral is a number that is either even or odd where div and quot
are floored and truncated division, respectively.
Methods:
TOINTEGER :: :INT → Integer
Instances
Remainder [CLASS] · src
Remainder is typically an integral domain satisfying:
a = (+ (* b (quot a b)) (rem a b))
a = (+ (* b (div a b)) (mod a b))
Methods:
QUOT :: :A * :A → :AREM :: :A * :A → :AQUOTREM :: :A * :A → :A * :ADIV :: :A * :A → :AMOD :: :A * :A → :ADIVMOD :: :A * :A → :A * :A
Instances
Values
(EVEN? N) [FUNCTION] · src
∀ :A. Integral :A ⇒ :A → Boolean
Is N even?
(GCD A B) [FUNCTION] · src
∀ :A. (Remainder :A) (Ord :A) ⇒ :A * :A → :A
The greatest common divisor of A and B.
(ILOG B X) [FUNCTION] · src
∀ :INT. Integral :INT ⇒ :INT * :INT → :INT
The floor of the logarithm with base B > 1 of X >= 1.
(INTEGRAL->NUM N) [FUNCTION] · src
∀ :A :B. (Integral :A) (Num :B) ⇒ :A → :B
Converts any Integral N into any Num.
(ISQRT X) [FUNCTION] · src
∀ :INT. Integral :INT ⇒ :INT → :INT
The floor of the square root of N > 0.
(LCM A B) [FUNCTION] · src
∀ :A. (Remainder :A) (Ord :A) ⇒ :A * :A → :A
The least common multiple of A and B.
(LSH X N) [FUNCTION] · src
∀ :B :N. (Integral :N) (Bits :B) ⇒ :B * :N → :B
Left shift X by N
(ODD? N) [FUNCTION] · src
∀ :A. Integral :A ⇒ :A → Boolean
Is N odd?
(RSH X N) [FUNCTION] · src
∀ :B :N. (Integral :N) (Bits :B) ⇒ :B * :N → :B
Right shift X by N
(^ BASE POWER) [FUNCTION] · src
∀ :A :INT. (Num :A) (Integral :INT) ⇒ :A * :INT → :A
Exponentiate BASE to a non-negative POWER.
(^^ BASE POWER) [FUNCTION] · src
∀ :A :INT. (Reciprocable :A) (Integral :INT) ⇒ :A * :INT → :A
Exponentiate BASE to a signed POWER.
Package COALTON/MATH/REAL
Structs
Quantization #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A> [STRUCT] · src
Represents an integer quantization of :a.
Instances
RuntimeRepr (Quantization :|0|)
Classes
Quantizable [CLASS] · src
Quantizable :A
The representation of a type that allows for rounding operations
max x such that (floor x) <= x
min x such that (ceiling x) <= x
And
(proper x) = (values (truncate x) (- x (truncate x)))
where
(truncate x) = (* (sign x) (floor (abs x))
Methods:
Instances
Quantizable RealAlgebraicQuantizable CRealQuantizable Big-FloatQuantizable DyadicQuantizable F64Quantizable F32Quantizable FractionQuantizable IntegerQuantizable IFixQuantizable I64Quantizable I32Quantizable I8Quantizable UFixQuantizable U64Quantizable U32Quantizable U8Quantizable Bit
Rational [CLASS] · src
(Real :A) (Ord :A) ⇒ Rational :A
Any number that can be exactly represented by a fraction, or is not finite.
If a rational can be converted from a fraction it must satisfy:
(into (to-fraction x)) = x
(into (best-approx x)) = x
Furthermore, best-approx returns the simplest fraction, and both functions may be partial.
Methods:
Instances
Real [CLASS] · src
(Quantizable :A) (Num :A) ⇒ Real :A
A real number that can be approximated with abs(real-approx x - x) < 2^-n.
Methods:
Instances
Values
(CEILING/ A B) [FUNCTION] · src
Divide two integers and compute the ceiling of the quotient.
(EXACT/ A B) [FUNCTION] · src
Exactly divide two integers and produce a fraction.
(FLOOR/ A B) [FUNCTION] · src
Divide two integers and compute the floor of the quotient.
(FROMFRAC Q) [FUNCTION] · src
∀ :A. Dividable Integer :A ⇒ Fraction → :A
Converts a fraction to a target type.
Specifically, target types must have an instance of Dividable Integer :a.
This conversion may result in loss of fidelity.
(INEXACT/ A B) [FUNCTION] · src
Compute the quotient of integers as a double-precision float.
Note: This does not divide double-float arguments.
(QUANTIZE X) [FUNCTION] · src
∀ :A. Real :A ⇒ :A → Quantization :A
Given X, (QUANTIZE X) will return the least integer greater or equal to X, and the greatest integer less than or equal to X, along with their respective remainders expressed as values of type of X.
(ROUND X) [FUNCTION] · src
∀ :A. (Quantizable :A) (Num :A) ⇒ :A → Integer
Return the nearest integer to X, with ties breaking towards even numbers.
(ROUND-HALF-DOWN X) [FUNCTION] · src
∀ :A. (Quantizable :A) (Num :A) ⇒ :A → Integer
Return the nearest integer to X, with ties breaking toward positive infinity.
(ROUND-HALF-UP X) [FUNCTION] · src
∀ :A. (Quantizable :A) (Num :A) ⇒ :A → Integer
Return the nearest integer to X, with ties breaking toward positive infinity.
(ROUND/ A B) [FUNCTION] · src
Divide two integers and round the quotient.
(SAFE/ X Y) [FUNCTION] · src
∀ :A :B. (Num :A) (Dividable :A :B) ⇒ :A * :A → Optional :B
Safely divide X by Y, returning None if Y is zero.
(TRUNCATE X) [FUNCTION] · src
∀ :A. Quantizable :A ⇒ :A → Integer
Returns the integer closest/equal to x that is within 0 and x.
Package COALTON/MONAD/CLASSES
Classes
LiftTo [CLASS] · src
(Monad :M) (Monad :R) ⇒ LiftTo :M :R
A monad, :m, which can be lifted to :r. Typically because :m is a MonadTransformer or :m and :r are the same.
Methods:
LIFT-TO :: :M :A → :R :A
Instances
MonadEnvironment [CLASS] · src
Monad :M ⇒ MonadEnvironment :ENV :M
A monad capable of a function in a computation environment.
Methods:
ASK :: :M :ENV
Retrieves the computation environment.LOCAL :: (:ENV → :ENV) * :M :A → :M :A
Run a computation in a modified environment.ASKS :: (:ENV → :A) → :M :A
Retrieve an aspect of the computation environment.
Instances
MonadEnvironment :E :M ⇒ MonadEnvironment :E (LoopT :M)MonadEnvironment :ENV :M ⇒ MonadEnvironment :ENV (OptionalT :M)MonadEnvironment :ENV :M ⇒ MonadEnvironment :ENV (ResultT :ERR :M)Monad :M ⇒ MonadEnvironment :ENV (EnvT :ENV :M)MonadEnvironment :ENV (Env :ENV)MonadEnvironment :E :M ⇒ MonadEnvironment :E (StateT :S :M)
MonadState [CLASS] · src
Monad :M ⇒ MonadState :S :M
A monad capable of tracking state in a computation.
Methods:
GET :: :M :S
Retrieve the computation state.PUT :: :S → :M Unit
Set the state to a given value.MODIFY :: (:S → :S) → :M Unit
Modify the computation state, discarding the old state.
Instances
MonadState :S :M ⇒ MonadState :S (LoopT :M)MonadState :S :M ⇒ MonadState :S (OptionalT :M)MonadState :S :M ⇒ MonadState :S (ResultT :ERR :M)MonadState :S :M ⇒ MonadState :S (EnvT :E :M)Monad :M ⇒ MonadState :S (StateT :S :M)
Package COALTON/MONAD/ENVIRONMENT
Types
Env [TYPE] · src
(Env :A → :B)
A computation that runs inside an :env environment.
Instances
Applicative (Env :ENV)Functor (Env :ENV)Monad (Env :ENV)MonadEnvironment :ENV (Env :ENV)RuntimeRepr (Env :|0| :|1|)
EnvT [TYPE] · src
(EnvT :A → :B :C)
A monadic computation that runs inside an :env environment. Equivalent to Haskell’s ReaderT monad https://hackage.haskell.org/package/transformers-0.6.1.2/docs/Control-Monad-Trans-Reader.html
Instances
Applicative :M ⇒ Applicative (EnvT :ENV :M)Functor :M ⇒ Functor (EnvT :ENV :M)Monad :M ⇒ Monad (EnvT :ENV :M)Monad :M ⇒ MonadEnvironment :ENV (EnvT :ENV :M)MonadState :S :M ⇒ MonadState :S (EnvT :E :M)MonadTransformer (EnvT :ENV)RuntimeRepr (EnvT :|0| :|1| :|2|)
Values
(ASKS-ENV FENV->A) [FUNCTION] · src
∀ :ENV :A. (:ENV → :A) → Env :ENV :A
Retrieve an aspect of the computation environment.
(ASKS-ENVT FENV->A) [FUNCTION] · src
∀ :ENV :A :M. Applicative :M ⇒ (:ENV → :A) → EnvT :ENV :M :A
Retrieve an aspect of the computation environment.
(LIFT-ENVT M) [FUNCTION] · src
∀ :M :A :ENV. :M :A → EnvT :ENV :M :A
(LOCAL-ENV FENV MENV) [FUNCTION] · src
∀ :ENV :VALUE. (:ENV → :ENV) * Env :ENV :VALUE → Env :ENV :VALUE
(LOCAL-ENVT FENV (ENVT FENV->A)) [FUNCTION] · src
∀ :ENV :M :VALUE. (:ENV → :ENV) * EnvT :ENV :M :VALUE → EnvT :ENV :M :VALUE
Run a computation in a modified environment.
(MAP-ENVT FMA->NB (ENVT FENV->MA)) [FUNCTION] · src
∀ :M :A :N :B :ENV. (:M :A → :N :B) * EnvT :ENV :M :A → EnvT :ENV :N :B
(RUN-ENV (ENV ENV-COMPUTATION) ENV) [FUNCTION] · src
∀ :ENV :VALUE. Env :ENV :VALUE * :ENV → :VALUE
Run a Env inside an environment.
(RUN-ENVT (ENVT FENV->VAL) ENV) [FUNCTION] · src
∀ :ENV :M :VALUE. EnvT :ENV :M :VALUE * :ENV → :M :VALUE
Run a EnvT inside an environment.
ASK-ENV [VALUE] · src
∀ :ENV. Env :ENV :ENV
Retrieve the computation environment.
ASK-ENVT [VALUE] · src
∀ :ENV :M. Monad :M ⇒ EnvT :ENV :M :ENV
Retrieve the computation environment.
Package COALTON/MONAD/FREE
Types
Free [TYPE] · src
(Free :A (Free :A :B))(Val :A)
Free :f gives you a Monad instance for any Functor :f.
Instances
Foldable :F ⇒ Foldable (Free :F)Functor :F ⇒ Applicative (Free :F)Functor :F ⇒ Functor (Free :F)Functor :F ⇒ Monad (Free :F)Functor :F ⇒ MonadFree :F (Free :F)RuntimeRepr (Free :|0| :|1|)Traversable :T ⇒ Traversable (Free :T)
Classes
MonadFree [CLASS] · src
A free monad is a monad, :m, which is capable of ‘wrapping’
around functors, and then ‘unwrapping’ them later using >>=.
Methods:
WRAP :: :F (:M :A) → :M :A
Values
(FOLDFREE NAT FR) [FUNCTION] · src
∀ :A :B :C. Monad :C ⇒ (:A (Free :A :B) → :C (Free :A :B)) * Free :A :B → :C :B
Given a natural transformation, induce a Monad homomorphism from a free monad to a target monad.
(LIFTF F) [FUNCTION] · src
∀ :F :A :M. (Functor :F) (MonadFree :F :M) ⇒ :F :A → :M :A
Lift a Functor into the Free Monad.
(RUN-FREE TRANSF OP) [FUNCTION] · src
∀ :F :A. Functor :F ⇒ (:F (Free :F :A) → Free :F :A) * Free :F :A → :A
Run a free monad with a function that unwraps a single layer of the functor
f at a time.
References: here
Package COALTON/MONAD/FREET
Types
FreeF [TYPE] · src
(FreeF :A :B)(Val :A)
Instances
Functor :F ⇒ Bifunctor (FreeF :F)Functor :F ⇒ Functor (FreeF :F :A)RuntimeRepr (FreeF :|0| :|1| :|2|)Traversable :F ⇒ Traversable (FreeF :F :A)
FreeT [TYPE] · src
Free :f :m :a gives you a Monad Transformer instance for any Functor :f and Monad :m.
Instances
(Functor :F) (Functor :M) ⇒ Functor (FreeT :F :M)(Functor :F) (Monad :M) ⇒ Applicative (FreeT :F :M)(Functor :F) (Monad :M) ⇒ Monad (FreeT :F :M)(Functor :F) (Monad :M) ⇒ MonadFree :F (FreeT :F :M)(Monad :M) (Traversable :M) (Traversable :F) ⇒ Traversable (FreeT :F :M)Functor :F ⇒ MonadTransformer (FreeT :F)RuntimeRepr (FreeT :|0| :|1| :|2|)
Values
(FOLD-FREET F (FREET M)) [FUNCTION] · src
∀ :F :M :A :T. (MonadTransformer :T) (Monad (:T :M)) (Monad :M) ⇒ (:F (FreeT :F :M :A) → :T :M (FreeT :F :M :A)) * FreeT :F :M :A → :T :M :A
(RUN-FREET TRANSF OP) [FUNCTION] · src
∀ :F :M :A. Monad :M ⇒ (:F (FreeT :F :M :A) → FreeT :F :M :A) * FreeT :F :M :A → :M :A
Run a free monad transformer with a function that unwraps a single layer of the
functor f at a time.
(UNWRAP-FREET (FREET M)) [FUNCTION] · src
∀ :F :M :A. FreeT :F :M :A → :M (FreeF :F :A (FreeT :F :M :A))
Unwrap one layer of the the free monad transformer, returning a value of the base monad containing a FreeF (which can either contain VAL, a pure value, or FREEF, another wrapped layer of the free monad transformer).
Package COALTON/MONAD/IDENTITY
Types
Identity [TYPE] · src
(Identity :A)
A bare computation. Not useful on its own, but is useful for running Monad transformers in a bare context.
Instances
Values
(RUN-IDENTITY (IDENTITY A)) [FUNCTION] · src
∀ :A. Identity :A → :A
Package COALTON/MONAD/OPTIONALT
Types
OptionalT [TYPE] · src
(OptionalT :A (Optional :B))
A monadic computation that returns an Optional.
Instances
Functor :M ⇒ Functor (OptionalT :M)Monad :M ⇒ Alternative (OptionalT :M)Monad :M ⇒ Applicative (OptionalT :M)Monad :M ⇒ Monad (OptionalT :M)MonadEnvironment :ENV :M ⇒ MonadEnvironment :ENV (OptionalT :M)MonadState :S :M ⇒ MonadState :S (OptionalT :M)MonadTransformer OptionalTRuntimeRepr (OptionalT :|0| :|1|)
Values
(MAP-OPTIONALT F (OPTIONALT M)) [FUNCTION] · src
∀ :M :A :N :B. (:M (Optional :A) → :N (Optional :B)) * OptionalT :M :A → OptionalT :N :B
(RUN-OPTIONALT (OPTIONALT M)) [FUNCTION] · src
∀ :M :A. OptionalT :M :A → :M (Optional :A)
Package COALTON/MONAD/RESULTT
Types
ResultT [TYPE] · src
(ResultT :A (Result :B :C))
A monadic computation that returns a Result.
Instances
Functor :M ⇒ Functor (ResultT :ERR :M)Monad :M ⇒ Applicative (ResultT :ERR :M)Monad :M ⇒ Monad (ResultT :ERR :M)MonadEnvironment :ENV :M ⇒ MonadEnvironment :ENV (ResultT :ERR :M)MonadState :S :M ⇒ MonadState :S (ResultT :ERR :M)MonadTransformer (ResultT :ERR)RuntimeRepr (ResultT :|0| :|1| :|2|)
Values
(ERR-IFM FAILED? FAILURE) [FUNCTION] · src
∀ :ERR :M. Monad :M ⇒ Boolean * :ERR → :M (Result :ERR Unit)
Fail with FAILURE inside :m if FAILED? is True.
(ERR-IFT FAILED? FAILURE) [FUNCTION] · src
∀ :ERR :M. Monad :M ⇒ Boolean * :ERR → ResultT :ERR :M Unit
Fail with FAILURE if FAILED? is True.
(MAP-ERRM FERR M) [FUNCTION] · src
∀ :A :B :M :C. Monad :M ⇒ (:A → :B) * :M (Result :A :C) → :M (Result :B :C)
Map FERR over the error value of a Result contained in M.
(MAP-ERRT FERR RT) [FUNCTION] · src
∀ :A :B :M :C. Functor :M ⇒ (:A → :B) * ResultT :A :M :C → ResultT :B :M :C
(MAP-RESULTT F (RESULTT M)) [FUNCTION] · src
∀ :M :E1 :A :N :E2 :B. (:M (Result :E1 :A) → :N (Result :E2 :B)) * ResultT :E1 :M :A → ResultT :E2 :N :B
(RUN-RESULTT (RESULTT M)) [FUNCTION] · src
∀ :ERR :M :OK. ResultT :ERR :M :OK → :M (Result :ERR :OK)
Package COALTON/MONAD/STATE
Types
ST [TYPE] · src
(ST :A → Tuple :A :B)
A computation of a value which may affect the state. Represented as a closure from initial state to updated state and value.
Instances
Applicative (ST :STATE)Functor (ST :STATE)Monad (ST :STATE)RuntimeRepr (ST :|0| :|1|)
Values
(MODIFY FS->S) [FUNCTION] · src
∀ :STATE. (:STATE → :STATE) → ST :STATE Unit
Modify the state in a StatefulComputation, discarding the old state.
(MODIFY-GET FS->S) [FUNCTION] · src
∀ :STATE. (:STATE → :STATE) → ST :STATE :STATE
Modify the state in a StatefulComputation, discarding the old state. Return the new state.
(MODIFY-SWAP FS->S) [FUNCTION] · src
∀ :STATE. (:STATE → :STATE) → ST :STATE :STATE
Modify the state in a StatefulComputation, returning the old state.
(PUT STATE) [FUNCTION] · src
∀ :STATE. :STATE → ST :STATE Unit
A StatefulComputation with state set to be the given state. The returned value is Unit.
(RUN SC STATE) [FUNCTION] · src
∀ :STATE :A. ST :STATE :A * :STATE → Tuple :STATE :A
Runs a StatefulComputation to produce a final updated state and value given an initial state
(SWAP STATE) [FUNCTION] · src
∀ :STATE. :STATE → ST :STATE :STATE
A StatefulComputation with state set to be the given state. The old state is returned.
GET [VALUE] · src
∀ :STATE. ST :STATE :STATE
A StatefulComputation which returns the current state as the value.
Package COALTON/MONAD/STATET
Types
StateT [TYPE] · src
(StateT :A → :B (Tuple :A :C))
A monadic computation that tracks state of type :s.
Instances
Applicative :M ⇒ Applicative (StateT :S :M)Functor :M ⇒ Functor (StateT :S :M)Monad :M ⇒ Monad (StateT :S :M)Monad :M ⇒ MonadState :S (StateT :S :M)MonadEnvironment :E :M ⇒ MonadEnvironment :E (StateT :S :M)MonadTransformer (StateT :S)RuntimeRepr (StateT :|0| :|1| :|2|)
Values
(LIFT-STATET M) [FUNCTION] · src
∀ :M :A :S. Functor :M ⇒ :M :A → StateT :S :M :A
Lift a stateless computation into a stateful context.
(MAP-STATET FMA->NB (STATET FS->MSA)) [FUNCTION] · src
∀ :M :S :A :N :B. (:M (Tuple :S :A) → :N (Tuple :S :B)) * StateT :S :M :A → StateT :S :N :B
Map the return value, the final state, and the execution context.
(MODIFY-STATET FS->S) [FUNCTION] · src
∀ :S :M. Applicative :M ⇒ (:S → :S) → StateT :S :M Unit
Modify the computation state, discarding the old state.
(PUT-STATET STATE) [FUNCTION] · src
∀ :S :M. Applicative :M ⇒ :S → StateT :S :M Unit
A stateful computation with state set to the given state. The returned value is Unit.
(RUN-STATET (STATET FS->MSA) S) [FUNCTION] · src
∀ :S :M :A. Applicative :M ⇒ StateT :S :M :A * :S → :M (Tuple :S :A)
(RUN-STATET_ ST-OP S) [FUNCTION] · src
∀ :S :M :A. Applicative :M ⇒ StateT :S :M :A * :S → :M :A
Run ST-OP, discarding the state and returning the result.
GET-STATET [VALUE] · src
∀ :S :M. Applicative :M ⇒ StateT :S :M :S
A stateful computation which returns the current state as the value.
Package COALTON/OPTIONAL
Values
(FROM-SOME STR OPT) [FUNCTION] · src
∀ :A. String * Optional :A → :A
Get the value of OPT, erroring with the provided string if it is None.
(NONE? X) [FUNCTION] · src
Is X None?
(SOME? X) [FUNCTION] · src
Is X Some?
Package COALTON/ORDMAP
Immutable maps ordered by key comparison and iterated in ascending key order.
Types
OrdMap [TYPE] · src
A binary tree which associates each :KEY with a :VALUE, sorted by <=>' on the keys and unique by ==’ on the keys.
Instances
(Eq :KEY) (Eq :VALUE) ⇒ Eq (OrdMap :KEY :VALUE)(Hash :KEY) (Hash :VALUE) ⇒ Hash (OrdMap :KEY :VALUE)(Show :KEY) (Show :VALUE) ⇒ Show (OrdMap :KEY :VALUE)Functor (OrdMap :KEY)IntoIterator (OrdMap :KEY :VALUE) (Tuple :KEY :VALUE)Ord :KEY ⇒ FromAssociationComprehension (OrdMap :KEY :VALUE) :KEY :VALUE (OrdMap :KEY :VALUE)Ord :KEY ⇒ FromItemizedAssociation (OrdMap :KEY :VALUE) :KEY :VALUE (OrdMap :KEY :VALUE)Ord :KEY ⇒ FromIterator (OrdMap :KEY :VALUE) (Tuple :KEY :VALUE)Ord :KEY ⇒ Monoid (OrdMap :KEY :VALUE)Ord :KEY ⇒ Semigroup (OrdMap :KEY :VALUE)RuntimeRepr (OrdMap :|0| :|1|)
Values
(ADJOIN MP K V) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * :KEY * :VALUE → OrdMap :KEY :VALUE
Returns an OrdMap in which the key k is associated with v added
to the mp, only when mp doesn’t have an association with k.
If mp already contains an association with k, mp is returned as is.
(COLLECT COLL) [FUNCTION] · src
∀ :COLLECTION :KEY :VALUE. (Ord :KEY) (Foldable :COLLECTION) ⇒ :COLLECTION (Tuple :KEY :VALUE) → OrdMap :KEY :VALUE
Construct a OrdMap containing all the (key value) pairs in coll.
If coll contains duplicate keys, later values will overwrite earlier values.
(COLLECT! ITER) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ Iterator (Tuple :KEY :VALUE) → OrdMap :KEY :VALUE
Construct a OrdMap containing all the (key value) pairs in iter.
If iter contains duplicate keys, later values will overwrite earlier values.
(DIFFERENCE A B) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * OrdMap :KEY :VALUE → OrdMap :KEY :VALUE
Returns an OrdMap that contains mappings in a but not in b.
(EMPTY? M) [FUNCTION] · src
∀ :KEY :VALUE. OrdMap :KEY :VALUE → Boolean
Returns True iff the given OrdMap is empty.
(ENTRIES MP) [FUNCTION] · src
∀ :KEY :VALUE. OrdMap :KEY :VALUE → Iterator (Tuple :KEY :VALUE)
Iterate over the (key value) pairs in MP, sorted by the keys in least-to-greatest order.
(INSERT MP K V) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * :KEY * :VALUE → OrdMap :KEY :VALUE
Returns an OrdMap in which the key k is associated with v added
to the mp. If mp already contains mapping for k, it is replaced.
(INTERSECTION A B) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * OrdMap :KEY :VALUE → OrdMap :KEY :VALUE
Construct an OrdMap contaning elements whose key appears in both a and b.
The resulting values are from a.
(KEYS MP) [FUNCTION] · src
∀ :KEY :VALUE. OrdMap :KEY :VALUE → Iterator :KEY
Iterate over the keys in MP, sorted least-to-greatest.
(LOOKUP MP K) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * :KEY → Optional :VALUE
Retrieve the value associated with K in MP, or None if MP does not contain K.
(LOOKUP-NEIGHBORS MP K) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * :KEY → Tuple3 (Optional (Tuple :KEY :VALUE)) (Optional (Tuple :KEY :VALUE)) (Optional (Tuple :KEY :VALUE))
Returns elements LO, ON, and HI, such that LO has the closest
key that is strictly less than k, ON is the entry with k,
and HI has the closest key that is strictly greater than ‘k’.
Any of these values can be None if there’s no such entry.
(MAX-KEY-ENTRY MP) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE → Optional (Tuple :KEY :VALUE)
Returns the entry (Tuple :key :value) with the maximum key in the map mp. If the map is empty, None is returned.
(MIN-KEY-ENTRY MP) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE → Optional (Tuple :KEY :VALUE)
Returns the entry (Tuple :key :value) with the minimum key in the map mp. If the map is empty, None is returned.
(REMOVE MP K) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * :KEY → OrdMap :KEY :VALUE
Returns an OrdMap in which the association with key ‘k’ is removed from
mp. If mp doesn’t have an association with k, it is returned as is.
(REPLACE MP K V) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * :KEY * :VALUE → OrdMap :KEY :VALUE
Returns an OrdMap in which the key k is associated with v replaced
from mp, when mp already has an association with k.
If mp doesn’t has an association with k, mp is returned as is.
(UNION A B) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * OrdMap :KEY :VALUE → OrdMap :KEY :VALUE
Construct an OrdMap containing all the mappings of both A and B.
If A and B contain mappings X -> A’ and X -> B’, the former mapping is kept.
The operation is associative, but not commutative.
(UPDATE MP K F) [FUNCTION] · src
∀ :KEY :VALUE :A. Ord :KEY ⇒ OrdMap :KEY :VALUE * :KEY * (Optional :VALUE → Optional :VALUE * :A) → OrdMap :KEY :VALUE * :A
Lookup an association with k in mp. If there’s an entry, call f
with its value wrapped with Some. If there isn’t an entry, call ‘f’ with
None. f must return a possible new value and an auxiliary result.
If the first return value of f is Some, its content is inserted into
mp in association with k. If the first return value of f is None,
an association with k in mp is removed. A possibly updated mapping
is returned as the first value.
The auxiliary result from f is returned as the second value.
This can be used for the caller to obtain the previous state along updated map. For example, the following code inserts an entry (k, v) into mp, and obtain (Some v’) or None in the second value of the result, where v’ is the previous value associated with k.
(update mp k (fn (prev) (values (Some v) prev)))
(VALUES-ITER MP) [FUNCTION] · src
∀ :KEY :VALUE. OrdMap :KEY :VALUE → Iterator :VALUE
Iterate over the values in MP, sorted by their corresponding keys in least-to-greatest order.
(XOR A B) [FUNCTION] · src
∀ :KEY :VALUE. Ord :KEY ⇒ OrdMap :KEY :VALUE * OrdMap :KEY :VALUE → OrdMap :KEY :VALUE
Returns an OrdMap that contains mappings either in a or in b,
but not in both.
EMPTY [VALUE] · src
∀ :KEY :VALUE. OrdMap :KEY :VALUE
A OrdMap containing no mappings.
Package COALTON/ORDTREE
Types
OrdTree [TYPE] · src
Empty- exported; an empty tree.
A 1-2 brother tree, sorted by <=> and unique by ==.
Instances
Eq :ELT ⇒ Eq (OrdTree :ELT)Foldable OrdTreeHash :ELT ⇒ Hash (OrdTree :ELT)IntoIterator (OrdTree :ELT) :ELTOrd :ELT ⇒ FromIterator (OrdTree :ELT) :ELTRuntimeRepr (OrdTree :|0|)
Values
(ADJOIN T A) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * :ELT → OrdTree :ELT
Returns an ordtree that has a new entry a. If t already has an entry
which is == to a, however, the original t is returned as is.
(DECREASING-ORDER TRE) [FUNCTION] · src
∀ :ELT. OrdTree :ELT → Iterator :ELT
Returns an iterator that traverses elements in tre in decreasing order.
(DIFFERENCE A B) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * OrdTree :ELT → OrdTree :ELT
Returns an OrdTree that contains elements in a but not in b.
(EMPTY? T) [FUNCTION] · src
∀ :ELT. OrdTree :ELT → Boolean
(INCREASING-ORDER TRE) [FUNCTION] · src
∀ :ELT. OrdTree :ELT → Iterator :ELT
Returns an iterator that traverses elements in tre in increasing order.
This is same as (iter:into-iter tre).
(INSERT T A) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * :ELT → OrdTree :ELT
Returns an ordtree that has an new entry a added to t. If t already
has an entry which is == to a, The new ordtree has a in place of the
existing entry.
(INTERSECTION A B) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * OrdTree :ELT → OrdTree :ELT
Returns an OrdTree that contains elements that appear in both a and b.
The resulting elements are from a.
(LOOKUP HAYSTACK NEEDLE) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * :ELT → Optional :ELT
If HAYSTACK contains an element == to NEEDLE, return it.
(LOOKUP-NEIGHBORS HAYSTACK NEEDLE) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * :ELT → Tuple3 (Optional :ELT) (Optional :ELT) (Optional :ELT)
Returns elements LO, ON, and HI, such that LO is the closest
element that is strictly less than needle, ON is the element
that is == to needle, and HI is the closest element that is
strictly greater than needle. Any of these values can be None
if there’s no such element.
(MAX-ELEMENT TRE) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT → Optional :ELT
Returns the maximum element in the tree, or None if the tree is empty.
(MIN-ELEMENT TRE) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT → Optional :ELT
Returns the minimum element in the tree, or None if the tree is empty.
(REMOVE T A) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * :ELT → OrdTree :ELT
Returns an ordtree that is the same as t except that the entry
which is == to a is removed. If t does not have such an entry,
t is returned as is.
(REPLACE T A) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * :ELT → OrdTree :ELT
Returns an ordtree that has an entry a only if t already has an
entry which is == to a. The original entry is replaced with the given
a. If t doesn’t have an entry == to a, t is returned as is.
(TRANSFORM-ELEMENTS F TRE) [FUNCTION] · src
∀ :A :B. (:A → :B) * OrdTree :A → OrdTree :B
Returns a tree whose element consists of the result of f applied to
the original element, and isomorphic to the original tree.
It is important that transforming keys with f does not change the order
of the element. If f violates the condition, the resulting tree isn’t
guaranteed to be consistent.
We do not name this map because of this restriction.
(UNION A B) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * OrdTree :ELT → OrdTree :ELT
Returns an OrdTree that contains all the elements from a and b.
If both OrdTrees has the same (==) element, the one from a is taken.
(UPDATE T A F) [FUNCTION] · src
∀ :ELT :A. Ord :ELT ⇒ OrdTree :ELT * :ELT * (Optional :ELT → Optional :ELT * :A) → OrdTree :ELT * :A
Generic update. Look for the element a in t. If there’s an entry,
call f with the existing entry wrapped with Some. If there isn’t an entry,
call f with None. f must return a possible replacement entry and an
auxiliary result.
If the entry doesn’t exist in t and f returns (Some elt), elt is
inserted. If the entry exists in t and f returns None, the element
is removed. If the entry exists in t and f returns (Some elt), elt
replaces the original entry.
It is important that if f returns (Some elt), elt must be still greater
than the ‘previous’ element and less than the ’next’ element in the tree,
otherwise the returned tree would be inconsistent.
If you use an ordtree to keep a set of keys, you don’t really need to alter
the existing entry. It is useful if you define your own element type that
carries extra info, though; see OrdMap implementation.
(XOR A B) [FUNCTION] · src
∀ :ELT. Ord :ELT ⇒ OrdTree :ELT * OrdTree :ELT → OrdTree :ELT
Rdturns an OrdTree that contains elements either in a or in b,
but not in both.
Package COALTON/QUEUE
Mutable FIFO queues with efficient insertion at the back and removal from the front.
Types
Queue [TYPE] · src
Unbounded FIFO queue implemented with a linked list.
Instances
Values
(APPEND Q1 Q2) [FUNCTION] · src
∀ :A. Queue :A * Queue :A → Queue :A
Create a new queue containing the elements of q1 followed by the elements of q2.
(CLEAR! Q) [FUNCTION] · src
∀ :A. Queue :A → Void
Clear all elements from q.
(COPY Q) [FUNCTION] · src
Return a new queue containing the same elements as q.
(EMPTY? Q) [FUNCTION] · src
Is q empty?
(EXTEND! Q ITER) [FUNCTION] · src
∀ :ELT :CONTAINER. IntoIterator :CONTAINER :ELT ⇒ Queue :ELT * :CONTAINER → Void
Push every element in iter to the end of q.
(INDEX INDEX Q) [FUNCTION] · src
∀ :A. UFix * Queue :A → Optional :A
Return the indexth element of q.
(INDEX-UNSAFE INDEX Q) [FUNCTION] · src
Return the indexth element of q without checking if the element exists.
(ITEMS! Q) [FUNCTION] · src
Returns an iterator over the items of q, removing items as they are returned.
(LENGTH Q) [FUNCTION] · src
Returns the length of q.
(NEW) [FUNCTION] · src
∀ :A. Void → Queue :A
Create a new empty queue.
(PEEK Q) [FUNCTION] · src
Peek at the first item of q.
(PEEK-UNSAFE Q) [FUNCTION] · src
∀ :A. Queue :A → :A
Peek at the first item of q without checking if the queue is empty.
(POP! Q) [FUNCTION] · src
Remove and return the first item of q.
(POP-UNSAFE! Q) [FUNCTION] · src
∀ :A. Queue :A → :A
Remove and return the first item of q without checking if the queue is empty.
(PUSH! ITEM Q) [FUNCTION] · src
∀ :A. :A * Queue :A → Void
Push item onto the end of q.
Package COALTON/RANDOMACCESS
Classes
RandomAccess [CLASS] · src
RandomAccess :F :T
Establishes that :f is a random-access store of elements of type :t. The storage type :f implies the stored type :t. The storage is expected to be sequential and O(1) in random access reads and writes.
It is permitted for any of make, unsafe-aref, or unsafe-set! to error.
Methods:
MAKE :: UFix * :T → :FMAKE-UNINITIALIZED :: UFix → :FLENGTH :: :F → UFixREADABLE? :: :F → BooleanWRITABLE? :: :F → BooleanUNSAFE-AREF :: :F * UFix → :TUNSAFE-SET! :: :F * UFix * :T → Void
Instances
RandomAccess (Vector :T) :TRuntimeRepr :T ⇒ RandomAccess (LispArray :T) :T
Values
(AREF STORAGE INDEX) [FUNCTION] · src
∀ :F :T. RandomAccess :F :T ⇒ :F * UFix → Optional :T
Read the element at index of the random-access storage storage. Return None if the read is out-of-bounds or not permitted.
(ROTATE! STORAGE INDEX1 INDEX2) [FUNCTION] · src
∀ :T :F. RandomAccess :F :T ⇒ :F * UFix * UFix → Optional Unit
Rotate the elements at indices index1 and index2 of the random-access storage storage. Return None if the indices are out-of-bounds or if reading from or writing to storage is not permitted.
(SET! STORAGE INDEX VALUE) [FUNCTION] · src
∀ :F :T. RandomAccess :F :T ⇒ :F * UFix * :T → Optional Unit
Write the element value at index of the random-access storage storage. Return None if the write is out-of-bounds or not permitted.
(UNSAFE-ROTATE! STORAGE INDEX1 INDEX2) [FUNCTION] · src
∀ :T :F. RandomAccess :F :T ⇒ :F * UFix * UFix → Void
Rotate the elements at indices index1 and index2 of the random-access storage storage.
Package COALTON/RESULT
Values
(ERR-IF FAILED? FAILURE) [FUNCTION] · src
∀ :ERR. Boolean * :ERR → Result :ERR Unit
Fail with FAILURE value if FAILED? is True.
(ERR? X) [FUNCTION] · src
∀ :A :B. Result :A :B → Boolean
Returns TRUE if X is ERR
(FLATTEN X) [FUNCTION] · src
∀ :A. Result :A :A → :A
(MAP-ERR F X) [FUNCTION] · src
∀ :A :B :C. (:A → :B) * Result :A :C → Result :B :C
Map over the ERR case
(OK-OR-DEF DEF RES) [FUNCTION] · src
∀ :A :ERR. :A * Result :ERR :A → :A
Take value in RES if it is OK, or DEF if it is ERR.
(OK-OR-ERROR RES) [FUNCTION] · src
∀ :ERR :A. Signalable :ERR ⇒ Result :ERR :A → :A
(OK? X) [FUNCTION] · src
∀ :A :B. Result :A :B → Boolean
Returns TRUE if X is OK
(OKM F-A) [FUNCTION] · src
∀ :F :A :E. Functor :F ⇒ :F :A → :F (Result :E :A)
Wrap a value inside F-A inside of ‘Ok’.
(OPT->RESULT FAILURE OPT) [FUNCTION] · src
∀ :ERR :A. :ERR * Optional :A → Result :ERR :A
Convert OPT to a Result, using FAILURE value if None.
Package COALTON/SEQ
Persistent sequences based on relaxed radix balanced trees.
Types
Seq [TYPE] · src
Instances
(Foldable :F) (RuntimeRepr :A) ⇒ Into (:F :A) (Seq :A)Eq :A ⇒ Eq (Seq :A)Functor SeqInto (Seq :A) (List :A)Into (Seq :A) (Vector :A)IntoIterator (Seq :A) :ARuntimeRepr (Seq :|0|)RuntimeRepr (Tuple :KEY :VALUE) ⇒ FromAssociationComprehension (Seq (Tuple :KEY :VALUE)) :KEY :VALUE (Seq (Tuple :KEY :VALUE))RuntimeRepr (Tuple :KEY :VALUE) ⇒ FromItemizedAssociation (Seq (Tuple :KEY :VALUE)) :KEY :VALUE (Seq (Tuple :KEY :VALUE))RuntimeRepr :A ⇒ Default (Seq :A)RuntimeRepr :A ⇒ FromCollectionComprehension (Seq :A) :A (Seq :A)RuntimeRepr :A ⇒ FromItemizedCollection (Seq :A) :A (Seq :A)RuntimeRepr :A ⇒ FromIterator (Seq :A) :ARuntimeRepr :A ⇒ Monoid (Seq :A)RuntimeRepr :A ⇒ Semigroup (Seq :A)Show :A ⇒ Show (Seq :A)
Values
(CONC LEFT RIGHT) [FUNCTION] · src
∀ :A. RuntimeRepr :A ⇒ Seq :A * Seq :A → Seq :A
Concatenate two Seqs
(EMPTY? SEQ) [FUNCTION] · src
(GET SEQ IDX) [FUNCTION] · src
∀ :A. Seq :A * UFix → Optional :A
Get the member of seq at index idx, or None if idx is larger
than (size seq)
(NEW) [FUNCTION] · src
∀ :A. RuntimeRepr :A ⇒ Void → Seq :A
Create a new empty Seq.
(POP SEQ) [FUNCTION] · src
∀ :A. Seq :A → Optional (Tuple :A (Seq :A))
If seq is empty, return None. Otherwise, the last member of seq and
a new Seq instance.
(PUSH SEQ A) [FUNCTION] · src
Push a onto the end of seq, returning a new Seq instance.
(PUT SEQ IDX A) [FUNCTION] · src
∀ :A. Seq :A * UFix * :A → Optional (Seq :A)
If idx is less than (size seq), Return a new seq whose idx position
contains a.
(SIZE SEQ) [FUNCTION] · src
Return the number of elements in the seq.
Macros
MAKE (&REST ELEMS) [MACRO]
Create a new Seq containing elems.
Package COALTON/SHOW
A way to show linear, human-readable, textual representations of objects.
Classes
Show [CLASS] · src
Show :A
Objects which have a convenient, textual, linear printed representation for display in a terminal. This is principally for program output and debugging.
Methods:
SHOW-TO :: (String → Void) * :A → Void
Execute a callback on a debugging string representation of an object. The callback may be called multiple times on different sections of the string, and the callback is guaranteed to be called on sections left-to-right. For example, for a callback functionf, an object like(1 2 3)may be executed as
(f "(")
(f "1 2")
(f " ")
(f "3)")

Instances
Show :A ⇒ Show (Seq :A)(Show :KEY) (Show :VALUE) ⇒ Show (OrdMap :KEY :VALUE)Show :A ⇒ Show (Queue :A)(Hash :K) (Show :K) (Show :V) ⇒ Show (HashMap :K :V)(Show :KEY) (Show :VALUE) ⇒ Show (HashTable :KEY :VALUE)Show :A ⇒ Show (Vector :A)Show :A ⇒ Show (LispArray :A)(RuntimeRepr :T) (Show :T) ⇒ Show (Complex :T)Show CharShow StringShow FractionShow F64Show F32Show I64Show I32Show I16Show I8Show IFixShow U64Show U32Show U16Show U8Show BitShow UFixShow IntegerShow TypeSchemeShow LispTypeShow (Proxy :A)Show :A ⇒ Show (List :A)Show :A ⇒ Show (Optional :A)Show Boolean
Values
(MAKE-STRING-BUILDER) [FUNCTION] · src
Void → (String → Void) * (Void → String)
Make a string builder and extractor. Return two values:
-
A procedure which consumes strings (accumulating state underneath).
-
A thunk which extracts (and clears) the strings consumed.
(SHOW X) [FUNCTION] · src
∀ :A. Show :A ⇒ :A → Void
Display x to the show stream and flush immediately.
(SHOW-AS-STRING X) [FUNCTION] · src
Display x as a string.
This is not necessarily identical to (the String (into x)).
Macros
SHOW* (&REST ITEMS) [MACRO]
Show each of the items items sequentially.
Package COALTON/SLICE
Types
Slice [TYPE] · src
Instances
Values
(INDEX IDX S) [FUNCTION] · src
∀ :A. UFix * Slice :A → Optional :A
Lookup the element at index in s.
(INDEX-UNSAFE IDX S) [FUNCTION] · src
Lookup the element at index in s without bounds checking.
(ITER-CHUNKED SIZE S) [FUNCTION] · src
∀ :B :A. Sliceable (:B :A) ⇒ UFix * :B :A → Iterator (Slice :A)
Divide s into a series of slices of length size. Will return a final shorter slice if s does not divide evenly.
(ITER-CHUNKED-EXACT SIZE S) [FUNCTION] · src
∀ :B :A. Sliceable (:B :A) ⇒ UFix * :B :A → Iterator (Slice :A)
Divide s into a series of slices of length size. Will skip trailing elements if s does not divide evenly.
(ITER-SLIDING SIZE S) [FUNCTION] · src
∀ :B :A. Sliceable (:B :A) ⇒ UFix * :B :A → Iterator (Slice :A)
Returns an iterator that yields a series of overlapping slices of length size.
(LENGTH S) [FUNCTION] · src
Returns the length of s.
(NEW START LEN V) [FUNCTION] · src
∀ :B :A. Sliceable (:B :A) ⇒ UFix * UFix * :B :A → Slice :A
Create a new slice backed by v starting at index start and continuing for len elements.
(SET! IDX ITEM S) [FUNCTION] · src
∀ :A. UFix * :A * Slice :A → Void
Set the element at index idx in s to item.
Package COALTON/STRING
Values
(CHARS STR) [FUNCTION] · src
Returns an iterator over the characters in str.
(CONCAT STR1 STR2) [FUNCTION] · src
Concatenate STR1 and STR2 together, returning a new string.
(DOWNCASE STR) [FUNCTION] · src
Returns a new string with lowercase characters.
(LENGTH STR) [FUNCTION] · src
The length of a string STR.
(PARSE-INT STR) [FUNCTION] · src
Parse the integer in string str.
(REF STR IDX) [FUNCTION] · src
Return the idxth character of str.
(REF-UNCHECKED STR IDX) [FUNCTION] · src
Return the idxth character of str. This function is partial.
(REVERSE S) [FUNCTION] · src
Reverse a string.
(SPLIT C STR) [FUNCTION] · src
Split a string around the separator character c.
(SPLIT-AT N STR) [FUNCTION] · src
UFix * String → Tuple String String
Splits a string into a substring of the first N characters and a substring of the remaining characters.
(STRIP-PREFIX PREFIX STR) [FUNCTION] · src
String * String → Optional String
Returns a string without a give prefix, or None if the string
does not have that suffix.
(STRIP-SUFFIX SUFFIX STR) [FUNCTION] · src
String * String → Optional String
Returns a string without a give suffix, or None if the string
does not have that suffix.
(SUBSTRING STR START END) [FUNCTION] · src
Compute a substring of a string bounded by given indices.
(SUBSTRING-INDEX SMALL BIG) [FUNCTION] · src
String * String → Optional UFix
If the first argument appears as a substring within the second argument, return the starting index into the second argument.
(SUBSTRING? SMALL BIG) [FUNCTION] · src
Return true if the first argument appears as a substring within the second argument.
(UPCASE STR) [FUNCTION] · src
Returns a new string with uppercase characters.
Package COALTON/SYMBOL
An interface to Common Lisp symbols.
Types
Symbol [TYPE] · src
A Common Lisp symbol.
Values
(GENSYM) [FUNCTION] · src
Void → Symbol
Make an uninterned symbol as by cl:gensym.
(KEYWORD? S) [FUNCTION] · src
Is the symbol s a Common Lisp keyword?
(MAKE-KEYWORD S) [FUNCTION] · src
Find or make a keyword named s.
WARNING: This function interns a new symbol. It will not get garbage collected. Use with caution.
(MAKE-SYMBOL S) [FUNCTION] · src
Make an uninterned symbol with the name s.
(SYMBOL-NAME S) [FUNCTION] · src
Return the name of the symbol s.
(UNINTERNED? S) [FUNCTION] · src
Is the symbol s uninterned?
Package COALTON/SYSTEM
Types
LispCondition [TYPE] · src
Condition for lisp error handling. Uses cl:condition.
Instances
Structs
MeteredResult #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A> [STRUCT] · src
Function output with space and timing metedata.
Instances
RuntimeRepr (MeteredResult :|0|)
Values
(ADD-FEATURE FEAT) [FUNCTION] · src
String → Void
Adds a feature feat to cl:*features*.
(ARCHITECTURE) [FUNCTION] · src
Void → String
The system’s architecture (stored at compile time).
(ARGV0) [FUNCTION] · src
The first command line argument (stored at compile time).
(CMD-ARGS) [FUNCTION] · src
The current command line arguments (stored at compile time).
(FEATURES) [FUNCTION] · src
Returns a list of active features, from cl:*features*.
(GC) [FUNCTION] · src
Void → Void
Perform a full garbage collection.
(GET-REAL-TIME) [FUNCTION] · src
Void → Integer
Gets the real-time in internal time units. The difference between two successive calls to this function represents the time that has elapsed.
(GETENV VAR) [FUNCTION] · src
Gets the value of the environmental variable var, errors if var doesn’t exist.
(HOSTNAME) [FUNCTION] · src
Void → String
Returns the system’s hostname. This is a function because the hostname can be redefined.
(IMPLEMENTATION) [FUNCTION] · src
Void → String
The lisp implementation (stored at compile time).
(LISP-VERSION) [FUNCTION] · src
Void → String
The lisp implementation version (stored at compile time).
(MONOTONIC-BYTES-CONSED) [FUNCTION] · src
Returns the number of bytes consed since some unspecified point in time.
The difference between two successive calls to this function represents the number of bytes consed in that period of time.
(OS) [FUNCTION] · src
Void → String
The system’s operating system (stored at compile time).
(SETENV! VAR VAL) [FUNCTION] · src
Sets an environment variable var to string val, only if var already exists.
(SLEEP N) [FUNCTION] · src
∀ :A. Rational :A ⇒ :A → Void
Sleep for n seconds, where n can be of any type with an instance of Rational.
Sleep uses type class Rational’s best-approx instead of Real’s real-approx because it handles the approximation without arbitrary precision. The only Real type excluded by this decision is CReal.
(SPACE F) [FUNCTION] · src
∀ :A. (Void → :A) → :A * Optional Integer
Run the thunk f and return its value along with the approximate number of bytes consed during the course of executing f.
The amount of space used may be peculiar to the implementation, such as rounding to certain page boundaries.
A garbage collection will be forced prior to invoking f.
(SPACETIME F) [FUNCTION] · src
∀ :A. (Void → :A) → MeteredResult :A
Runs a function, gathering space and timing information and returning a MeteredResults object.
Garbage collection will be performed before profiling is performed.
(TIME F) [FUNCTION] · src
∀ :A. (Void → :A) → :A * Integer
Run the thunk f and return its value along with the run time in microseconds.
While the result will always contain microseconds, some implementations may return a value rounded to less precision (e.g., rounded to the nearest second or millisecond).
(TIME-UNITS->ROUNDED-MICROSECONDS T) [FUNCTION] · src
Converts internal time units into an integer number of rounded microseconds.
(TIME-UNITS->SECONDS T) [FUNCTION] · src
Converts internal time units into Fraction seconds.
INTERNAL-TIME-UNITS-PER-SECOND [VALUE] · src
The number of internal time units per second. This is implementation specific.
Package COALTON/TUPLE
Structs
Tuple3 #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :B> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :C> [STRUCT] · src
FIRST :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A>SECOND :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :B>THIRD :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :C>
Instances
Tuple4 #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :B> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :C> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :D> [STRUCT] · src
FIRST :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A>SECOND :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :B>THIRD :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :C>FOURTH :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :D>
Instances
Tuple5 #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :B> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :C> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :D> #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :E> [STRUCT] · src
FIRST :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :A>SECOND :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :B>THIRD :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :C>FOURTH :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :D>FIFTH :: #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :E>
Instances
Values
(FST (TUPLE A _)) [FUNCTION] · src
∀ :A :B. Tuple :A :B → :A
Get the first element of a tuple.
(SEQUENCE-TUPLE (TUPLE A? B?)) [FUNCTION] · src
∀ :M :A :B. Monad :M ⇒ Tuple (:M :A) (:M :B) → :M (Tuple :A :B)
Flatten a Tuple of wrapped-values. Particularly useful for types like (Tuple (Optional :a) (Optional :b)), etc.
(SEQUENCE-TUPLE3 (TUPLE3 A? B? C?)) [FUNCTION] · src
∀ :M :A :B :C. Monad :M ⇒ Tuple3 (:M :A) (:M :B) (:M :C) → :M (Tuple3 :A :B :C)
Flatten a Tuple of wrapped-values. Particularly useful for types like (Tuple (Optional :a) (Optional :b)), etc.
(SEQUENCE-TUPLE4 (TUPLE4 A? B? C? D?)) [FUNCTION] · src
∀ :M :A :B :C :D. Monad :M ⇒ Tuple4 (:M :A) (:M :B) (:M :C) (:M :D) → :M (Tuple4 :A :B :C :D)
Flatten a Tuple of wrapped-values. Particularly useful for types like (Tuple (Optional :a) (Optional :b)), etc.
(SEQUENCE-TUPLE5 (TUPLE5 A? B? C? D? E?)) [FUNCTION] · src
∀ :M :A :B :C :D :E. Monad :M ⇒ Tuple5 (:M :A) (:M :B) (:M :C) (:M :D) (:M :E) → :M (Tuple5 :A :B :C :D :E)
Flatten a Tuple of wrapped-values. Particularly useful for types like (Tuple (Optional :a) (Optional :b)), etc.
(SND (TUPLE _ B)) [FUNCTION] · src
∀ :A :B. Tuple :A :B → :B
Get the second element of a tuple.
Package COALTON/TYPES
Types
LispType [TYPE] · src
The runtime representation of a Coalton type as a Lisp type.
Proxy [TYPE] · src
Proxy
Proxy holds no data, but has a phantom type parameter.
Instances
RuntimeRepr (Proxy :A)Show (Proxy :A)
TypeScheme [TYPE] · src
An opaque reflection object representing a Coalton type scheme.
Instances
Classes
RuntimeRepr [CLASS] · src
RuntimeRepr :A
Types which have a runtime LispType representation.
The compiler will auto-generate instances of RuntimeRepr for all defined types.
Methods:
RUNTIME-REPR :: Proxy :A → LispType
The type emitted by the Coalton compiler for the type parameter to the given Proxy.
Instances
RuntimeRepr RealAlgebraicRuntimeRepr (Poly :|0|)RuntimeRepr CRealRuntimeRepr Big-FloatRuntimeRepr RoundingModeRuntimeRepr (Hyperdual :|0|)RuntimeRepr (Dual :|0|)RuntimeRepr DyadicRuntimeRepr OpenDirectionRuntimeRepr IfExistsRuntimeRepr (FileStream :|0|)RuntimeRepr FileErrorRuntimeRepr PathnameRuntimeRepr LispConditionRuntimeRepr (MeteredResult :|0|)RuntimeRepr (Seq :|0|)RuntimeRepr (OrdMap :|0| :|1|)RuntimeRepr (MapPair :|0| :|1|)RuntimeRepr (OrdTree :|0|)RuntimeRepr (LoopT :|0| :|1|)RuntimeRepr (Step :|0|)RuntimeRepr (FreeT :|0| :|1| :|2|)RuntimeRepr (FreeF :|0| :|1| :|2|)RuntimeRepr (Free :|0| :|1|)RuntimeRepr (OptionalT :|0| :|1|)RuntimeRepr (ResultT :|0| :|1| :|2|)RuntimeRepr (EnvT :|0| :|1| :|2|)RuntimeRepr (Env :|0| :|1|)RuntimeRepr (StateT :|0| :|1| :|2|)RuntimeRepr (ST :|0| :|1|)RuntimeRepr (Identity :|0|)RuntimeRepr (Queue :|0|)RuntimeRepr InsertionModeRuntimeRepr (HashMap :|0| :|1|)RuntimeRepr (HmNode :|0| :|1|)RuntimeRepr (HmEntry :|0| :|1|)RuntimeRepr (HashTable :|0| :|1|)RuntimeRepr (Slice :|0|)RuntimeRepr (Vector :|0|)RuntimeRepr :T ⇒ RuntimeRepr (LispArray :T)RuntimeRepr (LispArrayBuilder :|0|)RuntimeRepr RangeStatusRuntimeRepr (Iterator :|0|)RuntimeRepr (Tuple5 :|0| :|1| :|2| :|3| :|4|)RuntimeRepr (Tuple4 :|0| :|1| :|2| :|3|)RuntimeRepr (Tuple3 :|0| :|1| :|2|)RuntimeRepr (Cell :|0|)RuntimeRepr :T ⇒ RuntimeRepr (Complex :T)RuntimeRepr (Quantization :|0|)RuntimeRepr SymbolRuntimeRepr %OutputStreamRuntimeRepr (Tuple :|0| :|1|)RuntimeRepr OrderingRuntimeRepr HashRuntimeRepr (Result :|0| :|1|)RuntimeRepr UFixRuntimeRepr IFixRuntimeRepr I64RuntimeRepr I32RuntimeRepr I16RuntimeRepr I8RuntimeRepr U64RuntimeRepr U32RuntimeRepr U16RuntimeRepr U8RuntimeRepr BitRuntimeRepr (Proxy :A)RuntimeRepr LispTypeRuntimeRepr (Optional :A)RuntimeRepr (List :A)RuntimeRepr (:A → :B)RuntimeRepr FractionRuntimeRepr StringRuntimeRepr F64RuntimeRepr F32RuntimeRepr IntegerRuntimeRepr CharRuntimeRepr Boolean
Values
(AS-PROXY-OF X _) [FUNCTION] · src
∀ :A. :A * Proxy :A → :A
Returns the parameter, forcing the proxy to have the same type as the parameter.
(PROXY-INNER _) [FUNCTION] · src
∀ :A :B. Proxy (:A :B) → Proxy :B
(PROXY-OF _) [FUNCTION] · src
∀ :A. :A → Proxy :A
Returns a Proxy containing the type of the parameter.
(RUNTIME-REPR-OF _) [FUNCTION] · src
∀ :A. RuntimeRepr :A ⇒ :A → LispType
Returns the runtime representation of the type of the given value.
Package COALTON/UTILS
Values
(CONCAT-STRING A B) [FUNCTION] · src
Package COALTON/VECTOR
Resizable mutable vectors with efficient indexed access and amortized end updates.
Types
Vector [TYPE] · src
Instances
Default (Vector :A)Eq :A ⇒ Eq (Vector :A)Foldable VectorFromCollectionComprehension (Vector :A) :A (Vector :A)FromItemizedCollection (Vector :A) :A (Vector :A)FromIterator (Vector :A) :AFunctor VectorInto (List :A) (Vector :A)Into (Seq :A) (Vector :A)Into (Slice :A) (Vector :A)Into (Vector :A) (List :A)Into (Vector :A) (Slice :A)Into (Vector Char) StringInto String (Vector Char)IntoIterator (Vector :A) :AIso (Slice :A) (Vector :A)Iso (Vector :A) (List :A)Monoid (Vector :A)RandomAccess (Vector :T) :TRuntimeRepr (Vector :|0|)Semigroup (Vector :A)Show :A ⇒ Show (Vector :A)Sliceable (Vector :A)
Values
(APPEND V1 V2) [FUNCTION] · src
∀ :A. Vector :A * Vector :A → Vector :A
Create a new vector containing the elements of v1 followed by the elements of v2.
(CAPACITY V) [FUNCTION] · src
Returns the number of elements that v can store without resizing.
(CLEAR! V) [FUNCTION] · src
∀ :A. Vector :A → Void
Set the capacity of v to 0.
(COPY V) [FUNCTION] · src
Return a new vector containing the same elements as v.
(EMPTY? V) [FUNCTION] · src
Is v empty?
(EXTEND! VEC ITER) [FUNCTION] · src
∀ :ELT :CONTAINER. IntoIterator :CONTAINER :ELT ⇒ Vector :ELT * :CONTAINER → Void
Push every element in iter to the end of vec.
(FIND-ELEM E V) [FUNCTION] · src
∀ :A. Eq :A ⇒ :A * Vector :A → Optional UFix
Find the index of element e in v.
(HEAD V) [FUNCTION] · src
Return the first item of v.
(HEAD-UNSAFE V) [FUNCTION] · src
∀ :A. Vector :A → :A
Return the first item of v without first checking if v is empty.
(INDEX INDEX V) [FUNCTION] · src
∀ :A. UFix * Vector :A → Optional :A
Return the indexth element of v.
(INDEX-UNSAFE IDX V) [FUNCTION] · src
Return the idxth element of v without checking if the element exists.
(LAST V) [FUNCTION] · src
Return the last element of v.
(LAST-UNSAFE V) [FUNCTION] · src
∀ :A. Vector :A → :A
Return the last element of v without first checking if v is empty.
(LENGTH V) [FUNCTION] · src
Returns the length of v.
(NEW) [FUNCTION] · src
∀ :A. Void → Vector :A
Create a new empty vector
(POP! V) [FUNCTION] · src
Remove and return the last item of v.
(POP-UNSAFE! V) [FUNCTION] · src
∀ :A. Vector :A → :A
Remove and return the last item of v without checking if the vector is empty.
(PUSH! ITEM V) [FUNCTION] · src
Append item to v and resize v if necessary, returning the index of the new item.
(RESECT! V START END) [FUNCTION] · src
∀ :A. Vector :A * UFix * UFix → Void
Destructively kills a subsequence in a vector bounded by given indices.
start index is inclusive and end index is exclusive.
(REVERSE V) [FUNCTION] · src
Returns a fresh vector with the elements of vector v in reverse order. The original vector isn’t modified.
(REVERSE! V) [FUNCTION] · src
Returns a vector with the elements of vector v in reverse order. The original vector may be destroyed to produce the result.
(SET! IDX ITEM V) [FUNCTION] · src
∀ :A. UFix * :A * Vector :A → Void
Set the idxth element of v to item. This function left intentionally unsafe because it does not have a return value to check.
(SET-CAPACITY! NEW-CAPACITY V) [FUNCTION] · src
Set the capacity of v to new-capacity. Setting the capacity to lower then the length will remove elements from the end.
(SINGLETON X) [FUNCTION] · src
∀ :A. :A → Vector :A
Create a new vector with a single element equal to x
(SINGLETON? V) [FUNCTION] · src
Is v a singleton?
(SORT! V) [FUNCTION] · src
∀ :A. Ord :A ⇒ Vector :A → Void
Sort a vector in-place in ascending order.
(SORT-BY! F V) [FUNCTION] · src
∀ :A. (:A * :A → Boolean) * Vector :A → Void
Sort a vector in-place with predicate function f.
(SUBSEQ V START END) [FUNCTION] · src
∀ :A. Vector :A * UFix * UFix → Vector :A
Compute a subseq of a vector bounded by given indices.
start index is inclusive and end index is exclusive.
(SWAP-REMOVE! IDX VEC) [FUNCTION] · src
∀ :A. UFix * Vector :A → Optional :A
Remove the element idx from vec and replace it with the last element in vec. Then return the removed element.
(SWAP-REMOVE-UNSAFE! IDX VEC) [FUNCTION] · src
Remove the element idx from vec and replace it with the last element in vec without bounds checking. Then return the removed element.
(WITH-CAPACITY N) [FUNCTION] · src
Create a new vector with n elements preallocated.
(WITH-INITIAL-ELEMENT N X) [FUNCTION] · src
Create a new vector with n elements equal to x.
Macros
MAKE (&REST ELEMENTS) [MACRO]
Construct a `Vector’ containing the ELEMENTS, in the order listed.
Package COALTON/XMATH/BIG-FLOAT
Types
Big-Float [TYPE] · src
An arbitrary (but fixed) precision floating point number.
Instances
ComplexComponent Big-FloatDividable Integer Big-FloatElementary Big-FloatEq Big-FloatExponentiable Big-FloatInto F32 Big-FloatInto F64 Big-FloatInto Fraction Big-FloatInto Integer Big-FloatNum Big-FloatOrd Big-FloatPolar Big-FloatQuantizable Big-FloatRadical Big-FloatRational Big-FloatReal Big-FloatReciprocable Big-FloatRuntimeRepr Big-FloatTransfinite Big-FloatTrigonometric Big-Float
RoundingMode [TYPE] · src
Instances
Values
(BF-EE) [FUNCTION] · src
Void → Big-Float
Return the value of ee = exp(1) to the currently set precision.
(BF-PI) [FUNCTION] · src
Void → Big-Float
Return the value of pi to the currently set precision.
(GET-PRECISION) [FUNCTION] · src
Void → UFix
Get the current precision of Big-Float arithmetic.
(GET-ROUNDING-MODE) [FUNCTION] · src
Void → RoundingMode
Get the current rounding-mode of Big-Float arithmetic.
(SET-PRECISION! PREC-BITS) [FUNCTION] · src
UFix → Void
Set the precision of Big-Float arithmetic to PREC-BITS bits.
(SET-ROUNDING-MODE! R) [FUNCTION] · src
RoundingMode → Void
Set the global rounding mode for Big-Float operations.
(WITH-PRECISION F) [FUNCTION] · src
∀ :A. (Void → :A) &key (:precision UFix) → :A
Call F with a temporary Big-Float PRECISION.
(WITH-PRECISION-ROUNDING F) [FUNCTION] · src
∀ :A. (Void → :A) &key (:precision UFix) (:rounding RoundingMode) → :A
Call F with a temporary Big-Float PRECISION and ROUNDING mode.
(WITH-ROUNDING F) [FUNCTION] · src
∀ :A. (Void → :A) &key (:rounding RoundingMode) → :A
Call F with a temporary Big-Float ROUNDING mode.
RNDA [VALUE] · src
RouND Away from zero.
RNDD [VALUE] · src
RouND Down, toward negative infinity.
RNDF [VALUE] · src
Faithful rounding (experimental).
RNDN [VALUE] · src
RouND to Nearest, with the even rounding rule.
RNDNA [VALUE] · src
RouND to Nearest Away.
RNDU [VALUE] · src
RouND Up, toward positive infinity.
RNDZ [VALUE] · src
RouND toward Zero.
Package COALTON/XMATH/COMPUTABLE-REALS
Types
CReal [TYPE] · src
Instances
ComplexComponent CRealDividable Integer CRealElementary CRealEq CRealExponentiable CRealInto F32 CRealInto F64 CRealInto Fraction CRealInto I16 CRealInto I32 CRealInto I64 CRealInto I8 CRealInto IFix CRealInto Integer CRealInto U16 CRealInto U32 CRealInto U64 CRealInto U8 CRealInto UFix CRealNum CRealOrd CRealPolar CRealQuantizable CRealRadical CRealReal CRealReciprocable CRealRuntimeRepr CRealTrigonometric CReal
Values
(APPROX X K) [FUNCTION] · src
Computes an approximation of the bits of a given
CReal. Specifically, given an object of type CReal x and a
non-negative integer k, return an integer $a$ with
$$ \vert a\cdot 2^{-\mathtt{k}} - \mathtt{x}\vert \leq 2^{-\mathtt{k}}. $$
See rational or rationalize to produce a rational approximation of
CReal.
(COMPARISON-THRESHOLD) [FUNCTION] · src
Void → UFix
Returns the current CReal comparison threshold measured as a number
of bits after the ‘decimal’ point.
This threshold is used to ensure Eq and Ord instances
terminate. (In general, computable real arithmetic is undecidable.)
Note that if the production of a CReal depends on comparison, there
is no guarantee that the CReal will be accurate to any precision.
(CR-PRINT X K) [FUNCTION] · src
Prints a real x up to k bits of precision.
(RATIONAL-APPROX X K) [FUNCTION] · src
Produce a rational approximation of x called $r$ such that
$$ \vert r - \mathtt{x} \vert < 2^{-\mathtt{k}}. $$
(RATIONALIZE X K) [FUNCTION] · src
Produce a rational approximation of x called $r$ such that
$$ \vert r - \mathtt{x} \vert < 2^{-\mathtt{k}}, $$
taking into account the maximum precision specified by k to return
the simplest possible such approximation.
(SET-COMPARISON-THRESHOLD! K) [FUNCTION] · src
∀ :A. :A → Unit
Sets the global CReal comparison threshold to k bits after the ‘decimal’ point.
See comparison-threshold for more details.
(WITH-COMPARISON-THRESHOLD F) [FUNCTION] · src
∀ :A. (Void → :A) &key (:bits UFix) → :A
Call F with a temporary CReal comparison threshold of BITS.
Package COALTON/XMATH/DUAL
Dual numbers are a hypercomplex number system [1]. A dual number has the form $a + b\varepsilon$ where $a$ and $b$ are real numbers and $\varepsilon$ is a symbol that satisfies $\varepsilon^2=0$ and $\varepsilon\neq 0$. The value $a$ is often called the primal part and the value $b$ is often called the dual part. One application of dual numbers is automatic differentiation; an example taken from [2] is as follows.
Consider the function $f(x) = 3x+2$ and you want to calculate $f(4)$ and $f^{\prime}(4)$. By the usual rules of differentiation, we know $f^{\prime}(x) = 3$ and thus $(f(4), f^{\prime}(4)) = (14, 3)$. We seek to recover this with dual numbers.
With dual numbers, we can calculate
$$f(a) + f^{\prime}(a)\varepsilon$$
by taking a real-valued function $f$ and evaluating as if it were a dual-valued function at the point $a + \varepsilon$. Thus, for the defined $f$, we have:
$$ \begin{aligned} f(4 + \varepsilon) &= 3(4 + \varepsilon) + 2 \\ &= 3\cdot 4 + 3\varepsilon + 2 \\ &= 14 + 3\varepsilon. \end{aligned} $$
In this result, the primal $14$ is the value of $f(4)$ and the dual is the value of of $f^{\prime}(4)$.
Haskell has an automatic differentiation library and you can find it here [3].
Limitations:
We have decided to implement Ord, Eq, and Hash to look at only the primal part of numbers. This is so the Dual type can be used primarily for the purpose of automatic differentiation of existing code, and not for general abstract mathematics. If you need these type classes acting in the usual way (i.e., on both primal and dual parts), then we recommend making your own data type which wraps a dual number.
References:
- [1] https://en.wikipedia.org/wiki/Dual_number
- [2] https://blog.demofox.org/2014/12/30/dual-numbers-automatic-differentiation/
- [3] https://hackage.haskell.org/package/ad
Structs
Dual #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :T> [STRUCT] · src
Representation of a dual number in the form $a + b\varepsilon$ where $a$ and $b$ are real numbers and $\varepsilon$ satisfies $\varepsilon^2 = 0$ and $\varepsilon \neq 0$.
Note: Eq, and Ord and Hash only make use of the primal
component.
Instances
(Num :T) (Exponentiable :T) (Reciprocable :T) ⇒ Exponentiable (Dual :T)(Num :T) (Radical :T) (Reciprocable :T) (Exponentiable :T) ⇒ Radical (Dual :T)(Num :T) (Trigonometric :T) (Reciprocable :T) (Radical :T) ⇒ Trigonometric (Dual :T)Eq :T ⇒ Eq (Dual :T)
Note: Eq only compares the primal component.Hash :T ⇒ Hash (Dual :T)
Note: Hash only considers the primal component in order to be consistent with Eq.Num :T ⇒ Num (Dual :T)Ord :T ⇒ Ord (Dual :T)
Note: Ord only compares the primal component.Reciprocable :T ⇒ Reciprocable (Dual :T)RuntimeRepr (Dual :|0|)
Values
(DUAL-PART (DUAL _ D)) [FUNCTION] · src
∀ :T. Dual :T → :T
The dual (i.e., derivative) part of a dual number.
(PRIMAL-PART (DUAL P _)) [FUNCTION] · src
∀ :T. Dual :T → :T
The primal (i.e., real) part of a dual number.
Package COALTON/XMATH/DYADIC
Types
Dyadic [TYPE] · src
(Dyadic n k) represents the rational $\mathtt{n}\cdot 2^{\mathtt{k}}$.
Instances
Values
(SCALE X J) [FUNCTION] · src
Scales a dyadic x by $2^{\mathtt{k}}$.
(SHIFT K A) [FUNCTION] · src
Shift dyadic a to its floor with $\mathtt{k}+1$ bits of precision.
(SIMPLIFY D) [FUNCTION] · src
Simplifies a dyadic by maximizing the absolute value of the exponent.
(SIMPLIFY-INTEGER N) [FUNCTION] · src
Finds the simplest dyadic given an integer.
Package COALTON/XMATH/FFT
A coalton package for performing FFTs.
Classes
FFTCyclicGroup [CLASS] · src
A class of types, each of which is a mathematical cyclic group.
These are types which are valid elements for a collection which may undergo a discrete Fourier transform. Examples include complex floating-point numbers and finite (modular) integers.
Methods:
CYCLIC-ADD-IDENTITY :: :TCYCLIC-ADD :: :T * :T → :TCYCLIC-ADD-INVERSE :: :T → :TCYCLIC-NTH-GENERATOR :: UFix → :T
A function which returns a primitiventh root of unity.
Instances
FFTField [CLASS] · src
A class of types, each of which is a mathematical field.
These are types which are valid elements for a collection which may undergo a discrete Fourier transform. Examples include complex floating-point numbers and finite (modular) integers.
Methods:
MULTIPLY-INVERSE :: :T → :T
FFTGroup [CLASS] · src
FFTGroup :T
A class of types, each of which is a mathematical group.
These are types which are valid elements for a collection which may undergo a discrete Fourier transform. Examples include complex floating-point numbers and finite (modular) integers.
Methods:
ADD-IDENTITY :: :TADD :: :T * :T → :TADD-INVERSE :: :T → :T
FFTRing [CLASS] · src
A class of types, each of which is a mathematical ring.
These are types which are valid elements for a collection which may undergo a discrete Fourier transform. Examples include complex floating-point numbers and finite (modular) integers.
Methods:
MULTIPLY-IDENTITY :: :TMULTIPLY :: :T * :T → :T
Values
(DIF-FFT-RAW DST SRC) [FUNCTION] · src
∀ :T :C :D. (RandomAccess :C :T) (RandomAccess :D :T) (FFTRing :T) (FFTCyclicGroup :T) ⇒ :C * :D → Void
A decimation-in-frequency fast fourier transform, reading from src and writing to dst.
Input: natural order Output: bit-reversed order Normalization: none
(DIF-IFFT-RAW DST SRC) [FUNCTION] · src
∀ :T :C :D. (RandomAccess :C :T) (RandomAccess :D :T) (FFTRing :T) (FFTCyclicGroup :T) ⇒ :C * :D → Void
A decimation-in-frequency inverse fast fourier transform, reading from src and writing to dst.
Input: natural order Output: bit-reversed order Normalization: none
(DIT-FFT-RAW DST SRC) [FUNCTION] · src
∀ :T :C :D. (RandomAccess :C :T) (RandomAccess :D :T) (FFTRing :T) (FFTCyclicGroup :T) ⇒ :C * :D → Void
A decimation-in-time fast fourier transform, reading from src and writing to dst.
Input: bit-reversed order Output: natural order Normalization: none
(DIT-IFFT-RAW DST SRC) [FUNCTION] · src
∀ :T :C :D. (RandomAccess :C :T) (RandomAccess :D :T) (FFTRing :T) (FFTCyclicGroup :T) ⇒ :C * :D → Void
A decimation-in-time inverse fast fourier transform, reading from src and writing to dst.
Input: bit-reversed order Output: natural order Normalization: none
(DIVIDE X Y) [FUNCTION] · src
∀ :T. FFTField :T ⇒ :T * :T → :T
(FFT STORAGE) [FUNCTION] · src
∀ :T :C :D. (RandomAccess :C :T) (RandomAccess :D :T) (FFTRing :T) (FFTCyclicGroup :T) ⇒ :C → :D
Perform a fast Fourier transform on the data in storage.
(FFT! STORAGE) [FUNCTION] · src
∀ :T :C. (RandomAccess :C :T) (FFTRing :T) (FFTCyclicGroup :T) ⇒ :C → :C
Perform an in-place fast Fourier transform on storage.
(FFT-INTO! DST SRC) [FUNCTION] · src
∀ :T :D :C. (RandomAccess :C :T) (RandomAccess :D :T) (FFTRing :T) (FFTCyclicGroup :T) ⇒ :D * :C → :D
Perform a fast Fourier transform of src, writing the result to dst. If dst is longer than src, then remaining elements of dst are left unmutated.
(IFFT STORAGE) [FUNCTION] · src
∀ :T :C :D. (RandomAccess :C :T) (RandomAccess :D :T) (FFTField :T) (FFTCyclicGroup :T) (Num :T) ⇒ :C → :D
Perform an inverse fast Fourier transform on the data in storage.
(IFFT! STORAGE) [FUNCTION] · src
∀ :T :C. (RandomAccess :C :T) (FFTField :T) (FFTCyclicGroup :T) (Num :T) ⇒ :C → :C
Perform an in-place inverse fast Fourier transform on storage.
(IFFT-INTO! DST SRC) [FUNCTION] · src
∀ :T :D :C. (RandomAccess :C :T) (RandomAccess :D :T) (FFTField :T) (FFTCyclicGroup :T) (Num :T) ⇒ :D * :C → :D
Perform an inverse fast Fourier transform of src, writing the result to dst. If dst is longer than src, then remaining elements of dst are left unmutated.
(SUBTRACT X Y) [FUNCTION] · src
∀ :T. FFTGroup :T ⇒ :T * :T → :T
Package COALTON/XMATH/HYPERDUAL
An implementation of hyperdual numbers for second-order and multivariate automatic differentiation.
——————————————————————————————————————————————–
For univariate differentiation of a function f at a point x, apply
f to (Hyperdual x 1 1 0). The result will be
(Hyperdual f(x) df/dx(x) df/dx(x) d²f/dx²(x)).
You may also use the convenience functions d-x and d-xx to compute
the first and second derivatives as (d-x f x) and (d-xx f x).
——————————————————————————————————————————————–
For multivariate differentiation of a function f at a point (x, y), an application of f to (Hyperdual x 1 0 0) and
(Hyperdual y 0 1 0) will result in
(Hyperdual f(x, y) ∂f/∂x(x, y) ∂f/∂y(x, y) ∂²f/∂x∂y(x, y)).
Second derivatives of a single argument xi of f are computed in
the same manner as the univariate case, except the values
(Hyperdual xj 0 0 0) are passed for the remaining arguments, j ≠ i.
You may also use the convenience functions partial-x, partial-y,
gradient, partial-xx, partial-xy, partial-yy, hessian, and
laplacian, to compute partials of bivariate functions.
——————————————————————————————————————————————–
The following list of identities describe the theory of hyperdual numbers.
:: given (∀i∀j((i ≠ j) → (εᵢεⱼ ≠ 0)) ∧ ∀i(εᵢ² = 0))
——————————————————————————————————————————————–
:: univariate identities
(1) f(a + bε₁ + cε₂ + dε₁ε₂) = f(a) + (bε₁+cε₂+dε₁ε₂)f’(a) + bcε₁ε₂f’’(a) = f(a) + bf’(a)ε₁ + cf’(a)ε₂ + [df’(a) + bcf’’(a)]ε₁ε₂
(2) f(x + ε₁ + ε₂) = f(x) + f’(x)ε₁ + f’(x)ε₂ + f’’(x)ε₁ε₂
:: multivariate identities
(3) f(a₁ + b₁ε₁ + c₁ε₂ + d₁ε₁ε₂, a₂ + b₂ε₁ + c₂ε₂ + d₂ε₁ε₂) = f(a₁, a₂) + (b₁ε₁ + c₁ε₂ + d₁ε₁ε₂)∂f/∂x(a₁, a₂) + b₁c₁ε₁ε₂∂²f/∂x²(a₁, a₂) + (b₂ε₁ + c₂ε₂ + d₂ε₁ε₂)∂f/∂y(a₁, a₂) + b₂c₂ε₁ε₂∂²f/∂y² + (b₁c₂ + b₂c₁)ε₁ε₂∂²f/∂x∂y(a₁, a₂) = f(a₁, a₂) + (b₁∂f/∂x(a₁, a₂) + b₂∂f/∂y(a₁, a₂))ε₁ + (c₁∂f/∂x(a₁, a₂) + c₂∂f/∂y(a₁, a₂))ε₂ + (d₁∂f/∂x(a₁, a₂) + d₂∂f/∂y(a₁, a₂) + b₁c₁∂²f/∂x²(a₁, a₂) + b₂c₂∂²f/∂x²(a₁, a₂) + (b₁c₂ + b₂c₁)∂²f/∂x∂y(a₁, a₂))ε₁ε₂
(4) f(x + ε₁ + ε₂, y) = f(x, y) + ∂f/∂x(x, y)ε₁ + ∂f/∂x(x, y)ε₂ + ∂²f/∂x²(x, y)ε₁ε₂
(5) f(x + ε₁, y + ε₂) = f(x, y) + ∂f/∂x(x, y)ε₁ + ∂f/∂y(x, y)ε₂ + ∂²f/∂x∂y(x, y)ε₁ε₂
(6) f(x, y + ε₁ + ε₂) = f(x, y) + ∂f/∂y(x, y)ε₁ + ∂f/∂y(x, y)ε₂ + ∂²f/∂y²(x, y)ε₁ε₂
:: equivalently
(1) (f (Hyperdual a b c d)) = (Hyperdual (f a) (* b (f’ a)) (* c (f’ a)) (+ (* d (f’ a)) (* (* b c) (f’’ a))))
(2) (f (Hyperdual x 1 1 0)) = (Hyperdual (f x) (f’ x) (f’ x) (f’’ x))
(3) (f (Hyperdual a1 b1 c1 d1) (Hyperdual a2 b2 c2 d2)) = (Hyperdual (f a1 a2) (+ (* b1 (∂f/∂x a1 a2)) (* b2 (∂f/∂y a1 a2))) (+ (* c1 (∂f/∂x a1 a2)) (* c2 (∂f/∂y a1 a2))) (+ (+ (* d1 (∂f/∂x a1 a2)) (* d2 (∂f/∂y a1 a2))) (+ (* (* b1 c1) (∂²f/∂x² a1 a2)) (* (* b2 c2) (∂²f/∂y² a1 a2))) (* (+ (* b1 c2) (* b2 c1)) (∂²f/∂x∂y a1 a2)))
(4) (f (Hyperdual x 1 1 0) (Hyperdual y 0 0 0)) = (Hyperdual (f x y) (∂f/∂x x y) (∂f/∂x x y) (∂²f/∂x² x y))
(5) (f (Hyperdual x 1 0 0) (Hyperdual y 0 1 0)) = (Hyperdual (f x y) (∂f/∂x x y) (∂f/∂y x y) (∂²f/∂x∂y x y))
(6) (f (Hyperdual x 0 0 0) (Hyperdual y 1 1 0)) = (Hyperdual (f x y) (∂f/∂x x y) (∂f/∂x x y) (∂²f/∂x² x y))
Structs
Hyperdual #<COALTON-IMPL/TYPECHECKER/TYPES:TYVAR :T> [STRUCT] · src
Representation of a hyperdual number in the form a + bε₁ + cε₂ + dε₁ε₂ where a, b, c, and d are real numbers and ε₁ and ε₂ satisfy εᵢ² = 0 and ε₁ε₂ != 0.
Note: Eq, and Ord and Hash only make use of the primal component.
Instances
(Exponentiable :T) (Reciprocable :T) ⇒ Exponentiable (Hyperdual :T)(Radical :T) (Reciprocable :T) (Exponentiable :T) ⇒ Radical (Hyperdual :T)(Trigonometric :T) (Reciprocable :T) (Radical :T) ⇒ Trigonometric (Hyperdual :T)ComplexComponent :T ⇒ ComplexComponent (Hyperdual :T)Eq :T ⇒ Eq (Hyperdual :T)Hash :T ⇒ Hash (Hyperdual :T)Num :T ⇒ Into :T (Hyperdual :T)Num :T ⇒ Num (Hyperdual :T)Ord :T ⇒ Ord (Hyperdual :T)Reciprocable :T ⇒ Reciprocable (Hyperdual :T)RuntimeRepr (Hyperdual :|0|)
Values
(D-X F X) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T → Hyperdual :T) * :T → :T
Compute f’(x).
(D-XX F X) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T → Hyperdual :T) * :T → :T
Compute f’’(x).
(GRADIENT F X Y) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T * Hyperdual :T → Hyperdual :T) * :T * :T → List :T
Compute the gradient (∂f/∂x, ∂f/∂y) at the point (x, y).
(HESSIAN F X Y) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T * Hyperdual :T → Hyperdual :T) * :T * :T → List :T
Compute the flat Hessian (∂²f/∂x², ∂²f/∂x∂y, ∂²f/∂y∂x, ∂²f/∂y²) at the point (x, y).
(LAPLACIAN F X Y) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T * Hyperdual :T → Hyperdual :T) * :T * :T → :T
Compute the Laplacian ∂²f/∂x² + ∂²f/∂y² at the point (x, y).
(PARTIAL-X F X Y) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T * Hyperdual :T → Hyperdual :T) * :T * :T → :T
Compute ∂f/∂x(x, y).
(PARTIAL-XX F X Y) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T * Hyperdual :T → Hyperdual :T) * :T * :T → :T
Compute ∂²f/∂x²(x, y).
(PARTIAL-XY F X Y) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T * Hyperdual :T → Hyperdual :T) * :T * :T → :T
Compute ∂²f/∂x∂y(x, y).
(PARTIAL-Y F X Y) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T * Hyperdual :T → Hyperdual :T) * :T * :T → :T
Compute ∂f/∂y(x, y).
(PARTIAL-YY F X Y) [FUNCTION] · src
∀ :T. Num :T ⇒ (Hyperdual :T * Hyperdual :T → Hyperdual :T) * :T * :T → :T
Compute ∂²f/∂y²(x, y).
Package COALTON/XMATH/REALALGEBRAIC
Certified real algebraic numbers.
A real algebraic number is represented as a square-free primitive polynomial over Z together with a rational isolating interval certified by Sturm’s theorem. Arithmetic is implemented via resultant-based elimination, and all operations (construction, comparison, root selection) are exact.
Construct values with root (single root from polynomial + interval),
real-roots (all roots of a polynomial), fromInt, or into. Extract
rational values with tryInto. Standard numeric type class instances are
provided: Eq, Ord, Num, Reciprocable, Radical, Quantizable, and Real.
Structs
RealAlgebraic [STRUCT] · src
Certified real algebraic number.
poly is a square-free primitive defining polynomial in descending degree
order. (lo, hi) is a rational open interval that isolates exactly one real
root of poly. sturm caches a Sturm sequence for poly.
Instances
Values
(DECIMAL-STRING DIGITS X) [FUNCTION] · src
UFix * RealAlgebraic → String
Render a fixed-point decimal approximation of x.
digits is the number of digits after the decimal point. Rounding is half-up
and computed from exact rational arithmetic.
(ISOLATING-INTERVAL X) [FUNCTION] · src
RealAlgebraic → Tuple Fraction Fraction
Return the current rational isolating interval (lo, hi) for x.
(RATIONAL? X) [FUNCTION] · src
Return True when x is rational, decided by the rational root theorem.
(REAL-ROOTS COEFFS) [FUNCTION] · src
List Integer → Result String (List RealAlgebraic)
Isolate all distinct real roots of a polynomial.
COEFFS is a list of integer coefficients in descending degree order.
(REFINE X) [FUNCTION] · src
Return a strictly tighter certified isolating interval for x.
(REFINE-TO-WIDTH WIDTH X) [FUNCTION] · src
Fraction * RealAlgebraic → RealAlgebraic
Refine x until its isolating interval width is at most width.
width must be positive.
(ROOT COEFFS LO HI) [FUNCTION] · src
List Integer * Fraction * Fraction → Result String RealAlgebraic
Construct a real algebraic number from a polynomial and isolating interval.
COEFFS is a list of integer coefficients in descending degree order. The
rational interval (lo, hi) must isolate exactly one real root of the
polynomial.
(SHOW X) [FUNCTION] · src
Render a human-readable representation of x as a string.
Exposes the defining polynomial and current isolating interval, useful for debugging, proof traces, and serialization diagnostics.