Module Prelude

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.


Exported Datatypes: Bool, Char, DET, Either, FilePath, Float, Int, IO, IOError, Maybe, Ordering, ReadS, ShowS, String, Success

Exported Functions: !!, $, $!, $!!, $#, $##, &, &&, &>, ++, ., /==, <$>, =:<<=, =:<=, =:=, =<<, ?, ^, all, and, any, anyOf, ap, appendFile, apply, asTypeOf, break, catch, chr, concat, concatMap, cond, const, constrEq, curry, doSolve, drop, dropWhile, either, elem, ensureNotFree, ensureSpine, eqString, error, even, failed, filter, flip, foldl, foldl1, foldr, foldr1, fromIntegral, fst, getChar, getLine, groundNormalForm, head, id, ifThenElse, ioError, isAlpha, isAlphaNum, isBinDigit, isDigit, isHexDigit, isLower, isOctDigit, isSpace, isUpper, iterate, length, lex, liftM2, lines, lookup, map, mapM, mapM_, maybe, normalForm, not, notElem, null, odd, or, ord, otherwise, PEVAL, print, putChar, putStr, putStrLn, read, readFile, readParen, reads, realToFrac, repeat, replicate, reverse, seq, sequence, sequence_, showChar, showParen, shows, showString, showTuple, snd, solve, span, splitAt, success, tail, take, takeWhile, uncurry, unknown, unlines, until, unwords, unzip, unzip3, userError, words, writeFile, zip, zip3, zipWith, zipWith3, ||

Exported Classes: Alternative, Applicative, Bounded, Data, Enum, Eq, Floating, Fractional, Functor, Integral, Monad, MonadFail, Monoid, Num, Ord, Read, Real, RealFrac, Show


Basic Datatypes


data Char

The externally defined type of characters.

Known instances:


data Int

The externally defined type of integers.

Known instances:


data Float

The externally defined type of float point numbers.

Known instances:


data Bool

The type of Boolean values.

Constructors:

  • False :: Bool
  • True :: Bool

Known instances:


data Ordering

Ordering type. Useful as a result of comparison functions.

Constructors:

  • LT :: Ordering
  • EQ :: Ordering
  • GT :: Ordering

Known instances:


data Maybe a

The Maybe type can be used for values which could also be absent.

Constructors:

  • Nothing :: Maybe a
  • Just :: a -> Maybe a

Known instances:


data Either a b

The Either type can be used to combine values of two different types.

Constructors:

  • Left :: a -> Either a b
  • Right :: b -> Either a b

Known instances:


Type Classes


class Data a

The class Data defines a strict equality operator === and a non-deterministic operation aValue which yields all values of the given type. To ensure that the operator === always corresponds to the syntactic equality of values and aValue enumerates all values, instances of Data are automatically derived and cannot be defined in a valid Curry program. For data types contain functional values, Data instances are not derived. Free variables have always a data context to ensure that possible values for the type of the free variable can be enumerated.

Note that the class Data is different from the class Eq, since the latter defines only an equivalence relation rather than syntactic equality.

Methods:

(===) :: a -> a -> Bool  

Further infos:
defined as non-associative infix operator with precedence 4

aValue :: a  


(/==) :: Data a => a -> a -> Bool  Deterministic 

The negation of strict equality.

Further infos:
  • defined as non-associative infix operator with precedence 4

class Eq a

The class Eq defines an equality (==) and an inequality (/=) method. Instances of this class should define an equivalence relationship on values. For basic data types, the instances are defined as syntactic equality of values.

Methods:

(==) :: a -> a -> Bool  

Further infos:
defined as non-associative infix operator with precedence 4

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

Further infos:
defined as non-associative infix operator with precedence 4

class Eq a => Ord a

The class Ord defines operations to compare values of the given type with respect to a total ordering. A minimal instance definition for some type must define <= or compare.

Methods:

compare :: a -> a -> Ordering  

(<) :: a -> a -> Bool  

Further infos:
defined as non-associative infix operator with precedence 4

(>) :: a -> a -> Bool  

Further infos:
defined as non-associative infix operator with precedence 4

(<=) :: a -> a -> Bool  

Further infos:
defined as non-associative infix operator with precedence 4

(>=) :: a -> a -> Bool  

Further infos:
defined as non-associative infix operator with precedence 4

min :: a -> a -> a  

max :: a -> a -> a  


class Show a

The class Show contains methods to transform values into a string representation.

Methods:

show :: a -> String  

showsPrec :: Int -> a -> ShowS  

showList :: [a] -> ShowS  


type ShowS = String -> String

The type synonym ShowS represents strings as difference lists. Composing functions of this type allows concatenation of lists in constant time.


shows :: Show a => a -> String -> String  Deterministic 

Converts a showable value to a show function that prepends this value.


showChar :: Char -> String -> String  Deterministic 

Converts a character to a show function that prepends the character.

Further infos:
  • solution complete, i.e., able to compute all solutions

showString :: String -> String -> String  Deterministic 

Converts a string to a show function that prepends the string.


showParen :: Bool -> (String -> String) -> String -> String  Deterministic 

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  Deterministic 

Converts a list of show functions to a show function combining the given show functions to a tuple representation.


class Read a

The class Read contains method to parse strings to return values corresponding to the textual representation as produced by show.

Methods:

readsPrec :: Int -> ReadS a  

readList :: ReadS [a]  


type ReadS a = String -> [(a, 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.


reads :: Read a => String -> [(a, String)]  Deterministic 

A parser to read data from a string. For instance, reads "42" :: [(Int,String)] returns [(42,[])], and reads "hello" :: [(Int,String)] returns [].


readParen :: Bool -> (String -> [(a, String)]) -> String -> [(a, String)]  Deterministic 

readParen True p parses what p parses, but surrounded with parentheses. readParen False p parses what p parses, but the string to be parsed can be optionally with parentheses.


read :: Read a => String -> a  Deterministic 

Reads data of the given type from a string. The operations fails if the data cannot be parsed. For instance read "42" :: Int evaluates to 42, and read "hello" :: Int fails.

Further infos:
  • partially defined

lex :: String -> [(String, String)]  Deterministic 

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, lex returns the empty string as lexeme. If there is no legal lexeme at the beginning of the input string, the operation fails, i.e., [] is returned.

Further infos:
  • partially defined

class Bounded a

Instances of the class Bounded are types with minmal and maximal values.

Methods:

minBound :: a  

maxBound :: a  


class Enum a

The class Enum provides methods to enumerate values of the given type in a sequential order. If a type is an instance of Enum, one can use the standard notation for arithmetic sequences to enumerate list of values.

Methods:

toEnum :: Int -> a  

fromEnum :: a -> Int  

succ :: a -> a  

pred :: a -> a  

enumFrom :: a -> [a]  

enumFromThen :: a -> a -> [a]  

enumFromTo :: a -> a -> [a]  

enumFromThenTo :: a -> a -> a -> [a]  


Numerical Typeclasses


class Num a

The class of basic numeric values. For type wich are instances of Num, one can write values as integers which are converted by an implicit fromInt application.

Methods:

(+) :: a -> a -> a  

Further infos:
defined as left-associative infix operator with precedence 6

(*) :: a -> a -> a  

Further infos:
defined as left-associative infix operator with precedence 7

abs :: a -> a  

signum :: a -> a  

fromInt :: Int -> a  

(-) :: a -> a -> a  

Further infos:
defined as left-associative infix operator with precedence 6

negate :: a -> a  


class Num a => Fractional a

The class Fractional defines numbers with a division operation.

Methods:

fromFloat :: Float -> a  

recip :: a -> a  

(/) :: a -> a -> a  

Further infos:
defined as left-associative infix operator with precedence 7

class (Num a, Ord a) => Real a

The class of real numbers which can be mapped to floats.

Methods:

toFloat :: a -> Float  


class (Real a, Enum a) => Integral a

The class of Integral numbers supports integer division operators.

Methods:

divMod :: a -> a -> (a, a)  

quotRem :: a -> a -> (a, a)  

toInt :: a -> Int  

div :: a -> a -> a  

Further infos:
defined as left-associative infix operator with precedence 7

mod :: a -> a -> a  

Further infos:
defined as left-associative infix operator with precedence 7

quot :: a -> a -> a  

Further infos:
defined as left-associative infix operator with precedence 7

rem :: a -> a -> a  

Further infos:
defined as left-associative infix operator with precedence 7

even :: Integral a => a -> Bool  Deterministic 

Returns whether an integer is even.


odd :: Integral a => a -> Bool  Deterministic 

Returns whether an integer is odd.


fromIntegral :: (Integral a, Num b) => a -> b  Deterministic 

General coercion from integral types.


realToFrac :: (Real a, Fractional b) => a -> b  Deterministic 

General coercion to fractional types.


(^) :: (Num a, Integral b) => a -> b -> a  Deterministic 

Raises a number to a non-negative integer power.

Further infos:
  • partially defined

class (Real a, Fractional a) => RealFrac a

Instances of the class RealFrac supports extracting components of Fractional values.

Methods:

properFraction :: Integral b => a -> (b, a)  

truncate :: Integral b => a -> b  

round :: Integral b => a -> b  

ceiling :: Integral b => a -> b  

floor :: Integral b => a -> b  


class Fractional a => Floating a

The class Floating defines Fractionals with trigonometric and hyperbolic and related functions.

Methods:

pi :: a  

exp :: a -> a  

log :: a -> a  

sin :: a -> a  

cos :: a -> a  

asin :: a -> a  

acos :: a -> a  

atan :: a -> a  

sinh :: a -> a  

cosh :: a -> a  

asinh :: a -> a  

acosh :: a -> a  

atanh :: a -> a  

sqrt :: a -> a  

(**) :: a -> a -> a  

logBase :: a -> a -> a  

tan :: a -> a  

tanh :: a -> a  


class Monoid a

The class Monoid defines types with an associative binary operation mappend having an identity mempty.

Methods:

mempty :: a  

mappend :: a -> a -> a  

mconcat :: [a] -> a  


class Functor f

The class Functor defines a general mapping of values contained in structures. A type constructor f is a Functor if it provides a function fmap which applies a function of type (a -> b) to all values contained in a structure of type f a yielding a structure of type f b.

Methods:

fmap :: (a -> b) -> f a -> f b  

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

Further infos:
defined as left-associative infix operator with precedence 4

class Functor f => Applicative f

The class Applicative defines a functor structure with application operators to apply functions and argument contained in structure and combining their results back into a structure.

Methods:

pure :: a -> f a  

(<*>) :: f (a -> b) -> f a -> f b  

Further infos:
defined as left-associative infix operator with precedence 4

(*>) :: f a -> f b -> f b  

Further infos:
defined as left-associative infix operator with precedence 4

(<*) :: f a -> f b -> f a  

Further infos:
defined as left-associative infix operator with precedence 4

liftA2 :: (a -> b -> c) -> f a -> f b -> f c  


class Applicative f => Alternative f

A monoid on applicative functors.

If defined, some and many should be the least solutions of the equations:

Methods:

empty :: f a  

The identity of <|>

(<|>) :: f a -> f a -> f a  

An associative binary operation

Further infos:
defined as left-associative infix operator with precedence 3

some :: f a -> f [a]  

One or more.

many :: f a -> f [a]  

Zero or more.


class Applicative m => Monad m

The class Monad defines operators for the sequential composition of computations. For instances of Monad, the standard do notation can be used.

Methods:

(>>=) :: m a -> (a -> m b) -> m b  

Further infos:
defined as left-associative infix operator with precedence 1

return :: a -> m a  

(>>) :: m a -> m b -> m b  

Further infos:
defined as left-associative infix operator with precedence 1

class Monad m => MonadFail m

The class MonadFail adds a fail operation to a monadic structure.

Methods:

fail :: String -> m a  


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

Same as >>=, but with the arguments interchanged.

Further infos:
  • defined as right-associative infix operator with precedence 1

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

Promotes function application to a monad. For instance,

> pure not `ap` Just True
Just False

This is useful to promote application of functions with larger arities to a monad, as liftM2 for arity 2. For instance,

> pure (\x y z -> x + y * z) `ap` Just 7 `ap` Just 5 `ap` Just 7
Just 42


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

Promotes a binary function to a monad. The function arguments are scanned from left to right. For instance, liftM2 (+) [1,2] [3,4] evaluates to [4,5,5,6], and liftM2 (,) [1,2] [3,4] evaluates to [(1,3),(1,4),(2,3),(2,4)].


sequence :: Monad a => [a b] -> a [b]  Deterministic 

Executes a sequence of monadic actions and collects all results in a list.


sequence_ :: Monad a => [a b] -> a ()  Deterministic 

Executes a sequence of monadic actions and ignores the results.


mapM :: Monad b => (a -> b c) -> [a] -> b [c]  Deterministic 

Maps a monadic action function on a list of elements. The results of all monadic actions are collected in a list.


mapM_ :: Monad b => (a -> b c) -> [a] -> b ()  Deterministic 

Maps a monadic action function on a list of elements. The results of all monadic actions are ignored.


Operations on Characters


isUpper :: Char -> Bool  Deterministic 

Returns true if the argument is an uppercase letter.


isLower :: Char -> Bool  Deterministic 

Returns true if the argument is an lowercase letter.


isAlpha :: Char -> Bool  Deterministic 

Returns true if the argument is a letter.


isDigit :: Char -> Bool  Deterministic 

Returns true if the argument is a decimal digit.


isAlphaNum :: Char -> Bool  Deterministic 

Returns true if the argument is a letter or digit.


isBinDigit :: Char -> Bool  Deterministic 

Returns true if the argument is a binary digit.


isOctDigit :: Char -> Bool  Deterministic 

Returns true if the argument is an octal digit.


isHexDigit :: Char -> Bool  Deterministic 

Returns true if the argument is a hexadecimal digit.


isSpace :: Char -> Bool  Deterministic 

Returns true if the argument is a white space.


ord :: Char -> Int  Deterministic 

Converts a character into its ASCII value.


chr :: Int -> Char  Deterministic 

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.

Further infos:
  • partially defined

type String = [Char]

The type String is a type synonym for list of characters so that all list operations can be used on strings.


lines :: String -> [String]  Deterministic 

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.


unlines :: [String] -> String  Deterministic 

Concatenates a list of strings with terminating newlines.


words :: String -> [String]  Deterministic 

Breaks a string into a list of words where the words are delimited by white spaces.


unwords :: [String] -> String  Deterministic 

Concatenates a list of strings with a blank between two strings.


Operations on Lists


head :: [a] -> a  Deterministic 

Computes the first element of a list.

Further infos:
  • partially defined

tail :: [a] -> [a]  Deterministic 

Computes the remaining elements of a list.

Further infos:
  • partially defined

null :: [a] -> Bool  Deterministic 

Is a list empty?

Further infos:
  • solution complete, i.e., able to compute all solutions

(++) :: [a] -> [a] -> [a]  Deterministic 

Concatenates two lists. Since it is flexible, it could be also used to split a list into two sublists etc.

Further infos:
  • defined as right-associative infix operator with precedence 5
  • solution complete, i.e., able to compute all solutions

length :: [a] -> Int  Deterministic 

Computes the length of a list.


(!!) :: [a] -> Int -> a  Deterministic 

List index (subscript) operator, head has index 0.

Further infos:
  • defined as left-associative infix operator with precedence 9
  • partially defined

map :: (a -> b) -> [a] -> [b]  Deterministic 

Maps a function on all elements of a list.


foldl :: (a -> b -> a) -> a -> [b] -> a  Deterministic 

Accumulates all list elements by applying a binary operator from left to right.


foldl1 :: (a -> a -> a) -> [a] -> a  Deterministic 

Accumulates a non-empty list from left to right.

Further infos:
  • partially defined

foldr :: (a -> b -> b) -> b -> [a] -> b  Deterministic 

Accumulates all list elements by applying a binary operator from right to left.


foldr1 :: (a -> a -> a) -> [a] -> a  Deterministic 

Accumulates a non-empty list from right to left:

Further infos:
  • partially defined

filter :: (a -> Bool) -> [a] -> [a]  Deterministic 

Filters all elements satisfying a given predicate in a list.


zip :: [a] -> [b] -> [(a, b)]  Deterministic 

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.

Further infos:
  • solution complete, i.e., able to compute all solutions

zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]  Deterministic 

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.

Further infos:
  • solution complete, i.e., able to compute all solutions

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]  Deterministic 

Joins two lists into one list by applying a combination function to corresponding pairs of elements. Thus zip = zipWith (,)


zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]  Deterministic 

Joins three lists into one list by applying a combination function to corresponding triples of elements. Thus zip3 = zipWith3 (,,)


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

Transforms a list of pairs into a pair of lists.

Further infos:
  • solution complete, i.e., able to compute all solutions

unzip3 :: [(a, b, c)] -> ([a], [b], [c])  Deterministic 

Transforms a list of triples into a triple of lists.

Further infos:
  • solution complete, i.e., able to compute all solutions

concat :: [[a]] -> [a]  Deterministic 

Concatenates a list of lists into one list.


concatMap :: (a -> [b]) -> [a] -> [b]  Deterministic 

Maps a function from elements to lists and merges the result into one list.


iterate :: (a -> a) -> a -> [a]  Deterministic 

Infinite list of repeated applications of a function f to an element x. Thus, iterate f x = [x, f x, f (f x), ...].


repeat :: a -> [a]  Deterministic 

Infinite list where all elements have the same value. Thus, repeat x = [x, x, x, ...].

Further infos:
  • solution complete, i.e., able to compute all solutions

replicate :: Int -> a -> [a]  Deterministic 

List of length n where all elements have the same value.


take :: Int -> [a] -> [a]  Deterministic 

Returns prefix of length n.


drop :: Int -> [a] -> [a]  Deterministic 

Returns suffix without first n elements.


splitAt :: Int -> [a] -> ([a], [a])  Deterministic 

splitAt n xs is equivalent to (take n xs, drop n xs)


takeWhile :: (a -> Bool) -> [a] -> [a]  Deterministic 

Returns longest prefix with elements satisfying a predicate.


dropWhile :: (a -> Bool) -> [a] -> [a]  Deterministic 

Returns suffix without takeWhile prefix.


span :: (a -> Bool) -> [a] -> ([a], [a])  Deterministic 

span p xs is equivalent to (takeWhile p xs, dropWhile p xs)

Further infos:
  • partially defined

break :: (a -> Bool) -> [a] -> ([a], [a])  Deterministic 

break p xs is equivalent to (takeWhile (not . p) xs, dropWhile (not . p) xs). Thus, it breaks a list at the first occurrence of an element satisfying p.


reverse :: [a] -> [a]  Deterministic 

Reverses the order of all elements in a list.


and :: [Bool] -> Bool  Deterministic 

Computes the conjunction of a Boolean list.


or :: [Bool] -> Bool  Deterministic 

Computes the disjunction of a Boolean list.


any :: (a -> Bool) -> [a] -> Bool  Deterministic 

Is there an element in a list satisfying a given predicate?


all :: (a -> Bool) -> [a] -> Bool  Deterministic 

Is a given predicate satisfied by all elements in a list?


elem :: Eq a => a -> [a] -> Bool  Deterministic 

Element of a list?

Further infos:
  • defined as non-associative infix operator with precedence 4

notElem :: Eq a => a -> [a] -> Bool  Deterministic 

Not element of a list?

Further infos:
  • defined as non-associative infix operator with precedence 4

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

Looks up a key in an association list.

Further infos:
  • partially defined

(<$>) :: Functor c => (a -> b) -> c a -> c b  Deterministic 

Apply a function of type (a -> b), given as the left argument, to a value of type f a, where f is a functor, to get a value of type f b. Basically, this is an infix operator version of fmap.

Further infos:
  • defined as left-associative infix operator with precedence 4

Evaluation


($) :: (a -> b) -> a -> b  Deterministic 

Right-associative application.

Further infos:
  • defined as right-associative infix operator with precedence 0

($!) :: (a -> b) -> a -> b  Deterministic 

Right-associative application with strict evaluation of its argument to head normal form.

Further infos:
  • defined as right-associative infix operator with precedence 0
  • externally defined

($!!) :: (a -> b) -> a -> b  Deterministic 

Right-associative application with strict evaluation of its argument to normal form.

Further infos:
  • defined as right-associative infix operator with precedence 0
  • externally defined

($#) :: (a -> b) -> a -> b  Deterministic 

Right-associative application with strict evaluation of its argument to a non-variable term.

Further infos:
  • defined as right-associative infix operator with precedence 0

($##) :: (a -> b) -> a -> b  Deterministic 

Right-associative application with strict evaluation of its argument to ground normal form.

Further infos:
  • defined as right-associative infix operator with precedence 0
  • externally defined

seq :: a -> b -> b  Deterministic 

Evaluates the first argument to head normal form (which could also be a free variable) and returns the second argument.

Further infos:
  • defined as right-associative infix operator with precedence 0

ensureNotFree :: a -> a  Deterministic 

Evaluates the argument to head normal form and returns it. Suspends until the result is bound to a non-variable term.

Further infos:
  • externally defined

ensureSpine :: [a] -> [a]  Deterministic 

Evaluates the argument to spine form and returns it. Suspends until the result is bound to a non-variable spine.


normalForm :: a -> a  Deterministic 

Evaluates the argument to normal form and returns it.


groundNormalForm :: a -> a  Deterministic 

Evaluates the argument to ground normal form and returns it. Suspends as long as the normal form of the argument is not ground.


Other Functions


(.) :: (a -> b) -> (c -> a) -> c -> b  Deterministic 

Function composition.

Further infos:
  • defined as right-associative infix operator with precedence 9

id :: a -> a  Deterministic 

Identity function.

Further infos:
  • solution complete, i.e., able to compute all solutions

const :: a -> b -> a  Deterministic 

Constant function.

Further infos:
  • solution complete, i.e., able to compute all solutions

asTypeOf :: a -> a -> a  Deterministic 

asTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the second.

Further infos:
  • solution complete, i.e., able to compute all solutions

curry :: ((a, b) -> c) -> a -> b -> c  Deterministic 

Converts an uncurried function to a curried function.


uncurry :: (a -> b -> c) -> (a, b) -> c  Deterministic 

Converts an curried function to a function on pairs.


flip :: (a -> b -> c) -> b -> a -> c  Deterministic 

flip f is identical to f, but with the order of arguments reversed.


until :: (a -> Bool) -> (a -> a) -> a -> a  Deterministic 

Repeats application of a function until a predicate holds.


(&&) :: Bool -> Bool -> Bool  Deterministic 

Sequential conjunction on Booleans.

Further infos:
  • defined as right-associative infix operator with precedence 3
  • solution complete, i.e., able to compute all solutions

(||) :: Bool -> Bool -> Bool  Deterministic 

Sequential disjunction on Booleans.

Further infos:
  • defined as right-associative infix operator with precedence 2
  • solution complete, i.e., able to compute all solutions

not :: Bool -> Bool  Deterministic 

Negation on Booleans.

Further infos:
  • solution complete, i.e., able to compute all solutions

otherwise :: Bool  Deterministic 

Useful name for the last condition in a sequence of conditional equations.

Further infos:
  • solution complete, i.e., able to compute all solutions

ifThenElse :: Bool -> a -> a -> a  Deterministic 

The standard conditional. It suspends if the condition is a free variable.


maybe :: a -> (b -> a) -> Maybe b -> a  Deterministic 

The maybe function takes a default value, a function, and a Maybe value. If the Maybe value is Nothing, the default value is returned. Otherwise, the function is applied to the value inside the Just and the result is returned.


either :: (a -> b) -> (c -> b) -> Either a c -> b  Deterministic 

Apply a case analysis to a value of the Either type. If the value is Left x, the first function is applied to x. If the value is Right y, the second function is applied to y.


fst :: (a, b) -> a  Deterministic 

Selects the first component of a pair.

Further infos:
  • solution complete, i.e., able to compute all solutions

snd :: (a, b) -> b  Deterministic 

Selects the second component of a pair.

Further infos:
  • solution complete, i.e., able to compute all solutions

failed :: a  Deterministic 

A non-reducible polymorphic function. It is useful to express a failure in a search branch of the execution.

Further infos:
  • externally defined

error :: String -> a  Deterministic 

Aborts the execution with an error message.


IO-Type and Operations


data IO _

The externally defined type of IO actions.

Known instances:


getChar :: IO Char  Deterministic 

An action that reads a character from standard output and returns it.

Further infos:
  • externally defined

getLine :: IO String  Deterministic 

An action that reads a line from standard input and returns it.


putChar :: Char -> IO ()  Deterministic 

An action that puts its character argument on standard output.


putStr :: String -> IO ()  Deterministic 

Action to print a string on standard output.


putStrLn :: String -> IO ()  Deterministic 

Action to print a string with a newline on standard output.


print :: Show a => a -> IO ()  Deterministic 

Converts a term into a string and prints it.


type FilePath = String

The FilePath is j type synonym for strings. It is useful to mark in type signatures if a file path is required.


readFile :: String -> IO String  Deterministic 

An action that (lazily) reads a file and returns its contents.


writeFile :: String -> String -> IO ()  Deterministic 

An action that writes a file.


appendFile :: String -> String -> IO ()  Deterministic 

An action that appends a string to a file. It behaves like writeFile if the file does not exist.


data IOError

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

Known instances:


userError :: String -> IOError  Deterministic 

A user error value is created by providing a description of the error situation as a string.

Further infos:
  • solution complete, i.e., able to compute all solutions

ioError :: IOError -> IO a  Deterministic 

Raises an I/O exception with a given error value.


catch :: IO a -> (IOError -> IO a) -> IO a  Deterministic 

Catches a possible error or failure during the execution of an I/O action. catch act errfun executes the I/O action act. If an exception or failure occurs during this I/O action, the function errfun is applied to the error value.

Further infos:
  • externally defined

Constraint Programming


type Success = Bool

The type synonym for constraints. It is included for backward compatibility and should be no longer used.


success :: Bool  Deterministic 

The always satisfiable constraint. It is included for backward compatibility and should be no longer used.

Further infos:
  • solution complete, i.e., able to compute all solutions

solve :: Bool -> Bool  Deterministic 

Enforce a Boolean condition to be true. The computation fails if the argument evaluates to False.

Further infos:
  • partially defined

doSolve :: Bool -> IO ()  Deterministic 

Solves a constraint as an I/O action. Note: The constraint should be always solvable in a deterministic way.

Further infos:
  • partially defined

(=:=) :: Data a => a -> a -> Bool  Deterministic 

The equational constraint. (e1 =:= e2) is satisfiable if both sides e1 and e2 can be reduced to a unifiable data term (i.e., a term without defined function symbols).

Further infos:
  • defined as non-associative infix operator with precedence 4
  • partially defined

(=:<=) :: Data a => a -> a -> Bool  Deterministic 

Non-strict equational constraint. This operation is not intended to be used in source programs but it is used to implement functional patterns. Conceptually, (e1 =:<= e2) is satisfiable if e1 can be evaluated to some pattern (data term) that matches e2, i.e., e2 is an instance of this pattern. The Data context is required since the resulting pattern might be non-linear so that it abbreviates some further equational constraints, see Section 7.

Further infos:
  • defined as non-associative infix operator with precedence 4
  • partially defined

constrEq :: a -> a -> Bool  Deterministic 

Internal operation to implement equational constraints. It is used by the strict equality optimizer but should not be used in regular programs.

Further infos:
  • partially defined
  • externally defined

(=:<<=) :: Data a => a -> a -> Bool  Deterministic 

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 and only supported in PAKCS.

Further infos:
  • defined as non-associative infix operator with precedence 4

(&) :: Bool -> Bool -> Bool  Deterministic 

Concurrent conjunction. An expression like (c1 & c2) is evaluated by evaluating the c1 and c2 in a concurrent manner.

Further infos:
  • defined as right-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions
  • externally defined

(&>) :: Bool -> a -> a  Deterministic 

Conditional expression. An expression like (c &> e) is evaluated by evaluating the first argument to True and then evaluating e. The expression has no value if the condition does not evaluate to True.

Further infos:
  • defined as right-associative infix operator with precedence 0
  • partially defined

Non-determinism


(?) :: a -> a -> a  Non-deterministic 

Non-deterministic choice par excellence. The value of x ? y is either x or y.

Further infos:
  • defined as right-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

anyOf :: [a] -> a  Non-deterministic 

Returns non-deterministically any element of a list.


unknown :: Data a => a  Non-deterministic 

Evaluates to a fresh free variable.

Further infos:
  • solution complete, i.e., able to compute all solutions

Internal Functions


apply :: (a -> b) -> a -> b  Deterministic 

Further infos:
  • externally defined

cond :: Bool -> a -> a  Deterministic 

Further infos:
  • externally defined

eqString :: String -> String -> Bool  Deterministic 


type DET a = a

Identity type synonym used to mark deterministic operations. Used by the Curry preprocessor.


PEVAL :: a -> a  Deterministic 

Identity function used by the partial evaluator to mark expressions to be partially evaluated.

Further infos:
  • solution complete, i.e., able to compute all solutions