Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
B Standard Prelude<br />
This section contains the standard prelude for <strong>Curry</strong> programs. 14 This prelude will be imported to<br />
every <strong>Curry</strong> program, i.e., the names declared in the prelude cannot be redefined.<br />
module prelude where<br />
-- Infix operator declarations<br />
infixl 9 !!<br />
infixr 9 .<br />
infixl 7 *, /, ‘div‘, ‘mod‘<br />
infixl 6 +, -<br />
infixr 5 ++, :<br />
infix 4 =:=, ==, /=, , =<br />
infix 4 ‘elem‘, ‘notElem‘<br />
infixr 3 &&<br />
infixr 2 ||<br />
infixl 1 >>, >>=<br />
infixr 0 $, $!, ‘seq‘, &, &><br />
-- Some standard combinators:<br />
-- Function composition<br />
(.) :: (b -> c) -> (a -> b) -> (a -> c)<br />
f . g = \x -> f (g x)<br />
-- Identity<br />
id :: a -> a<br />
id x = x<br />
-- Constant function<br />
const :: a -> b -> a<br />
const x _ = x<br />
-- Convert an uncurried function to a curried function<br />
curry :: ((a,b) -> c) -> a -> b -> c<br />
curry f a b = f (a,b)<br />
-- Convert an curried function to a function on pairs<br />
uncurry :: (a -> b -> c) -> (a,b) -> c<br />
uncurry f (a,b) = f a b<br />
14 The definition will be extended in a later version.<br />
46