Library Documentation
Add
Add two values together, returning the sum.
Add : left right (infer sum) => trait (left right -> sum)
instance (Add Number Number Number)
[default] [error] instance (Add left right sum)
[error] instance (Add () right sum)
instance (Add String String String) all?
Returns True if the condition is True for all items in the sequence, or if the sequence is empty.
all? :: (element -> Boolean) -> collection -> Boolean where (As-Sequence collection element) always
Create a sequence that always produces the provided element.
Example:
my-sequence : always "Hello, world!"
show (next my-sequence) -- Hello, world!
show (next my-sequence) -- Hello, world!
show (next my-sequence) -- Hello, world!
always :: element -> Sequence element And
Returns True if both sides are True.
And : left (infer right) (infer output) => trait (left {right} -> output)
instance (And Boolean Boolean Boolean) Angle
An angle represented in degrees.
Angle : type {degrees :: Number} any?
Returns True if the condition is True for any item in the sequence, or False if the sequence is empty.
any? :: (element -> Boolean) -> collection -> Boolean where (As-Sequence collection element) append
Add a new item to the end of a list, producing a new list.
append :: element -> (List element) -> List element As-Sequence
Convert a collection into a sequence.
As-Sequence : container (infer element) => trait (container -> Sequence element)
instance (As-Sequence (Dictionary key value) (key; value))
instance (As-Sequence (Set element) element)
instance (As-Sequence (Stride Number) Number)
[default] [error] instance (As-Sequence container element)
instance (As-Sequence (Sequence element) element)
instance (As-Sequence (Maybe element) element)
instance (As-Sequence (List element) element)
instance (As-Sequence String String) Boolean
Represents either True or False.
Boolean : type {
False
True
} build-sequence
Build a sequence from an initial item and a transform function.
build-sequence :: (Maybe element) (element -> Maybe element) -> Sequence element ceil
Round up a number to the nearest integer.
ceil :: Number -> Number collect
Collect a sequence into a single container, like a list.
collect :: input -> output where (As-Sequence input element) (From-Sequence element output) (output :: List element) contains?
Returns True if the collection contains the element.
contains? :: element -> collection -> Boolean where (Container collection element) Control-Flow
Used by repeat to determine whether to continue running or stop with a value.
Control-Flow : state result => type {
Continue state
Stop result
} cos
Calculate the cosine of an angle.
cos :: Angle -> Number count
Count the number of items in a sequence.
count :: collection -> Number where (As-Sequence collection element) degrees
An angle in degrees.
degrees :: Number -> Angle Describe
Produce a String describing the value.
Describe : value => trait (value -> String)
[default] [error] instance (Describe value)
instance (Describe String)
instance (Describe Number)
instance (Describe Boolean)
instance (Describe (Maybe value)) where (Describe value) Dictionary
A collection of unique keys associated with values.
Dictionary : key value => type {
size :: Number
entries :: List (Maybe (key; value))
} Divide
Divide two numbers, returning the quotient.
Divide : left right (infer quotient) => trait (left right -> quotient)
instance (Divide Number Number Number)
[default] [error] instance (Divide left right quotient)
[error] instance (Divide () right quotient) divisible-by?
Check if the first number is divisible by the second.
divisible-by? :: Number -> Number -> Boolean Dropdown
Display a dropdown with the provided options.
Dropdown : type {value :: String} each
Perform an action for each item in a sequence.
each :: (element -> ()) -> container -> () where (As-Sequence container element) entry
Retrieve the value for a key stored in a dictionary.
entry :: key -> (Dictionary key value) -> Maybe value where (Equal key) (Hash key) enumerate
Create a sequence that maintains a counter indicating the number of elements
produced. For example, enumerate ("a", "b", "c") produces (0; "a"),
(1; "b"), and (2; "c").
enumerate :: collection -> Sequence (Number; element) where (As-Sequence collection element) Equal
Returns True if two values are equal.
Equal : value => trait (value value -> Boolean)
instance (Equal String)
instance (Equal Number)
instance (Equal ())
instance (Equal Boolean) extend
Append the contents of a sequence to a collection.
extend :: from -> container -> container where (As-Sequence from element) (Extend container element) external
Send a message to the runtime.
external :: String input -> output where (As-External input) (From-External output) (output :: ()) filter
Keep only the items in the sequence that satisfy the provided condition.
filter :: (element -> Boolean) -> container -> Sequence element where (As-Sequence container element) filter-by
Transform each item in a sequence, keeping only the items that aren't None.
filter-by :: (element -> Maybe result) -> container -> Sequence result where (As-Sequence container element) find
Find the first item in a sequence that satisfies a condition.
find :: (element -> Boolean) -> collection -> Maybe element where (As-Sequence collection element) find-by
Find the first item in a sequence that can be transformed into a Some value.
find-by :: (element -> Maybe result) -> collection -> Maybe result where (As-Sequence collection element) find-position
Find the position of the first item in a sequence that satisfies a condition.
find-position :: (element -> Boolean) -> collection -> Maybe Number where (As-Sequence collection element) first
Retrieve the first item inside a list, or None if the list is empty.
first :: (List element) -> Maybe element flatten
Flatten a sequence of sequences.
flatten :: outer -> Sequence element where (As-Sequence outer inner) (As-Sequence inner element) floor
Round down a number to the nearest integer.
floor :: Number -> Number forever
Repeat forever.
forever :: Forever Greater-Than
Returns True if the left side is greater than the right side.
Greater-Than : value => trait (value value -> Boolean)
instance (Greater-Than value) where (Order value) Greater-Than-Or-Equal
Returns True if the left side is greater than or equal to the right side.
Greater-Than-Or-Equal : value => trait (value value -> Boolean)
instance (Greater-Than-Or-Equal value) where (Order value) Hash
Convert the components of a value into a number used by Dictionary and
Set to organize their elements.
Hash : value => trait (value -> Number)
instance (Hash Number)
instance (Hash String)
instance (Hash ()) if
Make a choice based on whether the input is True or False.
if :: (condition :: Boolean) {(then :: value)} {(else :: value)} -> (output :: value) initial
Retrieve all but the last item inside a list, or None if the list is empty.
initial :: (List element) -> Maybe (List element) Initial
Represents the default or initial value of a type.
Initial : value => trait value
instance (Initial (Dictionary key value))
instance (Initial (Set element))
[default] [error] instance (Initial value)
instance (Initial Number)
instance (Initial String)
instance (Initial Boolean)
instance (Initial (Maybe value))
instance (Initial (List element)) insert
Add a new element to a set, returning a new set.
insert :: element -> (Set element) -> Set element where (Equal element) (Hash element) insert-at
Insert a new item at a particular location inside a list, shifting the elements from that location on one place to the right, producing a new list.
insert-at :: Number element -> (List element) -> Maybe (List element) insert-entry
Add a new entry to a dictionary, returning a new dictionary.
insert-entry :: key value -> (Dictionary key value) -> Dictionary key value where (Equal key) (Hash key) join
Collect two sequences into a single value.
join :: a b -> c where (As-Sequence a element) (As-Sequence b element) (From-Sequence element c) (c :: a) last
Retrieve the last item inside a list, or None if the list is empty.
last :: (List element) -> Maybe element Less-Than
Returns True if the left side is less than the right side.
Less-Than : value => trait (value value -> Boolean)
instance (Less-Than value) where (Order value) Less-Than-Or-Equal
Returns True if the left side is less than or equal to the right side.
Less-Than-Or-Equal : value => trait (value value -> Boolean)
instance (Less-Than-Or-Equal value) where (Order value) max
Returns the larger of the two inputs.
max :: n n -> n where (Order n) min
Returns the smaller of the two inputs.
min :: n n -> n where (Order n) Mismatched
Resolved by the compiler for all type mismatches, so you can write better error messages for your types.
Mismatched : actual expected => trait () Multiply
Multiply two values together, returning the product.
Multiply : left right (infer product) => trait (left right -> product)
instance (Multiply Number Number Number)
[default] [error] instance (Multiply left right product)
[error] instance (Multiply () right product) nan
The number returned from calculations whose result is not a number (eg. dividing by zero).
nan :: Number negate
Negate the sign of a number.
negate :: Number -> Number next
Retrieve the next item in a sequence.
next :: (Sequence element) -> Maybe element not
Returns False if provided True, and vice versa. Can also be used on
boolean functions and any other value that implements Not.
not :: value -> value where (Not value) (value :: Boolean) Not
Represents the logical inverse of a value.
Not : value => trait (value -> value)
instance (Not Boolean)
instance (Not (a -> b)) where (Not b) (b :: Boolean) Not-Equal
Returns True if two values are not equal.
Not-Equal : value => trait (value value -> Boolean)
instance (Not-Equal value) where (Equal value) nth
Retrieve the value in a list at a particular location, if it exists.
nth :: Number -> (List element) -> Maybe element Or
Returns True if either side is True.
Or : left (infer right) (infer output) => trait (left {right} -> output)
instance (Or Boolean Boolean Boolean)
instance (Or (Maybe value) value value) Order
Implement this trait to enable comparisons between two values of your type.
Order : value => trait (value value -> Ordering)
[default] [error] instance (Order value)
instance (Order Number) Ordering
The result of a comparison between two values.
Ordering : type {
Is-Less-Than
Is-Equal-To
Is-Greater-Than
} Power
Raise one number to the power of the other number.
Power : left right (infer power) => trait (left right -> power)
instance (Power Number Number Number)
[default] [error] instance (Power left right power)
[error] instance (Power () right power) prompt
Ask the user to enter a value.
prompt :: String -> value where (value :: String) (Read value) random
Produce a random value.
random :: result where (Random () result) random-in
Produce a random value within the provided range.
random-in :: range -> result where (Random range result) Range
A continuous range between two numbers. Each bound may be nan to
indicate that the range is unbounded in that direction.
Range : index => type {
min :: index
max :: index
} Read
Convert from a String to a value.
Read : value => trait (String -> Maybe value)
[default] [error] instance (Read value)
instance (Read String)
instance (Read Number) reduce
Reduce a sequence down to a single item.
reduce :: result (result element -> result) -> container -> result where (As-Sequence container element) Remainder
Divide two numbers, returning the remainder.
Remainder : left right (infer remainder) => trait (left right -> remainder)
instance (Remainder Number Number Number)
[default] [error] instance (Remainder left right remainder)
[error] instance (Remainder () right remainder) remove
Remove an element from a set, returning a new set.
remove :: element -> (Set element) -> Set element where (Equal element) (Hash element) remove-at
Remove the item at a particular location inside a list, producing a new list.
remove-at :: Number -> (List element) -> Maybe (List element) remove-entry
Remove an entry from a dictionary by its key, returning a new dictionary.
remove-entry :: key -> (Dictionary key value) -> Dictionary key value where (Equal key) (Hash key) repeat
Run code repeatedly.
repeat :: state {body} -> result where (Repeat-Predicate state body result) Repeat-Predicate
Determines whether to evaluate a repeat body again.
Repeat-Predicate : state body result => trait (state -> Control-Flow (body -> state) result)
instance (Repeat-Predicate (With-Control-Flow result) (Control-Flow () result) result)
instance (Repeat-Predicate While body ()) where (body :: ())
instance (Repeat-Predicate Forever body result) where (result :: ())
[error] instance (Repeat-Predicate (state :: Number) body result)
instance (Repeat-Predicate Times body ()) where (body :: ()) replicate
Create a sequence that produces the provided element a certain number of
times. element . replicate n is equivalent to always element . take n.
replicate :: Number -> element -> Sequence element sequence
Create a sequence.
sequence :: {Maybe element} -> Sequence element Sequence
A container for a sequence that produces the next value on demand.
Sequence : element => type {next :: {Maybe element}} Set
An unordered collection of unique elements.
Set : element => type {dictionary :: Dictionary element ()} show
Display a value on the screen.
show :: value -> () where (Describe value) sin
Calculate the sine of an angle.
sin :: Angle -> Number split
Split a sequence into groups of consecutive items equal to a value.
split :: element -> collection -> Sequence (List element) where (As-Sequence collection element) (Equal element) split-by
Split a sequence into groups of consecutive items satisfying a condition.
split-by :: (element -> Boolean) -> collection -> Sequence (List element) where (As-Sequence collection element) sqrt
Calculate the square root of a number.
sqrt :: Number -> Number Stride
A range between two numbers that counts up in discrete steps.
Stride : index => type {
min :: index
max :: index
step :: index
} Subtract
Subtract one value from another, returning the difference.
Subtract : left right (infer difference) => trait (left right -> difference)
instance (Subtract Number Number Number)
[default] [error] instance (Subtract left right difference)
[error] instance (Subtract () right difference) sum
Find the sum of all the numbers in a sequence.
sum :: container -> n where (As-Sequence container n) (Initial n) (Add n n n) tail
Retrieve all but the first item inside a list, or None if the list is empty.
tail :: (List element) -> Maybe (List element) take
Take up to a fixed number of values from a sequence.
take :: Number -> collection -> Sequence element where (As-Sequence collection element) tan
Calculate the tangent of an angle.
tan :: Angle -> Number times
Repeat a certain number of times.
times :: Number -> Times unzip
Split a sequence that produces two values at a time into two separate collections.
unzip :: collection -> (left; right) where (Initial left) (Initial right) (As-Sequence collection (left-element; right-element)) (Extend left left-element) (Extend right right-element) while
Repeat so long as the provided condition is True.
while :: {Boolean} -> While with-control-flow
Repeat using the Control-Flow produced by the repeat body.
with-control-flow :: With-Control-Flow result zip
Create a sequence that takes values from two sequences at a time until either sequence runs out.
zip :: left right -> Sequence (left-element; right-element) where (As-Sequence left left-element) (As-Sequence right right-element)