Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
report
Commits
6d2c3195
Commit
6d2c3195
authored
May 28, 2018
by
Michael Hanus
Browse files
Font typo problems for backslash and underscores resolved
parent
1e31a8fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
fieldlabels.tex
View file @
6d2c3195
...
...
@@ -188,7 +188,7 @@ more than once. Fields not named by the pattern are ignored (matched
against
\code
{
\us
}
).
\translation
{
Using the prior definition of
$
pick
$
,
\\
\code
{$
C
$
\{
bs
\}
= (
$
C
$
(
$
pick
_
1
^
C
$
$
bs
$
_
)
\ldots
{}
(
$
pick
_{
k
}^
C
$
$
bs
$
_
))
}
\\
\code
{$
C
$
\{
$
bs
$
\}
= (
$
C
$
(
$
pick
_
1
^
C
$
$
bs
$
\us
{}
)
\ldots
{}
(
$
pick
_{
k
}^
C
$
$
bs
$
\us
{}
))
}
\\
where
$
k
$
is the arity of
$
C
$
.
}
\noindent
...
...
prelude.tex
View file @
6d2c3195
...
...
@@ -123,9 +123,10 @@ not True = False
not False = True
-- Conditional
$
\index
{
conditional
}$
if
_
then
_
else :: Bool -> a -> a -> a
$
\pindex
{
if
_
then
_
else
}$
if
_
then
_
else :: Bool -> a -> a -> a
$
\pindex
{
if
\char
95
{}
then
\char
95
{}
else
}$
if
_
then
_
else b t f = case b of True -> t
False -> f
--- Useful name for the last condition in a sequence of conditional equations.
otherwise :: Bool
$
\pindex
{
otherwise
}$
otherwise = True
...
...
@@ -551,7 +552,7 @@ sequenceIO (c:cs) = do x <- c
return (x:xs)
-- Execute a sequence of I/O actions and ignore the results:
sequenceIO
_
:: [IO
_
] -> IO ()
$
\pindex
{
sequenceIO
_
}$
sequenceIO
_
:: [IO
_
] -> IO ()
$
\pindex
{
sequenceIO
\char
95
{}
}$
sequenceIO
_
= foldr (>>) done
-- Map an I/O action function on a list of elements.
...
...
@@ -561,7 +562,7 @@ mapIO f = sequenceIO . map f
-- Map an I/O action function on a list of elements.
-- The results of all I/O actions are ignored.
mapIO
_
:: (a -> IO
_
) -> [a] -> IO ()
$
\pindex
{
mapIO
_
}$
mapIO
_
:: (a -> IO
_
) -> [a] -> IO ()
$
\pindex
{
mapIO
\char
95
{}
}$
mapIO
_
f = sequenceIO
_
. map f
...
...
programs.tex
View file @
6d2c3195
...
...
@@ -658,7 +658,7 @@ If one expression contains free variables, they are
instantiated in order to evaluate the equality.
For instance,
\ccode
{
[
John
]==
x
}
binds
\code
{
x
}
to
\code
{
[
John
]
}
and reduces to
\code
{
True
}
, but it also reduces to
\code
{
False
}
with the bindings of
\code
{
x
}
to
\code
{
[]
}
,
\code
{
(
Alice:
_
)
}
etc.
with the bindings of
\code
{
x
}
to
\code
{
[]
}
,
\code
{
(
Alice:
\us
{}
)
}
etc.
If one is interested only in bindings for positive solutions,
i.e., reductions to
\code
{
True
}
, one can also use the predefined
...
...
report.tex
View file @
6d2c3195
...
...
@@ -79,13 +79,8 @@
\newcommand
{
\pindex
}
[1]
{
\index
{
#1@
{
\tt
#1
}}}
% program elements in index
\newcommand
{
\comment
}
[1]
{}
% ignore the argument
\newcommand
{
\bs
}{
\mbox
{
\char
92
}}
% backslash
\newcommand
{
\caret
}{
\mbox
{
\char
94
}}
\newcommand
{
\us
}{
\mbox
{
\char
95
}}
% underscore
% allow underscores in programs:
\catcode
`
\_
=
\active
\let
_
=
\sb
\catcode
`
\_
=12
\newcommand
{
\bs
}{
\code
{
\char
92
}}
% backslash
\newcommand
{
\us
}{
\code
{
\char
95
}}
% underscore
% commands for the syntax:
\newcommand
{
\sor
}{
\ensuremath
{
|
}
}
...
...
types.tex
View file @
6d2c3195
...
...
@@ -32,15 +32,15 @@ is predefined as \code{True}
to write rules with multiple guards more nicely.
Boolean values can be used in conditionals, i.e., the
conditional function
\code
{
if
_
then
_
else
}
\pindex
{
if
_
then
_
else
}
\index
{
conditional
}
conditional function
\code
{
if
\us
{}
then
\us
{}
else
}
\pindex
{
if
\char
95
{}
then
\char
95
{}
else
}
\index
{
conditional
}
is predefined as
\begin{curry}
if
_
then
_
else :: Bool -> a -> a -> a
if
_
then
_
else b t f = case b of True -> t
False -> f
\end{curry}
where
``
\code
{
if b then x else y
}
''
is syntactic sugar for the application
\code
{
(if
_
then
_
else b x y)
}
.
where
\
c
code
{
if b then x else y
}
is syntactic sugar for the application
\code
{
(if
\us
{}
then
\us
{}
else b x y)
}
.
Due to the definition based on a case expression
(see Section~
\ref
{
sec-case-expressions
}
), the evaluation of
a conditional suspends of the discriminating Boolean argument
...
...
@@ -71,7 +71,7 @@ compare Tail Tail = EQ
\end{curry}
Note that one can also compare expressions containing free variables.
For instance, the evaluation of
\ccode
{
x < [Tail]
}
yields
\code
{
True
}
for the bindings
\code
{
\{
x=[]
\}
}
and
\code
{
\{
x=(Head:
_
)
\}
}
.
for the bindings
\code
{
\{
x=[]
\}
}
and
\code
{
\{
x=(Head:
\us
{}
)
\}
}
.
For built-in types like numbers or characters,
some Curry systems might suspend when comparing unknown values.
...
...
@@ -138,7 +138,7 @@ f $! x = x `seq` f x
%
Thus, if
\code
{
inf
}
is a non-terminating function
(e.g., defined by ``
\code
{
inf = inf
}
'')
and
\code
{
f
}
a constant function defined by
``
\code
{
f
_
= 0
}
''
,
and
\code
{
f
}
a constant function defined by
\
c
code
{
f
\us
{}
= 0
}
,
then the evaluation of the expression ``
\code
{
f~
\$
!~inf
}
''
does not terminate whereas the expression ``
\code
{
f~
\$
~inf
}
''
evaluates to
\code
{
0
}
.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment