Basic functions and operators

Booleans

data Boolean (Builtin)

Data type representing truth values True and False.

False :: Boolean (Builtin)
True :: Boolean (Builtin)
(&&) :: Boolean -> Boolean -> Boolean

Boolean conjunction (and). The function is a macro that evaluates the second parameter only if the first parameter is True.

aba && b
TrueTrueTrue
TrueFalseFalse
Falsenot evaluatedFalse
(||) :: Boolean -> Boolean -> Boolean

Boolean disjunction (or). The function is a macro that evaluates the second parameter only if the first parameter is False.

aba || b
Truenot evaluatedTrue
FalseTrueTrue
FalseFalseFalse
not :: Boolean -> Boolean

Boolean negation

and :: [Boolean] -> Boolean

Conjunction over a list.

or :: [Boolean] -> Boolean

Disjunction over a list.

all :: (a -> <b> Boolean) -> [a] -> <b> Boolean

all pred lst tests whether the predicate pred holds for all elements of lst. It returns immediately when it encounters the first value not satisfying the predicate.

any :: (a -> <b> Boolean) -> [a] -> <b> Boolean

any pred lst tests whether the predicate pred holds some element of lst. It returns immediately when it encounters the first value satisfying the predicate.

otherwise :: Boolean

Equivalent to the boolean value True. The value is meant to be used in guard patterns:

min a b | a < b     = a
        | otherwise = b

Comparison

class Ord a

The class of linearly ordered types. Method compare must be implemented in instances.

compare :: Ord a => a -> a -> Integer

compare x y returns a negative number, if x is smaller than y, a positive number, if x is bigger than y and zero if they are equal.

(<) :: Ord a => a -> a -> Boolean

Less

(<=) :: Ord a => a -> a -> Boolean

Less or equal

(>) :: Ord a => a -> a -> Boolean

Greater

(>=) :: Ord a => a -> a -> Boolean

Greater or equal

min :: Ord a => a -> a -> a

Minimum of the parameters

max :: Ord a => a -> a -> a

Maximum of the parameters

(!=) :: a -> a -> Boolean
minimum :: Ord a => [a] -> a

Minimum over a list

maximum :: Ord a => [a] -> a

Maximum over a list

minimumBy :: Ord a => (b -> <c> a) -> [b] -> <c> b

As minimum but compares the elements by the given projection. For example

minimumBy snd l

returns a pair with the smallest second component.

maximumBy :: Ord a => (b -> <c> a) -> [b] -> <c> b

As maximum but compares the elements by the given projection.

(&<&) :: Integer -> <a> Integer -> <a> Integer

Combines two integers such that if the first one is non-zero, it is returned, otherwise the second-one. The second parameter is not implemented, if it is not needed.

The function is useful for implementing efficient recursive comparison of structures, for example:

compare (x1,y1,z1) (x2,y2,z2) = compare x1 x2 &<& compare y1 y2 &<& compare z1 z2
isDigit :: Character -> Boolean

Returns true, if the given character is a digit.

isFinite :: Double -> Boolean
isInfinite :: Double -> Boolean
isNaN :: Double -> Boolean

Numeric functions

data Short (Builtin)

16-bit signed integer

data Integer (Builtin)

32-bit signed integer

data Long (Builtin)

64-bit signed integer

data Float (Builtin)

32-bit floating point number

data Double (Builtin)

64-bit floating point number

class Additive a

The Additive class is used for types that are additive monoids. The operations must satisfy the following laws (at least approximately, when implemented for floating point numbers): (a + b) + c = a + (b + c) a + 0 = 0 + a = a

zero :: Additive a => a

Neutral element of (+), i.e,

x + zero == x
zero + x == x
(+) :: Additive a => a -> a -> a

Adds two objects (numbers, vectors, strings, etc.) together.

sum :: Additive a => [a] -> a

Sum of the elements:

sum [e1,e2,...,eN] = e1 + e2 + ... + eN

Implemented usually more efficiently than with repetitive application of (+).

class (Additive a) => Ring a

The Ring class is used for types that are algebraic rings. The operations must satisfy the following laws (at least approximately) in addition to the laws of Additive:

a + b         = b + a
a - b         = a + (neg b)
a - a         = 0
(a * b) * c   = a * (b * c)
a * 1 = 1 * a = a
a * (b + c)   = a * b + a * c
(a + b) * c   = a * c + b * c
neg :: Ring a => a -> a

Negation. Synonym for unary -.

(-) :: Ring a => a -> a -> a

Subtraction

one :: Ring a => a

Neutral element of multiplication

(*) :: Ring a => a -> a -> a

Multiplication

fromInteger :: Ring a => Integer -> a

Converts an integer to a desired numeric type.

class (Ring a, Ord a) => OrderedRing a

The OrderedRing class combines the Ring and Ord classes. It additionally supports absolute value function.

abs :: OrderedRing a => a -> a

Absolute value.

toInteger :: OrderedRing a => a -> Integer

Converts the given number to Integer

class (OrderedRing a) => Real a

The Real class is used for types that represent some approximation of real numbers.

(/) :: Real a => a -> a -> a

Division

(^) :: Real a => a -> a -> a

Exponentation

pi :: Real a => a

Pi (3.141592654...)

sqrt :: Real a => a -> a

Square root

exp :: Real a => a -> a

Exponent function

log :: Real a => a -> a

Natural logarithm

sin :: Real a => a -> a

Sine

cos :: Real a => a -> a

Cosine

tan :: Real a => a -> a

Tangent

asin :: Real a => a -> a

Inverse sine

acos :: Real a => a -> a

Inverse cosine

atan :: Real a => a -> a

Inverse tangent.

sinh :: Real a => a -> a

Hyperbolic sine

cosh :: Real a => a -> a

Hyperbolic cosine

tanh :: Real a => a -> a

Hyperbolic tangent

asinh :: Real a => a -> a

Inverse hyberbolic sine

acosh :: Real a => a -> a

Inverse hyberbolic cosine

atanh :: Real a => a -> a

Inverse hyberbolic tangent

floor :: Real a => a -> a

The largest integer not greater than the given number

ceil :: Real a => a -> a

The smallest integer not smaller than the given number

round :: Real a => a -> Long
atan2 :: Real a => a -> a -> a

Two parameter version of atan. Its value is determined by the following equations when (x,y) is a unit vector:

x = cos (atan2 y x)
y = sin (atan2 y x)

When x > 0,

atan2 y x = atan (y/x)
fromDouble :: Real a => Double -> a

Converts a Double value to a desired numeric type.

toDouble :: Real a => a -> Double

Converts the given number to Double

class (OrderedRing a) => Integral a

The Integer class is used for types that represent either all integers or some range of them.

div :: Integral a => a -> a -> a

Integer division truncated toward zero.

mod :: Integral a => a -> a -> a

Integer remainder, satisfying (x `div` y)*y + (x `mod` y) = x

Data structures

Tuples

fst :: (a, b) -> a

Gives the first element of a pair.

snd :: (a, b) -> b

Gives the second element of a pair.

curry :: ((a, b) -> <d> c) -> a -> b -> <d> c

Transforms a function taking a pair as a parameter to a function taking two values as a parameter.

uncurry :: (a -> b -> <d> c) -> (a, b) -> <d> c

Transforms a function two values as a parameter to a function taking a pair as a parameter.

curry3 :: ((a, b, c) -> <e> d) -> a -> b -> c -> <e> d

Transforms a function taking a triple as a parameter to a function taking three values as a parameter.

uncurry3 :: (a -> b -> c -> <e> d) -> (a, b, c) -> <e> d

Transforms a function three values as a parameter to a function taking a priple as a parameter.

swap :: (a, b) -> (b, a)

Swaps the order of elements of a pair (2-tuple).

Maybe

data Maybe a (Builtin)

Represents an optional value.

Nothing :: Maybe b (Builtin)
Just :: b -> Maybe b (Builtin)
fromJust :: Maybe a -> a

Given Just x this function returns x. If the parameter is Nothing, the function raises an exception.

fromMaybe :: a -> Maybe a -> a

fromMaybe def v returns def if v=Nothing and x if v=Just x.

execJust :: Maybe a -> (a -> <c> b) -> <c> ()

execJust v f executes the function f with parameter value x, if v=Just x. If v=Nothing, the function does nothing.

filterJust :: [Maybe a] -> [a]

Takes those elements of the input list that match (Just x) and adds the contents to the resulting list. For example,

filterJust [Just 1, Nothing, Just 5] = [1, 5]
orElse :: Maybe a -> <b> a -> <b> a

Provides a default value if the first parameter is Nothing. The default value is evaluated only if needed. The function can be used as an operator and is right associative so that the following is possible:

tryWithTheFirstMethod
    `orElse` tryWithTheSecondMethod
    `orElse` fail "Didn't succeed."
elemMaybe :: a -> Maybe a -> Boolean

elemMaybe v1 (Just v2) returns true if v1 == v2. elemMaybe v1 Nothing is always false.

Either

data Either a b

The Either type represents values with two possibilities: a value of type Either a b is either Left a or Right b.

The Either type is sometimes used to represent a value which is either correct or an error; by convention, the Left constructor is used to hold an error value and the Right constructor is used to hold a correct value (mnemonic: "right" also means "correct").

Left :: a -> Either a b
mapEither :: (a -> <d> Either b c) -> [a] -> <d> ([b], [c])

Applies the given function to all elements of the list. Produces two lists: the first contains all elements x for which the function returned Left x and the second list contains all elements y for which the function returned Right y.

Lists

class Sequence a

A type class for sequences. All sequences must support indexing by integers.

length :: Sequence a => a -> Integer

Length of the sequence

take :: Sequence a => Integer -> a -> a

take n s returns the first n elements of the sequence s.

drop :: Sequence a => Integer -> a -> a

drop n s removes the first n elements of the sequence s.

sub :: Sequence a => a -> Integer -> Integer -> a

sub s begin end returns a subsequence of s starting from index begin and ending just before index end.

(!) :: IndexedSequence a => a b -> Integer -> b

seq ! i returns the ith element of the sequence seq. Indexing starts from zero.

getList :: [a] -> Integer -> a

getList l i returns the ith element of the list l. Indexing starts from zero. You can also use the ! infix function for this purpose.

elem :: a -> [a] -> Boolean

elem el lst return true, if el occurs in the list lst.

elemIndex :: a -> [a] -> Maybe Integer

elemIndex el lst returns the index of the first element in the given list lst which is equal (by ==) to the query element, or Nothing if there is no such element.

filter :: MonadZeroE a => (b -> <c> Boolean) -> a b -> <c> a b
concatMap :: (a -> <c> [b]) -> [a] -> <c> [b]

concatMap combines map and join functions. It maps the elements of a given list to lists with the given function and concatenates the results.

concatMap f lst = join (map f lst) = [y | x <- lst, y <- f x]
foldl :: (a -> b -> <c> a) -> a -> [b] -> <c> a
foldl op initialValue list

applies a binary operator op to all elements of list from left to right starting with initialValue. For example,

foldl op init [x1, x2, x3, x4] = (((init `op` x1) `op` x2) `op` x3) `op` x4
foldl1 :: (a -> a -> <b> a) -> [a] -> <b> a

Like foldl but assumes that the list is non-empty so the initial is not needed.

foldr :: (a -> b -> <c> b) -> b -> [a] -> <c> b

foldr is defined like foldl but it process the list from right to left.

unfoldl :: (a -> <c> Maybe (b, a)) -> a -> <c> [b]

Works like unfoldr but generates the list from right to left.

unfoldr :: (a -> <c> Maybe (b, a)) -> a -> <c> [b]

Generates a list from a given starting state and iteration function. For example

let nextState 0 = Nothing
    nextState i = Just (i, i `div` 2)
in  unfoldr nextState 30

produces

[30, 15, 7, 3, 1]
zip :: [a] -> [b] -> [(a, b)]

Combines two lists into one list of pairs. The length of the resulting list is the length of the smallest input list.

zip [1, 2, 3, 4, 5] ['a', 'b', 'c'] = [(1, 'a'), (2, 'b'), (3, 'c')]
zipWith :: (a -> b -> <d> c) -> [a] -> [b] -> <d> [c]

Combines two lists by using the given function for combining the elements. The length of the resulting list is the length of the smallest input list.

unzip :: [(a, b)] -> ([a], [b])

Produces two lists from one list of pairs.

unzip [(1, 'a'), (2, 'b'), (3, 'c')] = ([1, 2, 3], ['a', 'b', 'c'])
sort :: Ord a => [a] -> [a]

Sorts the given list using its default order.

sortBy :: Ord a => (b -> <c> a) -> [b] -> <c> [b]

Sorts the lists by the values computed by the first function. For example

sortBy snd [(1,5), (2,3), (3,4)] = [(2,3), (3,4), (1,5)]
sortWith :: (a -> a -> <b> Integer) -> [a] -> <b> [a]

Sorts the list using the given comparator.

index :: [(a, b)] -> a -> Maybe b

Given a list of key-value pairs, the function produces a function that finds a value efficiently for the given key.

indexBy :: (a -> <c> b) -> [a] -> <c> b -> Maybe a

Given a list of values and a function computing a key for each value, the function produces a function that finds a value effeciently for the given key.

indexWith :: (a -> Integer) -> (a -> a -> Boolean) -> [(a, b)] -> a -> Maybe b

Works like index but uses the given functions as hash codes and equality.

unique :: [a] -> [a]

Removes duplicates (all but the first occurrence) from the list but otherwise preserves the order of the elements.

uniqueBy :: (a -> <c> b) -> [a] -> <c> [a]

Like unique, but uses the given function for finding the key values used for uniqueness testing.

tail :: [a] -> [a]

Removes the first element of the list, if the list is non-empty.

reverse :: [a] -> [a]

Reverses a given list. For example, reverse [1,2,3] = [3,2,1]

range :: Integer -> Integer -> [Integer]

range begin end produces a list of consecutive integers starting from begin and ending to end (including end). The compiler supports syntactic sugar [begin..end] for this function.

(\\) :: [a] -> [a] -> [a]

a \\ b removes all elements of b from the list a.

deleteAllBy :: (a -> a -> Boolean) -> [a] -> [a] -> [a]

Works like \\ but uses the given function for equality tests.

for :: FunctorE a => a b -> (b -> <d> c) -> <d> ()

Iterates the elements of the given collection. Same as iter but parameters flipped.

forI :: FunctorE a => a b -> (Integer -> b -> <d> c) -> <d> ()

Iterates the elements of the given collection providing also the indices of the elements. Same as iterI but parameters flipped.

lookup :: a -> [(a, b)] -> Maybe b

Tries to find the given key from the list of key-value pairs and returns the corresponding value.

addList :: [a] -> a -> [a]

Adds the given value to the end of the list.

groupBy :: (a -> <c> b) -> [a] -> <c> [(b, [a])]

Groups a list values by a key computed by the given function.

intersect :: [a] -> [a] -> [a]

Computes a list that contains only elements that belongs to both input lists.

findFirst :: (a -> <b> Boolean) -> [a] -> <b> Maybe a

Returns the first element of the list satisfying the given condition, or Nothing if there is no such element.

singletonList :: a -> [a]

Creates a list with exectly one element.

group :: [(a, b)] -> [(a, [b])]

Groups a list of key-value pairs by the keys.

groupWith :: (a -> Integer) -> (a -> a -> Boolean) -> (b -> <c> a) -> (b -> <c> d) -> [b] -> <c> [(a, [d])]
mapFirst :: (a -> <c> Maybe b) -> [a] -> <c> Maybe b

Applies the given function to the elements of the lists until the function returns something else than Nothing. This return value is also returned as a result of this function.

mapMaybe :: (a -> <c> Maybe b) -> [a] -> <c> [b]

mapMaybe combines map and filter functions. It applies the given function to every element of the input list. If the result is Just x, then x is added to the resulting list.

mapMaybe f lst = [y | x <- lst, Just y = f x]
mapI :: (Integer -> a -> <c> b) -> [a] -> <c> [b]
build :: (forall a b. a -> (a -> c -> <b> a) -> <b,d> a) -> <d> [c]

A primitive for constructing a list by empty and cons operations given to the function given as a parameter to this function. For example:

build (\empty cons -> cons (cons (cons empty 1) 2) 3)

produces

[1, 2, 3]

The SCL compiler makes the following optimization when encountering build and foldl functions after inlining:

foldl f i (build g) = g i f
partition :: (a -> <b> Boolean) -> [a] -> <b> ([a], [a])
uniqueWith :: (a -> a -> Boolean) -> [a] -> [a]

Works like unique but uses the given function for equality tests.

transpose :: [[a]] -> [[a]]

Transposes the rows and columns of its argument. For example,

transpose [[1,2,3],[4,5,6]] == [[1,4],[2,5],[3,6]]
transpose [[1,2],[3,4,5]] == [[1,3],[2,4],[5]]
takeWhile :: (a -> <b> Boolean) -> [a] -> <b> [a]

takeWhile p l, returns the longest prefix (possibly empty) of list l of elements that satisfy p

Strings

trim :: String -> String

Removes leading and trailing whitespace from the string.

splitString :: String -> String -> [String]

splitString text pattern splits the string into a list of string where the parts are sepratated in the original list by the given pattern.

indexOf :: String -> String -> Integer

indexOf string s finds the first occurrence of s from string and returns its index. If the s does not occur in the string, return -1."

lastIndexOf :: String -> String -> Integer

Works like indexOf but returns the index of the last occurrence.

startsWith :: String -> String -> Boolean

startsWith string prefix returns true if the string begins with the given prefix.

endsWith :: String -> String -> Boolean

endsWith string suffix returns true if the string ends with the given prefix.

regionMatches :: String -> Integer -> String -> Integer -> Integer -> Boolean

regionMatches str1 offset1 str2 offset2 len tests whether sub str1 offset1 (offset1+len) == sub str2 offset2 (offset2+len).

replaceString :: String -> String -> String -> String

replaceString original pattern replacement replaces all occurrences of pattern in the string by replacement.

contains :: String -> String -> Boolean

contains string s returns true if string contains s as a substring.

charAt :: String -> Integer -> Character

charAt string i returns the ith character of the string.

isLetter :: Character -> Boolean

Returns true, if the given character is a letter.

addChar :: Character -> Integer -> Character

Adds a given integer to the character code.

subChar :: Character -> Character -> Integer

Subtracts a given integer from the character code.

intercalate :: String -> [String] -> String

The intercalate function takes a String and a list of Strings and concatenates the list after interspersing the first argument between each element of the list.

See also more generic joinWithSeparator which escapes its arguments using show.

string :: Vector Character -> String

Creates a string from a vector of characters.

joinWithSeparator :: Show a => String -> [a] -> String

Joins the string representations of the list of values with the given separator.

See intercalate for an alternative that works with Strings and doesn't escape its arguments.

printWithSeparator :: Show a => StringBuilder.T -> String -> [a] -> <Proc> StringBuilder.T

Appends the string representations of all elements of the list to the string builder and separates the values with the given separator.

split :: String -> String -> [String]

split pattern text splits text around matches of the given regular expression pattern.

This function works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.

The string "boo:and:foo", for example, yields the following results with these expressions:

Regex   Result
:       { "boo", "and", "foo" }
o       { "b", "", ":and:f" }

Higher order programming

Functions

const :: a -> b -> a

Creates a constant function. const x defines a function that always returns x.

($) :: (a -> <c> b) -> a -> <c> b

Function application. f $ x is equivalent with f x. The function has two uses. First is to remove parentheses from deeply nested expressions:

f (g (h x))  ==  f $ g $ h x

The second use is with higher order functions:

map ($ parameter) functions
(.) :: (a -> <c> b) -> (d -> <c> a) -> d -> <c> b

Composes two functions (f . g) x = f (g x)

id :: a -> a

Identity function.

flip :: (a -> b -> <d> c) -> b -> a -> <d> c

Flips the parameters of a binary function.

ignore :: a -> ()

Ignores the given value. This function is used in a situation where a function returns a value in a context where the value is not expected.

Functors

class Functor a

The Functor class is used for types that can be mapped over. Instances of Functor should satisfy the following laws:

fmap id  ==  id
fmap (f . g)  ==  fmap f . fmap g
fmap :: Functor a => (b -> c) -> a b -> a c

Lifts a pure function to the given functor.

class (Functor a) => FunctorE a

A class of types that can be mapped over with effectful mapping functions.

map :: FunctorE a => (b -> <d> c) -> a b -> <d> a c

Applies the function to all elements of the container and returns the similarly shaped container with the results:

For lists,

map f [e1, e2, ..., eN] = [f e1, f e2, ..., f eN]

for example

map (*2) [1..5] = [2, 4, 6, 8, 10]
iter :: FunctorE a => (b -> <d> c) -> a b -> <d> ()

Calls the given function with all elements of the given container.

iterI :: FunctorE a => (Integer -> b -> <d> c) -> a b -> <d> ()

Calls the given function with all elements of the given container giving also the index of the element as a parameter.

Monads

class (Functor a) => Monad a

The Monad class defines the basic operations over a monad, a concept from a branch of mathematics known as category theory. From the perspective of a SCL programmer, however, it is best to think of a monad as an abstract datatype of actions. SCL's `mdo expressions provide a convenient syntax for writing monadic expressions.

Instances of Monad should satisfy the following laws:

return a >>= k  ==  k a
m >>= return  ==  m
m >>= (\x -> k x >>= h)  ==  (m >>= k) >>= h
fmap f xs  ==  xs >>= return . f
return :: Monad a => b -> a b

Inject a value into the monadic type.

(>>=) :: Monad a => a b -> (b -> a c) -> a c

Sequentially compose two actions, passing any value produced by the first as an argument to the second.

join :: Monad a => a (a b) -> a b

The join function is the conventional monad join operator. It removes one level of monadic structure.

For lists, join concatenates a list of lists:

join [[1,2], [3,4]] = [1, 2, 3, 4]
(>>) :: Monad a => a b -> a c -> a c

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages."

(>=>) :: Monad a => (b -> a c) -> (c -> a d) -> b -> a d

Left-to-right Kleisli composition of monads.

class (FunctorE a) => FunctorM a
mapM :: FunctorM a => Monad b => (c -> <e> b d) -> a c -> <e> b (a d)

mapM f is equivalent to sequence . map f.

sequence :: FunctorM a => Monad b => a (b c) -> b (a c)

Evaluate each action in the sequence from left to right, and collect the results.

repeatForever :: Monad a => a b -> a c

Sequences the given monadic value infinitely:

repeatForever m = m >> m >> m >> ...
class (Monad a) => MonadZero a

A class of monads with zero element satisfying

mzero >>= f = mzero
mzero :: MonadZero a => a b
mfilter :: MonadZero a => (b -> Boolean) -> a b -> a b
guard :: MonadZero a => Boolean -> a ()

Injects a boolean test to a type beloning to MonadZero.

class (MonadZero a) => MonadPlus a

A class of monads with associative binary operator mplus satisfying the following laws:

mplus mzero b = b
mplus a mzero = a
mplus (mplus a b) c = mplus a (mplus b c)
mplus a b >>= k = mplus (a >>= k) (b >>= k)
mplus :: MonadPlus a => a b -> a b -> a b
class (MonadZero a) => MonadOr a

A class of monads with associative binary operator morelse satisfying the following laws:

morelse mzero b = b
morelse a mzero = a
morelse (morelse a b) c = morelse a (morelse b c)
morelse (return a) b = return a
morelse :: MonadOr a => a b -> a b -> a b
ignoreM :: a -> Maybe b
class (FunctorE a, Monad a) => MonadE a
bindE :: MonadE a => a b -> (b -> <d> a c) -> <d> a c

An effectful version of the bind operator (>>=)

compE :: MonadE a => (b -> <d> a c) -> (c -> <f> a e) -> b -> <d,f> a e

An effectful version of the Kleisli composition operator (>=>)

class (MonadE a, MonadZero a) => MonadZeroE a
filter :: MonadZeroE a => (b -> <c> Boolean) -> a b -> <c> a b

Side-effects

Mutable references

data Ref a

A mutable reference to a value of type a.

ref :: a -> <Proc> Ref a

Creates a new reference with the given initial value.

getRef :: Ref a -> <Proc> a

Returns the current value of the reference.

(:=) :: Ref a -> a -> <Proc> ()

Sets a new value for the reference.

Failure

fail :: String -> a (Builtin)

Throws a runtime exeception with the given string as a description.

Control structures

while :: <a> Boolean -> <a> b -> <a> ()

While loop. while cond body executes the body while the cond is true.

forN :: Integer -> (Integer -> <b> a) -> <b> ()

forN n f calls f for all integers 0, ..., n-1

Console

print :: Show a => a -> <Proc> ()

Prints the given value in the console.

printString :: String -> <Proc> ()

Prints the given string to the console.

printError :: String -> <Proc> ()

Prints an error message to the console.

printErrorsAsNormalPrints :: <b> a -> <b> a

printErrorsAsNormalPrints expression executes the expression so that all its error prints are printed as normal prints. This is useful mainly in testing scripts for checking that the implementations give proper error messages with invalid inputs.

printingToFile :: String -> <b> a -> <b> a

printingToFile "fileName" expression executes the expression so that all its console prints are written to the file given as a first parameter.

Progress

didWork :: Double -> <Proc> ()

Reports that certain amount of work has been done for the current task.

checkInterrupted :: <Proc> ()

Checks whether the current thread has been interrupted and throws an exception if it is.

isInterrupted :: <Proc> Boolean

Returns True if the current thread has been interrupted.

UIDs

generateUID :: <Proc> String

Generates a random identifier.

Data

String conversion

class Show a

The class of types whose elements can be converted to a string representation. Method show or (<+) must be implemented.

show :: Show a => a -> String

Converts a value to string.

(<+) :: Show a => StringBuilder.T -> a -> <Proc> StringBuilder.T

Appends the string representation of the value to the string builder.

precedence :: Show a => a -> Integer

Returns the precedence of the value. It is used to determine if parenteheses are needed around the string representation of the value. The default value is 0 and means that parentheses are never added.

showForPrinting :: Show a => a -> String

Converts a value to a string like show but does not put string literals in double quotes.

(<<) :: StringBuilder.T -> String -> <Proc> StringBuilder.T

Appends a string to the string builder.

data Par a

Par data type is used to control the placement of parentheses when converting values to string. Value Par prec val is converted to string like val but parentheses are put around, if the precedence of the value is greater than prec.

Par :: Integer -> a -> Par a
class Read a

Type class for parsing strings to values.

read :: Read a => String -> a

Converts a string to a required type of value.

toLowerCase :: String -> String

Converts all letters of the string to lower case.

toUpperCase :: String -> String

Converts all letters of the string to upper case.

Other conversions

toDoubleArray :: [Double] -> Vector Double

Converts a list of doubles to a double array.

fromDoubleArray :: Vector Double -> [Double]

Converts a double array to a list of doubles.

arrayToList :: Array a -> [a]

Converts an array to a list.

listToArray :: [a] -> Array a

Converts a list to an array.

Serialization

data Binding a (Builtin)

Binding represents a data type in the form supported by Databoard library. It is used to serialize and deserialize values.

class Serializable a

A class of types having a Binding

binding :: Serializable a => Binding a (Builtin)

Gives a binding for the required type.

Typeable

data Type (Builtin)

Represents an SCL data type.

class Typeable a

A class of types that can be reified with typeOf function.

typeOf :: Typeable a => a -> Type (Builtin)

Returns the type of the value given as a parameter.

Dynamic

data Dynamic

A data type that can represent any value.

toDynamic :: a -> Dynamic

Converts a value to Dynamic type.

fromDynamic :: Typeable a => Dynamic -> a

Converts a Dynamic value to a required value, or fails if the conversion is not possible.

Exception handling

catch :: VecComp a => <c,Exception> b -> (a -> <c> b) -> <c> b

Executes the given expression and catches certain class of exceptions (specified by the catch handler that is given as a second parameter.)

Undocumented entities

FunctorE_Either_a_super0 :: Functor (Either a)
FunctorE_Maybe_super0 :: Functor Maybe
FunctorE_¤91¤93¤_super0 :: Functor []
FunctorM_¤91¤93¤_super0 :: FunctorE []
Integral_Integer_super0 :: OrderedRing Integer
Integral_Long_super0 :: OrderedRing Long
MonadE_Either_a_super0 :: FunctorE (Either a)
MonadE_Either_a_super1 :: Monad (Either a)
MonadE_Maybe_super0 :: FunctorE Maybe
MonadE_Maybe_super1 :: Monad Maybe
MonadE_¤91¤93¤_super0 :: FunctorE []
MonadE_¤91¤93¤_super1 :: Monad []
MonadOr_Maybe_super0 :: MonadZero Maybe
MonadPlus_¤91¤93¤_super0 :: MonadZero []
MonadZeroE_Maybe_super0 :: MonadE Maybe
MonadZeroE_Maybe_super1 :: MonadZero Maybe
MonadZeroE_¤91¤93¤_super0 :: MonadE []
MonadZeroE_¤91¤93¤_super1 :: MonadZero []
MonadZero_Maybe_super0 :: Monad Maybe
MonadZero_¤91¤93¤_super0 :: Monad []
Monad_Either_a_super0 :: Functor (Either a)
Monad_Maybe_super0 :: Functor Maybe
Monad_¤91¤93¤_super0 :: Functor []
OrderedRing_Double_super0 :: Ring Double
OrderedRing_Double_super1 :: Ord Double
OrderedRing_Float_super0 :: Ring Float
OrderedRing_Float_super1 :: Ord Float
OrderedRing_Integer_super0 :: Ring Integer
OrderedRing_Integer_super1 :: Ord Integer
OrderedRing_Long_super0 :: Ring Long
OrderedRing_Long_super1 :: Ord Long
Real_Double_super0 :: OrderedRing Double
Real_Float_super0 :: OrderedRing Float
Ring_Byte_super0 :: Additive Byte
Ring_Double_super0 :: Additive Double
Ring_FUNC_a_b_c_super0 :: Ring a => Additive (b -> <c> a)
Ring_Float_super0 :: Additive Float
Ring_Integer_super0 :: Additive Integer
Ring_Long_super0 :: Additive Long
Ring_Short_super0 :: Additive Short
causeOfException :: Throwable a => a -> Maybe Throwable
disablePrintingForCommand :: <b> a -> <b> a

disablePrintingForCommand expression executes the expression so that it does not print return values. Errors are printed normally.

doubleToLongBits :: Double -> Long

Converts 64-bit floating point number to a 64-bit integer with the same byte level representation.

filterList :: (a -> <b> Boolean) -> [a] -> <b> [a]

filter pred lst returns those elements of lst that the predicate pred accepts. For example

filter (> 3) [1, 2, 3, 4, 5, 6] = [4, 5, 6]
first :: [a] -> a

Returns the first element of a sequence

floatToIntBits :: Float -> Integer

Converts 32-bit floating point number to a 32-bit integer with the same byte level representation.

foldlI :: (Integer -> a -> b -> <c> a) -> a -> [b] -> <c> a
foldr1 :: (a -> a -> <b> a) -> [a] -> <b> a
getBytes :: String -> String -> Vector Byte
getBytesUTF8 :: String -> Vector Byte
guardList :: Boolean -> [()]

guardList v returns a singleton [()] if v=True and the empty list if v=False.

indexGroup :: [(a, b)] -> a -> [b]

Composition of index and group.

indexGroupBy :: (a -> <c> b) -> [a] -> <c> b -> [a]

Composition of index and groupBy.

indexOfStartingFrom :: String -> String -> Integer -> Integer

Works like indexOf but starts searching from the given index instead of the beginning of the string.

indexSet :: [a] -> a -> Boolean

Given a list of elements, the function produces its characteristic function.

iterIList :: (Integer -> a -> <c> b) -> [a] -> <c> ()

A specific implementation of iterI for lists.

iterList :: (a -> <c> b) -> [a] -> <c> ()

A specific implementation of iter for lists.

last :: [a] -> a

Returns the last element of a sequence

lastIndexOfStartingFrom :: String -> String -> Integer -> Integer

Works like lastIndexOf but starts searching from the given index instead of the end of the string.

listToMaybe :: [a] -> Maybe a
mapFst :: (a -> <c> b) -> (a, d) -> <c> (b, d)
mapList :: (a -> b) -> [a] -> [b]

A specific implementation of fmap for lists.

mapSnd :: (a -> <c> b) -> (d, a) -> <c> (d, b)
maybe :: a -> (b -> <c> a) -> Maybe b -> <c> a

maybe def f v returns def if v=Nothing and f x if v=Just x.

maybeToList :: Maybe a -> [a]
messageOfException :: Throwable a => a -> String
orElseM :: Maybe a -> <b> Maybe a -> <b> Maybe a
removeForAll :: Type -> Type
replicate :: Integer -> a -> [a]

replicate n v returns a list of length n such that each element is a copy of v.

replicateM :: Monad a => Integer -> a b -> a [b]
replicateM_ :: Monad a => Integer -> a b -> a ()
scanl :: (a -> b -> <c> a) -> a -> [b] -> <c> [a]
showCharacter :: Character -> String
toThrowable :: Throwable a => a -> Throwable