Skip to content

Commands Cheat Sheet

Karl Ostmo edited this page Nov 20, 2023 · 24 revisions

Note, this page is auto-generated by swarm generate cheatsheet. If you notice this page is out-of-date, instead of editing it, you can help by regenerating the tables using the most up-to-date swarm executable and pasting the result here!

Commands

Syntax Type Capability Description
noop cmd unit Do nothing.
wait int -> cmd unit timerel Wait for a number of time steps.
selfdestruct cmd unit selfdestruct Self-destruct a robot.
move cmd unit move Move forward one step.
backup cmd unit backup Move backward one step.
path unit + int -> int * int + text -> cmd (unit + dir) path Obtain shortest path to the destination.
push cmd unit push Push an entity forward one step.
stride int -> cmd unit movemultiple Move forward multiple steps.
turn dir -> cmd unit turn Turn in some direction.
grab cmd text grab Grab an item from the current location.
harvest cmd text harvest Harvest an item from the current location.
ignite dir -> cmd unit ignite Ignite a combustible item in the specified direction.
place text -> cmd unit place Place an item at the current location.
ping actor -> cmd (unit + int * int) ping Obtain the relative location of another robot.
give actor -> text -> cmd unit give Give an item to another actor nearby.
equip text -> cmd unit equip Equip a device on oneself.
unequip text -> cmd unit unequip Unequip an equipped device, returning to inventory.
make text -> cmd unit make Make an item using a recipe.
has text -> cmd bool Sense whether the robot has a given item in its inventory.
equipped text -> cmd bool Sense whether the robot has a specific device equipped.
count text -> cmd int count Get the count of a given item in a robot's inventory.
drill dir -> cmd (unit + text) drill Drill through an entity.
use text -> dir -> cmd (unit + text) Use one entity upon another.
build ∀ a. {cmd a} -> cmd actor build Construct a new robot.
salvage cmd unit salvage Deconstruct an old robot.
reprogram ∀ a. actor -> {cmd a} -> cmd unit reprogram Reprogram another robot with a new command.
say text -> cmd unit Emit a message.
listen cmd text listen Listen for a message from other actors.
log text -> cmd unit log Log the string in the robot's logger.
view actor -> cmd unit View the given actor.
appear text -> cmd unit appear Set how the robot is displayed.
create text -> cmd unit god Create an item out of thin air.
halt actor -> cmd unit halt Tell a robot to halt.
time cmd int timeabs Get the current time.
scout dir -> cmd bool recondir Detect whether a robot is within line-of-sight in a direction.
whereami cmd (int * int) senseloc Get the current x and y coordinates.
waypoint text -> int -> cmd (int * int * int) waypoint Get the x, y coordinates of a named waypoint, by index
structure text -> int -> cmd (unit + int * int * int) structure Get the x, y coordinates of the southwest corner of a constructed structure, by name and index
floorplan text -> cmd (int * int) structure Get the dimensions of a structure template
hastag text -> text -> cmd bool hastag Check whether the given entity has the given tag
tagmembers text -> int -> cmd (int * text) tagmembers Get the entities labeled by a tag, by alphabetical index
detect text -> (int * int) * int * int -> cmd (unit + int * int) detectloc Detect an entity within a rectangle.
resonate text -> (int * int) * int * int -> cmd int detectcount Count specific entities within a rectangle.
density (int * int) * int * int -> cmd int detectcount Count all entities within a rectangle.
sniff text -> cmd int detectdistance Determine distance to entity.
chirp text -> cmd dir detectdirection Determine direction to entity.
watch dir -> cmd unit wakeself Interrupt wait upon location changes.
surveil int * int -> cmd unit god Interrupt wait upon (remote) location changes.
heading cmd dir orient Get the current heading.
blocked cmd bool sensefront See if the robot can move forward.
scan dir -> cmd (unit + text) scan Scan a nearby location for entities.
upload actor -> cmd unit scan Upload a robot's known entities and log to another robot.
ishere text -> cmd bool sensehere See if a specific entity is in the current location.
isempty cmd bool sensehere Check if the current location is empty.
meet cmd (unit + actor) meet Get a reference to a nearby actor, if there is one.
meetall ∀ b. (b -> actor -> cmd b) -> b -> cmd b meet Run a command for each nearby actor.
whoami cmd text whoami Get the robot's display name.
setname text -> cmd unit Set the robot's display name.
random int -> cmd int random Get a uniformly random integer.
run text -> cmd unit Run a program loaded from a file.
return ∀ a. a -> cmd a Make the value a result in cmd.
try ∀ a. {cmd a} -> {cmd a} -> cmd a try Execute a command, catching errors.
swap text -> cmd text swap Swap placed entity with one in inventory.
atomic ∀ a. cmd a -> cmd a atomic Execute a block of commands atomically.
instant ∀ a. cmd a -> cmd a god Execute a block of commands instantly.
installkeyhandler text -> (key -> cmd unit) -> cmd unit handleinput Install a keyboard input handler.
teleport actor -> int * int -> cmd unit teleport Teleport a robot to the given location.
as ∀ a. actor -> {cmd a} -> cmd a god Hypothetically run a command as if you were another robot.
robotnamed text -> cmd actor god Find an actor by name.
robotnumbered int -> cmd actor god Find an actor by number.
knows text -> cmd bool Check if the robot knows about an entity.

Builtin functions

These functions are evaluated immediately once they have enough arguments.

Syntax Type Capability Description
self actor whoami Get a reference to the current robot.
parent actor Get a reference to the robot's parent.
base actor Get a reference to the base.
if ∀ a. bool -> {a} -> {a} -> a cond If-Then-Else function.
inl ∀ a b. a -> a + b sum Put the value into the left component of a sum type.
inr ∀ a b. b -> a + b sum Put the value into the right component of a sum type.
case ∀ a b c. a + b -> (a -> c) -> (b -> c) -> c sum Evaluate one of the given functions on a value of sum type.
fst ∀ a b. a * b -> a prod Get the first value of a pair.
snd ∀ a b. a * b -> b prod Get the second value of a pair.
force ∀ a. {a} -> a Force the evaluation of a delayed value.
undefined ∀ a. a A value of any type, that is evaluated as error.
fail ∀ a. text -> a A value of any type, that is evaluated as error with message.
not bool -> bool negation Negate the boolean value.
format ∀ a. a -> text format Turn an arbitrary value into a string.
chars text -> int charcount Counts the number of characters in the text.
split int -> text -> text * text split Split the text into two at given position.
charat int -> text -> int code Get the character at a given index.
tochar int -> text code Create a singleton text value from the given character code.
key text -> key handleinput Create a key value from a text description.

Operators

Syntax Type Capability Description
- int -> int arith Negate the given integer value.
== ∀ a. a -> a -> bool compare Check that the left value is equal to the right one.
!= ∀ a. a -> a -> bool compare Check that the left value is not equal to the right one.
< ∀ a. a -> a -> bool compare Check that the left value is lesser than the right one.
> ∀ a. a -> a -> bool compare Check that the left value is greater than the right one.
<= ∀ a. a -> a -> bool compare Check that the left value is lesser or equal to the right one.
>= ∀ a. a -> a -> bool compare Check that the left value is greater or equal to the right one.
|| bool -> bool -> bool cond Logical or (true if either value is true).
&& bool -> bool -> bool cond Logical and (true if both values are true).
+ int -> int -> int arith Add the given integer values.
- int -> int -> int arith Subtract the given integer values.
* int -> int -> int arith Multiply the given integer values.
/ int -> int -> int arith Divide the left integer value by the right one, rounding down.
^ int -> int -> int arith Raise the left integer value to the power of the right one.
++ text -> text -> text concat Concatenate the given strings.
$ ∀ a b. (a -> b) -> a -> b Apply the function on the left to the value on the right.

Detailed descriptions

Noop

  • syntax: noop
  • type: cmd unit

Do nothing.

This is different than Wait in that it does not take up a time step. It is useful for commands like if, which requires you to provide both branches. Usually it is automatically inserted where needed, so you do not have to worry about it.

Wait

  • syntax: wait
  • type: int -> cmd unit
  • required capabilities: timerel

Wait for a number of time steps.

Selfdestruct

  • syntax: selfdestruct
  • type: cmd unit
  • required capabilities: selfdestruct

Self-destruct a robot.

Useful to not clutter the world. This destroys the robot's inventory, so consider salvage as an alternative.

Move

  • syntax: move
  • type: cmd unit
  • required capabilities: move

Move forward one step.

Backup

  • syntax: backup
  • type: cmd unit
  • required capabilities: backup

Move backward one step.

Path

  • syntax: path
  • type: unit + int -> int * int + text -> cmd (unit + dir)
  • required capabilities: path

Obtain shortest path to the destination.

Optionally supply a distance limit as the first argument. Supply either a location (inL) or an entity (inR) as the second argument. If a path exists, returns the direction to proceed along.

Push

  • syntax: push
  • type: cmd unit
  • required capabilities: push

Push an entity forward one step.

Both entity and robot moves forward one step. Destination must not contain an entity.

Stride

  • syntax: stride
  • type: int -> cmd unit
  • required capabilities: movemultiple

Move forward multiple steps.

Has a max range of 64 units.

Turn

  • syntax: turn
  • type: dir -> cmd unit
  • required capabilities: turn

Turn in some direction.

Grab

  • syntax: grab
  • type: cmd text
  • required capabilities: grab

Grab an item from the current location.

Harvest

  • syntax: harvest
  • type: cmd text
  • required capabilities: harvest

Harvest an item from the current location.

Leaves behind a growing seed if the harvested item is growable. Otherwise it works exactly like grab.

Ignite

  • syntax: ignite
  • type: dir -> cmd unit
  • required capabilities: ignite

Ignite a combustible item in the specified direction.

Combustion persists for a random duration and may spread.

Place

  • syntax: place
  • type: text -> cmd unit
  • required capabilities: place

Place an item at the current location.

The current location has to be empty for this to work.

Ping

  • syntax: ping
  • type: actor -> cmd (unit + int * int)
  • required capabilities: ping

Obtain the relative location of another robot.

The other robot must be within transmission range, accounting for antennas installed on either end, and the invoking robot must be oriented in a cardinal direction. The location (x, y) is given relative to one's current orientation: Positive x value is to the right, negative left. Likewise, positive y value is forward, negative back.

Give

  • syntax: give
  • type: actor -> text -> cmd unit
  • required capabilities: give

Give an item to another actor nearby.

Equip

  • syntax: equip
  • type: text -> cmd unit
  • required capabilities: equip

Equip a device on oneself.

Unequip

  • syntax: unequip
  • type: text -> cmd unit
  • required capabilities: unequip

Unequip an equipped device, returning to inventory.

Make

  • syntax: make
  • type: text -> cmd unit
  • required capabilities: make

Make an item using a recipe.

Has

  • syntax: has
  • type: text -> cmd bool

Sense whether the robot has a given item in its inventory.

Equipped

  • syntax: equipped
  • type: text -> cmd bool

Sense whether the robot has a specific device equipped.

Count

  • syntax: count
  • type: text -> cmd int
  • required capabilities: count

Get the count of a given item in a robot's inventory.

Drill

  • syntax: drill
  • type: dir -> cmd (unit + text)
  • required capabilities: drill

Drill through an entity.

Usually you want to drill forward when exploring to clear out obstacles. When you have found a source to drill, you can stand on it and drill down. See what recipes with drill you have available. The drill command may return the name of an entity added to your inventory.

Use

  • syntax: use
  • type: text -> dir -> cmd (unit + text)

Use one entity upon another.

Which entities you can use with others depends on the available recipes. The object being used must be a 'required' entity in a recipe.

Build

  • syntax: build
  • type: ∀ a. {cmd a} -> cmd actor
  • required capabilities: build

Construct a new robot.

You can specify a command for the robot to execute. If the command requires devices they will be taken from your inventory and equipped on the new robot.

Salvage

  • syntax: salvage
  • type: cmd unit
  • required capabilities: salvage

Deconstruct an old robot.

Salvaging a robot will give you its inventory, equipped devices and log.

Reprogram

  • syntax: reprogram
  • type: ∀ a. actor -> {cmd a} -> cmd unit
  • required capabilities: reprogram

Reprogram another robot with a new command.

The other robot has to be nearby and idle.

Say

  • syntax: say
  • type: text -> cmd unit

Emit a message.

The message will be in the robot's log (if it has one) and the global log. You can view the message that would be picked by listen from the global log in the messages panel, along with your own messages and logs. This means that to see messages from other robots you have to be able to listen for them, so once you have a listening device equipped messages will be added to your log. In creative mode, there is of course no such limitation.

Listen

  • syntax: listen
  • type: cmd text
  • required capabilities: listen

Listen for a message from other actors.

It will take the first message said by the closest actor. You do not need to actively listen for the message to be logged though, that is done automatically once you have a listening device equipped. Note that you can see the messages either in your logger device or the message panel.

Log

  • syntax: log
  • type: text -> cmd unit
  • required capabilities: log

Log the string in the robot's logger.

View

  • syntax: view
  • type: actor -> cmd unit

View the given actor.

This will recenter the map on the target robot and allow its inventory and logs to be inspected.

Appear

  • syntax: appear
  • type: text -> cmd unit
  • required capabilities: appear

Set how the robot is displayed.

You can either specify one character or five (for each direction). The default is "X^>v<".

Create

  • syntax: create
  • type: text -> cmd unit
  • required capabilities: god

Create an item out of thin air.

Only available in creative mode.

Halt

  • syntax: halt
  • type: actor -> cmd unit
  • required capabilities: halt

Tell a robot to halt.

Time

  • syntax: time
  • type: cmd int
  • required capabilities: timeabs

Get the current time.

Scout

  • syntax: scout
  • type: dir -> cmd bool
  • required capabilities: recondir

Detect whether a robot is within line-of-sight in a direction.

Perception is blocked by 'Opaque' entities. Has a max range of 64 units.

Whereami

  • syntax: whereami
  • type: cmd (int * int)
  • required capabilities: senseloc

Get the current x and y coordinates.

Waypoint

  • syntax: waypoint
  • type: text -> int -> cmd (int * int * int)
  • required capabilities: waypoint

Get the x, y coordinates of a named waypoint, by index

Return only the waypoints in the same subworld as the calling robot. Since waypoint names can have plural multiplicity, returns a tuple of (count, (x, y)). The supplied index will be wrapped automatically, modulo the waypoint count. A robot can use the count to know whether they have iterated over the full waypoint circuit.

Structure

  • syntax: structure
  • type: text -> int -> cmd (unit + int * int * int)
  • required capabilities: structure

Get the x, y coordinates of the southwest corner of a constructed structure, by name and index

The outermost type of the return value indicates whether any structure of such name exists. Since structures can have multiple occurrences, returns a tuple of (count, (x, y)). The supplied index will be wrapped automatically, modulo the structure count. A robot can use the count to know whether they have iterated over the full structure list.

Floorplan

  • syntax: floorplan
  • type: text -> cmd (int * int)
  • required capabilities: structure

Get the dimensions of a structure template

Returns a tuple of (width, height) for the structure of the requested name. Yields an error if the supplied string is not the name of a structure.

HasTag

  • syntax: hastag
  • type: text -> text -> cmd bool
  • required capabilities: hastag

Check whether the given entity has the given tag

Returns true if the first argument is an entity that is labeled by the tag in the second argument. Yields an error if the first argument is not a valid entity.

TagMembers

  • syntax: tagmembers
  • type: text -> int -> cmd (int * text)
  • required capabilities: tagmembers

Get the entities labeled by a tag, by alphabetical index

Returns a tuple of (member count, entity). The supplied index will be wrapped automatically, modulo the member count. A robot can use the count to know whether they have iterated over the full list.

Detect

  • syntax: detect
  • type: text -> (int * int) * int * int -> cmd (unit + int * int)
  • required capabilities: detectloc

Detect an entity within a rectangle.

Locate the closest instance of a given entity within the rectangle specified by opposite corners, relative to the current location.

Resonate

  • syntax: resonate
  • type: text -> (int * int) * int * int -> cmd int
  • required capabilities: detectcount

Count specific entities within a rectangle.

Applies a strong magnetic field over a given area and stimulates the matter within, generating a non-directional radio signal. A receiver tuned to the resonant frequency of the target entity is able to measure its quantity. Counts the entities within the rectangle specified by opposite corners, relative to the current location.

Density

  • syntax: density
  • type: (int * int) * int * int -> cmd int
  • required capabilities: detectcount

Count all entities within a rectangle.

Applies a strong magnetic field over a given area and stimulates the matter within, generating a non-directional radio signal. A receiver measured the signal intensity to measure the quantity. Counts the entities within the rectangle specified by opposite corners, relative to the current location.

Sniff

  • syntax: sniff
  • type: text -> cmd int
  • required capabilities: detectdistance

Determine distance to entity.

Measures concentration of airborne particles to infer distance to a certain kind of entity. If none is detected, returns (-1). Has a max range of 256 units.

Chirp

  • syntax: chirp
  • type: text -> cmd dir
  • required capabilities: detectdirection

Determine direction to entity.

Uses a directional sonic emitter and microphone tuned to the acoustic signature of a specific entity to determine its direction. Returns 'down' if out of range or the direction is indeterminate. Provides absolute directions if "compass" equipped, relative directions otherwise. Has a max range of 256 units.

Watch

  • syntax: watch
  • type: dir -> cmd unit
  • required capabilities: wakeself

Interrupt wait upon location changes.

Place seismic detectors to alert upon entity changes to the specified location. Supply a direction, as with the scan command, to specify a nearby location. Can be invoked more than once until the next wait command, at which time the only the registered locations that are currently nearby are preserved. Any change to entities at the monitored locations will cause the robot to wake up before the wait timeout.

Surveil

  • syntax: surveil
  • type: int * int -> cmd unit
  • required capabilities: god

Interrupt wait upon (remote) location changes.

Like watch, but with no restriction on distance.

Heading

  • syntax: heading
  • type: cmd dir
  • required capabilities: orient

Get the current heading.

Blocked

  • syntax: blocked
  • type: cmd bool
  • required capabilities: sensefront

See if the robot can move forward.

Scan

  • syntax: scan
  • type: dir -> cmd (unit + text)
  • required capabilities: scan

Scan a nearby location for entities.

Adds the entity (not actor) to your inventory with count 0 if there is any. If you can use sum types, you can also inspect the result directly.

Upload

  • syntax: upload
  • type: actor -> cmd unit
  • required capabilities: scan

Upload a robot's known entities and log to another robot.

Ishere

  • syntax: ishere
  • type: text -> cmd bool
  • required capabilities: sensehere

See if a specific entity is in the current location.

Isempty

  • syntax: isempty
  • type: cmd bool
  • required capabilities: sensehere

Check if the current location is empty.

Detects whether or not the current location contains an entity. Does not detect robots or other actors.

Meet

  • syntax: meet
  • type: cmd (unit + actor)
  • required capabilities: meet

Get a reference to a nearby actor, if there is one.

MeetAll

  • syntax: meetall
  • type: ∀ b. (b -> actor -> cmd b) -> b -> cmd b
  • required capabilities: meet

Run a command for each nearby actor.

Whoami

  • syntax: whoami
  • type: cmd text
  • required capabilities: whoami

Get the robot's display name.

Setname

  • syntax: setname
  • type: text -> cmd unit

Set the robot's display name.

Random

  • syntax: random
  • type: int -> cmd int
  • required capabilities: random

Get a uniformly random integer.

The random integer will be chosen from the range 0 to n-1, exclusive of the argument.

Run

  • syntax: run
  • type: text -> cmd unit

Run a program loaded from a file.

Return

  • syntax: return
  • type: ∀ a. a -> cmd a

Make the value a result in cmd.

Try

  • syntax: try
  • type: ∀ a. {cmd a} -> {cmd a} -> cmd a
  • required capabilities: try

Execute a command, catching errors.

Swap

  • syntax: swap
  • type: text -> cmd text
  • required capabilities: swap

Swap placed entity with one in inventory.

This essentially works like atomic grab and place. Use this to avoid race conditions where more robots grab, scan or place in one location.

Atomic

  • syntax: atomic
  • type: ∀ a. cmd a -> cmd a
  • required capabilities: atomic

Execute a block of commands atomically.

When executing atomic c, a robot will not be interrupted, that is, no other robots will execute any commands while the robot is executing @c@.

Instant

  • syntax: instant
  • type: ∀ a. cmd a -> cmd a
  • required capabilities: god

Execute a block of commands instantly.

Like atomic, but with no restriction on program size.

InstallKeyHandler

  • syntax: installkeyhandler
  • type: text -> (key -> cmd unit) -> cmd unit
  • required capabilities: handleinput

Install a keyboard input handler.

The first argument is a hint line that will be displayed when the input handler is active. The second argument is a function to handle keyboard inputs.

Teleport

  • syntax: teleport
  • type: actor -> int * int -> cmd unit
  • required capabilities: teleport

Teleport a robot to the given location.

As

  • syntax: as
  • type: ∀ a. actor -> {cmd a} -> cmd a
  • required capabilities: god

Hypothetically run a command as if you were another robot.

RobotNamed

  • syntax: robotnamed
  • type: text -> cmd actor
  • required capabilities: god

Find an actor by name.

RobotNumbered

  • syntax: robotnumbered
  • type: int -> cmd actor
  • required capabilities: god

Find an actor by number.

Knows

  • syntax: knows
  • type: text -> cmd bool

Check if the robot knows about an entity.

Self

  • syntax: self
  • type: actor
  • required capabilities: whoami

Get a reference to the current robot.

Parent

  • syntax: parent
  • type: actor

Get a reference to the robot's parent.

Base

  • syntax: base
  • type: actor

Get a reference to the base.

If

  • syntax: if
  • type: ∀ a. bool -> {a} -> {a} -> a
  • required capabilities: cond

If-Then-Else function.

If the bool predicate is true then evaluate the first expression, otherwise the second.

Inl

  • syntax: inl
  • type: ∀ a b. a -> a + b
  • required capabilities: sum

Put the value into the left component of a sum type.

Inr

  • syntax: inr
  • type: ∀ a b. b -> a + b
  • required capabilities: sum

Put the value into the right component of a sum type.

Case

  • syntax: case
  • type: ∀ a b c. a + b -> (a -> c) -> (b -> c) -> c
  • required capabilities: sum

Evaluate one of the given functions on a value of sum type.

Fst

  • syntax: fst
  • type: ∀ a b. a * b -> a
  • required capabilities: prod

Get the first value of a pair.

Snd

  • syntax: snd
  • type: ∀ a b. a * b -> b
  • required capabilities: prod

Get the second value of a pair.

Force

  • syntax: force
  • type: ∀ a. {a} -> a

Force the evaluation of a delayed value.

Undefined

  • syntax: undefined
  • type: ∀ a. a

A value of any type, that is evaluated as error.

Fail

  • syntax: fail
  • type: ∀ a. text -> a

A value of any type, that is evaluated as error with message.

Not

  • syntax: not
  • type: bool -> bool
  • required capabilities: negation

Negate the boolean value.

Format

  • syntax: format
  • type: ∀ a. a -> text
  • required capabilities: format

Turn an arbitrary value into a string.

Chars

  • syntax: chars
  • type: text -> int
  • required capabilities: charcount

Counts the number of characters in the text.

Split

  • syntax: split
  • type: int -> text -> text * text
  • required capabilities: split

Split the text into two at given position.

To be more specific, the following holds for all text values s1 and s2: (s1,s2) == split (chars s1) (s1 ++ s2) So split can be used to undo concatenation if you know the length of the original string.

CharAt

  • syntax: charat
  • type: int -> text -> int
  • required capabilities: code

Get the character at a given index.

Gets the character (as an int representing a Unicode codepoint) at a specific index in a text value. Valid indices are 0 through chars t - 1. Throws an exception if given an out-of-bounds index.

ToChar

  • syntax: tochar
  • type: int -> text
  • required capabilities: code

Create a singleton text value from the given character code.

That is, chars (toChar c) == 1 and charAt 0 (toChar c) == c.

Key

  • syntax: key
  • type: text -> key
  • required capabilities: handleinput

Create a key value from a text description.

The key description can optionally start with modifiers like 'C-', 'M-', 'A-', or 'S-', followed by either a regular key, or a special key name like 'Down' or 'End' For example, 'M-C-x', 'Down', or 'S-4'. Which key combinations are actually possible to type may vary by keyboard and terminal program.

Neg

  • syntax: -
  • type: int -> int
  • required capabilities: arith

Negate the given integer value.

Eq

  • syntax: ==
  • type: ∀ a. a -> a -> bool
  • required capabilities: compare

Check that the left value is equal to the right one.

Neq

  • syntax: !=
  • type: ∀ a. a -> a -> bool
  • required capabilities: compare

Check that the left value is not equal to the right one.

Lt

  • syntax: <
  • type: ∀ a. a -> a -> bool
  • required capabilities: compare

Check that the left value is lesser than the right one.

Gt

  • syntax: >
  • type: ∀ a. a -> a -> bool
  • required capabilities: compare

Check that the left value is greater than the right one.

Leq

  • syntax: <=
  • type: ∀ a. a -> a -> bool
  • required capabilities: compare

Check that the left value is lesser or equal to the right one.

Geq

  • syntax: >=
  • type: ∀ a. a -> a -> bool
  • required capabilities: compare

Check that the left value is greater or equal to the right one.

Or

  • syntax: ||
  • type: bool -> bool -> bool
  • required capabilities: cond

Logical or (true if either value is true).

And

  • syntax: &&
  • type: bool -> bool -> bool
  • required capabilities: cond

Logical and (true if both values are true).

Add

  • syntax: +
  • type: int -> int -> int
  • required capabilities: arith

Add the given integer values.

Sub

  • syntax: -
  • type: int -> int -> int
  • required capabilities: arith

Subtract the given integer values.

Mul

  • syntax: *
  • type: int -> int -> int
  • required capabilities: arith

Multiply the given integer values.

Div

  • syntax: /
  • type: int -> int -> int
  • required capabilities: arith

Divide the left integer value by the right one, rounding down.

Exp

  • syntax: ^
  • type: int -> int -> int
  • required capabilities: arith

Raise the left integer value to the power of the right one.

Concat

  • syntax: ++
  • type: text -> text -> text
  • required capabilities: concat

Concatenate the given strings.

AppF

  • syntax: $
  • type: ∀ a b. (a -> b) -> a -> b

Apply the function on the left to the value on the right.

This operator is useful to avoid nesting parentheses. For exaple: f $ g $ h x = f (g (h x))

Clone this wiki locally