The standard prelude of Curry with type classes. All exported functions, data types, type classes and methods defined in this module are always available in any Curry program.
(/==)
:: Data a => a -> a -> Bool
The negation of strict equality. |
eqString
:: String -> String -> Bool
|
shows
:: Show a => a -> String -> String
Converts a showable value to a show function that prepends this value. |
showChar
:: Char -> String -> String
Converts a character to a show function that prepends the character. |
showString
:: String -> String -> String
Converts a string to a show function that prepends the string. |
showParen
:: Bool -> (String -> String) -> String -> String
If the first argument is True , Converts a show function to a
show function adding enclosing brackets, otherwise the show function
is returned unchanged.
|
showTuple
:: [String -> String] -> String -> String
Converts a list of show functions to a show function combining the given show functions to a tuple representation. |
reads
:: Read a => String -> [(a,String)]
A parser to read data from a string. |
readParen
:: Bool -> (String -> [(a,String)]) -> String -> [(a,String)]
readParen True p
parses what p
parses, but surrounded with parentheses.
|
read
:: Read a => String -> a
Reads data of the given type from a string. |
lex
:: String -> [(String,String)]
Reads a single lexeme from the given string. |
even
:: Integral a => a -> Bool
Returns whether an integer is even. |
odd
:: Integral a => a -> Bool
Returns whether an integer is odd. |
fromIntegral
:: (Integral a, Num b) => a -> b
General coercion from integral types. |
realToFrac
:: (Real a, Fractional b) => a -> b
General coercion to fractional types. |
(^)
:: (Num a, Integral b) => a -> b -> a
Raises a number to a non-negative integer power. |
(<$>)
:: Functor a => (b -> c) -> a b -> a c
|
liftM2
:: Monad a => (b -> c -> d) -> a b -> a c -> a d
Promotes a function to a monad. |
sequence
:: Monad a => [a b] -> a [b]
Executes a sequence of monadic actions and collects all results in a list. |
sequence_
:: Monad a => [a b] -> a ()
Executes a sequence of monadic actions and ignores the results. |
mapM
:: Monad a => (b -> a c) -> [b] -> a [c]
Maps a monadic action function on a list of elements. |
mapM_
:: Monad a => (b -> a c) -> [b] -> a ()
Maps an monadic action function on a list of elements. |
isUpper
:: Char -> Bool
Returns true if the argument is an uppercase letter. |
isLower
:: Char -> Bool
Returns true if the argument is an lowercase letter. |
isAlpha
:: Char -> Bool
Returns true if the argument is a letter. |
isDigit
:: Char -> Bool
Returns true if the argument is a decimal digit. |
isAlphaNum
:: Char -> Bool
Returns true if the argument is a letter or digit. |
isBinDigit
:: Char -> Bool
Returns true if the argument is a binary digit. |
isOctDigit
:: Char -> Bool
Returns true if the argument is an octal digit. |
isHexDigit
:: Char -> Bool
Returns true if the argument is a hexadecimal digit. |
isSpace
:: Char -> Bool
Returns true if the argument is a white space. |
ord
:: Char -> Int
Converts a character into its ASCII value. |
chr
:: Int -> Char
Converts a Unicode value into a character. |
lines
:: String -> [String]
Breaks a string into a list of lines where a line is terminated at a newline character. |
unlines
:: [String] -> String
Concatenates a list of strings with terminating newlines. |
words
:: String -> [String]
Breaks a string into a list of words where the words are delimited by white spaces. |
unwords
:: [String] -> String
Concatenates a list of strings with a blank between two strings. |
($)
:: (a -> b) -> a -> b
Right-associative application. |
($!)
:: (a -> b) -> a -> b
Right-associative application with strict evaluation of its argument to head normal form. |
($!!)
:: (a -> b) -> a -> b
Right-associative application with strict evaluation of its argument to normal form. |
($#)
:: (a -> b) -> a -> b
Right-associative application with strict evaluation of its argument to a non-variable term. |
($##)
:: (a -> b) -> a -> b
Right-associative application with strict evaluation of its argument to ground normal form. |
seq
:: a -> b -> b
Evaluates the first argument to head normal form (which could also be a free variable) and returns the second argument. |
ensureNotFree
:: a -> a
Evaluates the argument to head normal form and returns it. |
ensureSpine
:: [a] -> [a]
Evaluates the argument to spine form and returns it. |
normalForm
:: a -> a
Evaluates the argument to normal form and returns it. |
groundNormalForm
:: a -> a
Evaluates the argument to ground normal form and returns it. |
(.)
:: (a -> b) -> (c -> a) -> c -> b
Function composition. |
id
:: a -> a
Identity function. |
const
:: a -> b -> a
Constant function. |
asTypeOf
:: a -> a -> a
asTypeOf
is a type-restricted version of const .
|
curry
:: ((a,b) -> c) -> a -> b -> c
Converts an uncurried function to a curried function. |
uncurry
:: (a -> b -> c) -> (a,b) -> c
Converts an curried function to a function on pairs. |
flip
:: (a -> b -> c) -> b -> a -> c
flip f
is identical to f , but with the order of arguments reversed.
|
until
:: (a -> Bool) -> (a -> a) -> a -> a
Repeats application of a function until a predicate holds. |
(&&)
:: Bool -> Bool -> Bool
Sequential conjunction on Booleans. |
(||)
:: Bool -> Bool -> Bool
Sequential disjunction on Booleans. |
not
:: Bool -> Bool
Negation on Booleans. |
otherwise
:: Bool
Useful name for the last condition in a sequence of conditional equations. |
ifThenElse
:: Bool -> a -> a -> a
The standard conditional. |
fst
:: (a,b) -> a
Selects the first component of a pair. |
snd
:: (a,b) -> b
Selects the second component of a pair. |
head
:: [a] -> a
Computes the first element of a list. |
tail
:: [a] -> [a]
Computes the remaining elements of a list. |
null
:: [a] -> Bool
Is a list empty? |
(++)
:: [a] -> [a] -> [a]
Concatenates two lists. |
length
:: [a] -> Int
Computes the length of a list. |
(!!)
:: [a] -> Int -> a
List index (subscript) operator, head has index 0. |
map
:: (a -> b) -> [a] -> [b]
Maps a function on all elements of a list. |
foldl
:: (a -> b -> a) -> a -> [b] -> a
Accumulates all list elements by applying a binary operator from left to right. |
foldl1
:: (a -> a -> a) -> [a] -> a
Accumulates a non-empty list from left to right. |
foldr
:: (a -> b -> b) -> b -> [a] -> b
Accumulates all list elements by applying a binary operator from right to left. |
foldr1
:: (a -> a -> a) -> [a] -> a
Accumulates a non-empty list from right to left: |
filter
:: (a -> Bool) -> [a] -> [a]
Filters all elements satisfying a given predicate in a list. |
zip
:: [a] -> [b] -> [(a,b)]
Joins two lists into one list of pairs. |
zip3
:: [a] -> [b] -> [c] -> [(a,b,c)]
Joins three lists into one list of triples. |
zipWith
:: (a -> b -> c) -> [a] -> [b] -> [c]
Joins two lists into one list by applying a combination function to corresponding pairs of elements. |
zipWith3
:: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
Joins three lists into one list by applying a combination function to corresponding triples of elements. |
unzip
:: [(a,b)] -> ([a],[b])
Transforms a list of pairs into a pair of lists. |
unzip3
:: [(a,b,c)] -> ([a],[b],[c])
Transforms a list of triples into a triple of lists. |
concat
:: [[a]] -> [a]
Concatenates a list of lists into one list. |
concatMap
:: (a -> [b]) -> [a] -> [b]
Maps a function from elements to lists and merges the result into one list. |
iterate
:: (a -> a) -> a -> [a]
Infinite list of repeated applications of a function f to an element x. |
repeat
:: a -> [a]
Infinite list where all elements have the same value. |
replicate
:: Int -> a -> [a]
List of length n where all elements have the same value. |
take
:: Int -> [a] -> [a]
Returns prefix of length n. |
drop
:: Int -> [a] -> [a]
Returns suffix without first n elements. |
splitAt
:: Int -> [a] -> ([a],[a])
splitAt n xs
is equivalent to (take n xs, drop n xs)
|
takeWhile
:: (a -> Bool) -> [a] -> [a]
Returns longest prefix with elements satisfying a predicate. |
dropWhile
:: (a -> Bool) -> [a] -> [a]
Returns suffix without takeWhile prefix. |
span
:: (a -> Bool) -> [a] -> ([a],[a])
span p xs
is equivalent to (takeWhile p xs, dropWhile p xs)
|
break
:: (a -> Bool) -> [a] -> ([a],[a])
break p xs
is equivalent to
`(takeWhile (not .
|
reverse
:: [a] -> [a]
Reverses the order of all elements in a list. |
and
:: [Bool] -> Bool
Computes the conjunction of a Boolean list. |
or
:: [Bool] -> Bool
Computes the disjunction of a Boolean list. |
any
:: (a -> Bool) -> [a] -> Bool
Is there an element in a list satisfying a given predicate? |
all
:: (a -> Bool) -> [a] -> Bool
Is a given predicate satisfied by all elements in a list? |
elem
:: Eq a => a -> [a] -> Bool
Element of a list? |
notElem
:: Eq a => a -> [a] -> Bool
Not element of a list? |
lookup
:: Eq a => a -> [(a,b)] -> Maybe b
Looks up a key in an association list. |
maybe
:: a -> (b -> a) -> Maybe b -> a
The maybe
function takes a default value, a function, and a Maybe
value.
|
either
:: (a -> b) -> (c -> b) -> Either a c -> b
Apply a case analysis to a value of the Either type. |
getChar
:: IO Char
An action that reads a character from standard output and returns it. |
getLine
:: IO String
An action that reads a line from standard input and returns it. |
putChar
:: Char -> IO ()
An action that puts its character argument on standard output. |
putStr
:: String -> IO ()
Action to print a string on standard output. |
putStrLn
:: String -> IO ()
Action to print a string with a newline on standard output. |
print
:: Show a => a -> IO ()
Converts a term into a string and prints it. |
readFile
:: String -> IO String
An action that (lazily) reads a file and returns its contents. |
writeFile
:: String -> String -> IO ()
An action that writes a file. |
appendFile
:: String -> String -> IO ()
An action that appends a string to a file. |
userError
:: String -> IOError
A user error value is created by providing a description of the error situation as a string. |
ioError
:: IOError -> IO a
Raises an I/O exception with a given error value. |
catch
:: IO a -> (IOError -> IO a) -> IO a
Catches a possible error or failure during the execution of an I/O action. |
success
:: Bool
The always satisfiable constraint. |
solve
:: Bool -> Bool
Enforce a Boolean condition to be true. |
doSolve
:: Bool -> IO ()
Solves a constraint as an I/O action. |
(=:=)
:: Data a => a -> a -> Bool
The equational constraint. |
constrEq
:: a -> a -> Bool
Internal operation to implement equational constraints. |
(=:<=)
:: Data a => a -> a -> Bool
Non-strict equational constraint. |
(=:<<=)
:: Data a => a -> a -> Bool
Non-strict equational constraint for linear functional patterns. |
(&)
:: Bool -> Bool -> Bool
Concurrent conjunction. |
(&>)
:: Bool -> a -> a
Conditional expression. |
(?)
:: a -> a -> a
Non-deterministic choice par excellence. |
anyOf
:: [a] -> a
Returns non-deterministically any element of a list. |
unknown
:: Data a => a
Evaluates to a fresh free variable. |
failed
:: a
A non-reducible polymorphic function. |
error
:: String -> a
Aborts the execution with an error message. |
apply
:: (a -> b) -> a -> b
|
cond
:: Bool -> a -> a
|
PEVAL
:: a -> a
Identity function used by the partial evaluator to mark expressions to be partially evaluated. |
Constructors:
Constructors:
Constructors:
The type of Boolean values.
Constructors:
False
:: Bool
True
:: Bool
Ordering type. Useful as a result of comparison functions.
Constructors:
LT
:: Ordering
EQ
:: Ordering
GT
:: Ordering
The type synonym ShowS
represent strings as difference lists.
Composing functions of this type allows concatenation of lists
in constant time.
Type synonym: ShowS = String -> String
The type synonym ReadS
represent a parser for values of type a.
Such a parser is a function that takes a String and
returns a list of possible parses as (a,String)
pairs.
Thus, if the result is the empty list, there is no parse, i.e.,
the input string is not valid.
Type synonym: ReadS a = String -> [(a,String)]
The type String
is a type synonym for list of characters so that
all list operations can be used on strings.
Type synonym: String = [Char]
The Maybe
type can be used for values which could also be absent.
Constructors:
Nothing
:: Maybe a
Just
:: a -> Maybe a
The Either
type can be used to combine values of two different types.
Constructors:
Left
:: a -> Either a b
Right
:: b -> Either a b
Constructors:
The FilePath
is j type synonym for strings.
It is useful to mark in type signatures if a file path is required.
Type synonym: FilePath = String
The (abstract) type of error values. Currently, it distinguishes between general I/O errors, user-generated errors (see userError), failures and non-determinism errors during I/O computations. These errors can be caught by catch. Each error contains a string shortly explaining the error. This type might be extended in the future to distinguish further error situations.
Constructors:
IOError
:: String -> IOError
UserError
:: String -> IOError
FailError
:: String -> IOError
NondetError
:: String -> IOError
The type synonym for constraints. It is included for backward compatibility and should be no longer used.
Type synonym: Success = Bool
Identity type synonym used to mark deterministic operations. Used by the Curry preprocessor.
Type synonym: DET a = a
The negation of strict equality.
|
|
Converts a showable value to a show function that prepends this value. |
Converts a character to a show function that prepends the character.
|
Converts a string to a show function that prepends the string. |
If the first argument is |
Converts a list of show functions to a show function combining the given show functions to a tuple representation. |
A parser to read data from a string.
For instance, |
|
Reads data of the given type from a string.
The operations fails if the data cannot be parsed.
For instance
|
Reads a single lexeme from the given string.
Initial white space is discarded and the characters of the lexeme
are returned. If the input string contains only white space,
|
Returns whether an integer is even. |
Returns whether an integer is odd. |
General coercion from integral types. |
General coercion to fractional types. |
Raises a number to a non-negative integer power.
|
|
Promotes a function to a monad. The function arguments are scanned
from left to right.
For instance, |
Executes a sequence of monadic actions and collects all results in a list. |
Executes a sequence of monadic actions and ignores the results. |
Maps a monadic action function on a list of elements. The results of all monadic actions are collected in a list. |
Maps an monadic action function on a list of elements. The results of all monadic actions are ignored. |
Returns true if the argument is an uppercase letter. |
Returns true if the argument is an lowercase letter. |
Returns true if the argument is a letter. |
Returns true if the argument is a decimal digit. |
Returns true if the argument is a letter or digit. |
Returns true if the argument is a binary digit. |
Returns true if the argument is an octal digit. |
Returns true if the argument is a hexadecimal digit. |
Returns true if the argument is a white space. |
Converts a character into its ASCII value. |
Converts a Unicode value into a character. The conversion is total, i.e., for out-of-bound values, the smallest or largest character is generated.
|
Breaks a string into a list of lines where a line is terminated at a newline character. The resulting lines do not contain newline characters. |
Concatenates a list of strings with terminating newlines. |
Breaks a string into a list of words where the words are delimited by white spaces. |
Concatenates a list of strings with a blank between two strings. |
Right-associative application.
|
Right-associative application with strict evaluation of its argument to head normal form.
|
Right-associative application with strict evaluation of its argument to normal form.
|
Right-associative application with strict evaluation of its argument to a non-variable term.
|
Right-associative application with strict evaluation of its argument to ground normal form.
|
Evaluates the first argument to head normal form (which could also be a free variable) and returns the second argument.
|
Evaluates the argument to head normal form and returns it. Suspends until the result is bound to a non-variable term.
|
Evaluates the argument to spine form and returns it. Suspends until the result is bound to a non-variable spine. |
Evaluates the argument to normal form and returns it. |
Evaluates the argument to ground normal form and returns it. Suspends as long as the normal form of the argument is not ground. |
Function composition.
|
Identity function.
|
Constant function.
|
|
Converts an uncurried function to a curried function. |
Converts an curried function to a function on pairs. |
|
Repeats application of a function until a predicate holds. |
Sequential conjunction on Booleans.
|
Sequential disjunction on Booleans.
|
Negation on Booleans.
|
Useful name for the last condition in a sequence of conditional equations.
|
The standard conditional. It suspends if the condition is a free variable. |
Selects the first component of a pair.
|
Selects the second component of a pair.
|
Computes the first element of a list.
|
Computes the remaining elements of a list.
|
Is a list empty?
|
Concatenates two lists. Since it is flexible, it could be also used to split a list into two sublists etc.
|
Computes the length of a list. |
List index (subscript) operator, head has index 0.
|
Maps a function on all elements of a list. |
Accumulates all list elements by applying a binary operator from left to right. |
Accumulates a non-empty list from left to right.
|
Accumulates all list elements by applying a binary operator from right to left. |
Accumulates a non-empty list from right to left:
|
Filters all elements satisfying a given predicate in a list. |
Joins two lists into one list of pairs. If one input list is shorter than the other, the additional elements of the longer list are discarded.
|
Joins three lists into one list of triples. If one input list is shorter than the other, the additional elements of the longer lists are discarded.
|
Joins two lists into one list by applying a combination function to
corresponding pairs of elements. Thus |
Joins three lists into one list by applying a combination function to
corresponding triples of elements. Thus |
Transforms a list of pairs into a pair of lists.
|
Transforms a list of triples into a triple of lists.
|
Concatenates a list of lists into one list. |
Maps a function from elements to lists and merges the result into one list. |
Infinite list of repeated applications of a function f to an element x.
Thus, |
Infinite list where all elements have the same value.
Thus,
|
List of length n where all elements have the same value. |
Returns prefix of length n. |
Returns suffix without first n elements. |
|
Returns longest prefix with elements satisfying a predicate. |
Returns suffix without takeWhile prefix. |
|
|
Reverses the order of all elements in a list. |
Computes the conjunction of a Boolean list. |
Computes the disjunction of a Boolean list. |
Is there an element in a list satisfying a given predicate? |
Is a given predicate satisfied by all elements in a list? |
Element of a list?
|
Not element of a list?
|
Looks up a key in an association list.
|
The |
Apply a case analysis to a value of the Either type.
If the value is |
An action that reads a character from standard output and returns it.
|
An action that reads a line from standard input and returns it. |
An action that puts its character argument on standard output. |
Action to print a string on standard output. |
Action to print a string with a newline on standard output. |
Converts a term into a string and prints it. |
An action that (lazily) reads a file and returns its contents. |
An action that writes a file. |
An action that appends a string to a file.
It behaves like |
A user error value is created by providing a description of the error situation as a string.
|
Raises an I/O exception with a given error value. |
Catches a possible error or failure during the execution of an
I/O action.
|
The always satisfiable constraint. It is included for backward compatibility and should be no longer used.
|
Enforce a Boolean condition to be true.
The computation fails if the argument evaluates to
|
Solves a constraint as an I/O action. Note: The constraint should be always solvable in a deterministic way.
|
The equational constraint.
|
Internal operation to implement equational constraints. It is used by the strict equality optimizer but should not be used in regular programs.
|
Non-strict equational constraint.
This operation is not intended to be used in source programs
but it is used to implement
functional patterns.
Conceptually,
|
Non-strict equational constraint for linear functional patterns. Thus, it must be ensured that the first argument is always (after evalutation by narrowing) a linear pattern. Experimental.
|
Concurrent conjunction.
An expression like
|
Conditional expression.
An expression like
|
Non-deterministic choice par excellence.
The value of
|
Returns non-deterministically any element of a list. |
Evaluates to a fresh free variable.
|
A non-reducible polymorphic function. It is useful to express a failure in a search branch of the execution.
|
Aborts the execution with an error message. |
|
|
Identity function used by the partial evaluator to mark expressions to be partially evaluated.
|