You are on page 1of 4

A

first
Hugs
session
Task
1
Load the
filc
FirstLiterate.
lhs
into
Hugs, and evaluate
the
following
expre\sion\
square
size
square
double
(square
2)
$$
square
(double
2)
23
-
double
(3+1)
23
-
double 3+1
$$
+
34
13
'div'
5
13
'mod'
5
On the
basis
of this can you
work out
the purpose of
$$?
Task
2
Use
the Hugs
command
:type
to
tell
you the
type
of
each
of
these, apart
from
$$.
Task
3
What
is the
effect
of typing
each
of the following?
double
square
2
double
Try
to
give
an
explanation
of
the
results
that you
obtain.
Task
4
Edit
the
file
FirstLiterate.
lhs
to
include definitions
of
functions
from
integers
to
integers which
behave
as
follows.
26
Getting
started
with
Haskell
and
Hugs
The
function should
double
its input and
square
the
result
of
that.
The
function should
square
its input and
double
the result
of
that.
Your
solution should include
declarations
of
the types
of the
functions.
(z
The standard
prelude and
the
Haskell
libraries
Wc
saw
in Chapter
I
that Haskell has various
built-in
types, such
as
integers and lists
and
functions over
those
types,
including
the
arithmetic
functions
and
the list
functions
map
and
++.
Definitions
of
these
are contained
in a file. the
standar

You might also like