|
ContentsBasic functions and operatorsBooleansdata Boolean (Builtin) Data type representing truth values 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
(||) :: Boolean -> Boolean -> Boolean Boolean disjunction (or). The function is a macro that evaluates the second parameter
only if the first parameter is
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
any :: (a -> <b> Boolean) -> [a] -> <b> Boolean
otherwise :: Boolean Equivalent to the boolean value
Comparisonclass Ord a The class of linearly ordered types.
Method compare :: Ord a => a -> a -> Integer
(<) :: 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
returns a pair with the smallest second component. maximumBy :: Ord a => (b -> <c> a) -> [b] -> <c> b As (&<&) :: 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:
minIndex :: Ord a => IndexedSequence b => Sequence (b a) => b a -> Integer O(n) Yield the index of the minimum element of the maxIndex :: Ord a => IndexedSequence b => Sequence (b a) => b a -> Integer O(n) Yield the index of the maximum element of the isDigit :: Character -> Boolean Returns true, if the given character is a digit. isFinite :: Double -> Boolean isInfinite :: Double -> Boolean isNaN :: Double -> Boolean Numeric functionsdata 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 zero :: Additive a => a Neutral element of (+), i.e,
(+) :: Additive a => a -> a -> a Adds two objects (numbers, vectors, strings, etc.) together. sum :: Additive a => [a] -> a Sum of the elements:
Implemented usually more efficiently than with repetitive
application of class (Additive a) => Ring a The
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 abs :: OrderedRing a => a -> a Absolute value. toInteger :: OrderedRing a => a -> Integer Converts the given number to class (OrderedRing a) => Real a The (/) :: 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
When x > 0,
fromDouble :: Real a => Double -> a Converts a toDouble :: Real a => a -> Double Converts the given number to class (OrderedRing a) => Integral a The div :: Integral a => a -> a -> a Integer division truncated toward zero. mod :: Integral a => a -> a -> a Integer remainder, satisfying Data structuresTuplesfst :: (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). Maybedata Maybe a (Builtin) Represents an optional value. Nothing :: Maybe b (Builtin) Just :: b -> Maybe b (Builtin) fromJust :: Maybe a -> a Given fromMaybe :: a -> Maybe a -> a
execJust :: Maybe a -> (a -> <c> b) -> <c> ()
filterJust :: [Maybe a] -> [a] Takes those elements of the input list that match
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:
elemMaybe :: a -> Maybe a -> Boolean
Eitherdata Either a b The Either type represents values with two possibilities: a value of type The Left :: a -> Either a b Right :: b -> 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 Listsclass 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
drop :: Sequence a => Integer -> a -> a
sub :: Sequence a => a -> Integer -> Integer -> a
(!) :: IndexedSequence a => a b -> Integer -> b
getList :: [a] -> Integer -> a
elem :: a -> [a] -> Boolean
elemIndex :: a -> [a] -> Maybe Integer
filter :: MonadZeroE a => (b -> <c> Boolean) -> a b -> <c> a b concatMap :: (a -> <c> [b]) -> [a] -> <c> [b]
foldl :: (a -> b -> <c> a) -> a -> [b] -> <c> a
applies a binary operator
foldl1 :: (a -> a -> <b> a) -> [a] -> <b> a Like foldr :: (a -> b -> <c> b) -> b -> [a] -> <c> b
unfoldl :: (a -> <c> Maybe (b, a)) -> a -> <c> [b] Works like unfoldr :: (a -> <c> Maybe (b, a)) -> a -> <c> [b] Generates a list from a given starting state and iteration function. For example
produces
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.
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.
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
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 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 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, range :: Integer -> Integer -> [Integer]
(\\) :: [a] -> [a] -> [a]
deleteAllBy :: (a -> a -> Boolean) -> [a] -> [a] -> [a] Works like for :: FunctorE a => a b -> (b -> <d> c) -> <d> () Iterates the elements of the given collection. Same as 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 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 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 mapMaybe :: (a -> <c> Maybe b) -> [a] -> <c> [b]
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
produces
The SCL compiler makes the following optimization when encountering
partition :: (a -> <b> Boolean) -> [a] -> <b> ([a], [a]) uniqueWith :: (a -> a -> Boolean) -> [a] -> [a] Works like transpose :: [[a]] -> [[a]] Transposes the rows and columns of its argument. For example,
takeWhile :: (a -> <b> Boolean) -> [a] -> <b> [a]
Stringstrim :: String -> String Removes leading and trailing whitespace from the string. splitString :: String -> String -> [String]
indexOf :: String -> String -> Integer
lastIndexOf :: String -> String -> Integer Works like startsWith :: String -> String -> Boolean
endsWith :: String -> String -> Boolean
regionMatches :: String -> Integer -> String -> Integer -> Integer -> Boolean
replaceString :: String -> String -> String -> String
contains :: String -> String -> Boolean
charAt :: String -> Integer -> Character
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 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]
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:
Higher order programmingFunctionsconst :: a -> b -> a Creates a constant function. ($) :: (a -> <c> b) -> a -> <c> b Function application.
The second use is with higher order 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. Functorsclass Functor a The
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,
for example
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. Monadsclass (Functor a) => Monad a The Instances of
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,
(>>) :: 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)
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:
class (Monad a) => MonadZero a A class of monads with zero element satisfying
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 class (MonadZero a) => MonadPlus a A class of monads with associative binary operator
mplus :: MonadPlus a => a b -> a b -> a b class (MonadZero a) => MonadOr a A class of monads with associative binary operator
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-effectsMutable referencesdata Ref a A mutable reference to a value of type 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. Failurefail :: String -> a (Builtin) Throws a runtime exeception with the given string as a description. Control structureswhile :: <a> Boolean -> <a> b -> <a> () While loop. forN :: Integer -> (Integer -> <b> a) -> <b> ()
Consoleprint :: 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
printingToFile :: String -> <b> a -> <b> a
ProgressdidWork :: 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 UIDsgenerateUID :: <Proc> String Generates a random identifier. DataString conversionclass Show a The class of types whose elements can be converted to a string representation.
Method 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 (<<) :: StringBuilder.T -> String -> <Proc> StringBuilder.T Appends a string to the string builder. data Par a
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 conversionstoDoubleArray :: [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. Serializationdata Binding a (Builtin)
class Serializable a A class of types having a binding :: Serializable a => Binding a (Builtin) Gives a binding for the required type. Typeabledata Type (Builtin) Represents an SCL data type. class Typeable a A class of types that can be reified with typeOf :: Typeable a => a -> Type (Builtin) Returns the type of the value given as a parameter. Dynamicdata Dynamic A data type that can represent any value. toDynamic :: a -> Dynamic Converts a value to fromDynamic :: Typeable a => Dynamic -> a Converts a Exception handlingcatch :: 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 entitiesFunctorE_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
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]
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 -> [()]
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 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 iterList :: (a -> <c> b) -> [a] -> <c> () A specific implementation of last :: [a] -> a Returns the last element of a sequence lastIndexOfStartingFrom :: String -> String -> Integer -> Integer Works like listToMaybe :: [a] -> Maybe a mapFst :: (a -> <c> b) -> (a, d) -> <c> (b, d) mapList :: (a -> b) -> [a] -> [b] A specific implementation of mapSnd :: (a -> <c> b) -> (d, a) -> <c> (d, b) maybe :: a -> (b -> <c> a) -> Maybe b -> <c> a
maybeToList :: Maybe a -> [a] messageOfException :: Throwable a => a -> String orElseM :: Maybe a -> <b> Maybe a -> <b> Maybe a possibleMessageOfException :: Throwable a => a -> Maybe String printingToFileWithCharset :: String -> String -> <b> a -> <b> a
removeForAll :: Type -> Type replicate :: Integer -> a -> [a]
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 |