swarm-0.6.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Game.Step.Arithmetic

Description

Arithmetic and Comparison commands

Synopsis

Documentation

evalCmp :: Has (Throw Exn) sig m => Const -> Value -> Value -> m Bool Source #

Evaluate the application of a comparison operator. Returns Nothing if the application does not make sense.

compareValues :: Has (Throw Exn) sig m => Value -> Value -> m Ordering Source #

Compare two values, returning an Ordering if they can be compared, or Nothing if they cannot.

incompatCmp :: Has (Throw Exn) sig m => Value -> Value -> m a Source #

Values with different types were compared; this should not be possible since the type system should catch it.

incomparable :: Has (Throw Exn) sig m => Value -> Value -> m a Source #

Values were compared of a type which cannot be compared (e.g. functions, etc.).

evalArith :: Has (Throw Exn) sig m => Const -> Integer -> Integer -> m Integer Source #

Evaluate the application of an arithmetic operator, returning an exception in the case of a failing operation, or in case we incorrectly use it on a bad Const in the library.

safeDiv :: Has (Throw Exn) sig m => Integer -> Integer -> m Integer Source #

Perform an integer division, but return Nothing for division by zero.

safeExp :: Has (Throw Exn) sig m => Integer -> Integer -> m Integer Source #

Perform exponentiation, but return Nothing if the power is negative.