Hello
I was surprised to be unable to find anything like this in the standard
libraries:
times :: (a - a) - Int - (a - a)
times f 0 = id
times f n = f . (times f (n-1))
Am I missing something more general which would allow me to repeatedly apply a
function to an input? Or is this not useful?
Hello
I'm
trying
to
define
functions
that
allow
you
to
traverse
a
bounded
enumeration,
wrapping
at
the
start
and
the
end.
My implementation looks like this:
next,
prev
::
(Enum
a,
Bounded
a)
=
a
-
a
next
=
turn
1
prev
=
turn
(-1)
turn
::
[Resending
with
formatting
fixed.]
Hello
I'm
trying
to
define
functions
that
allow
you
to
traverse
a
bounded
enumeration,
wrapping
at
the
start
and
the
end.
My
implementation
looks
like
this:
next,
prev
::
(Enum
a,
Bounded
a)
=
a
-
a
next
=
On
Feb
2,
2008,
at
18:41
, I
wrote:
No
instance
for
(Bounded
a)
arising
from
use
of
`maxBound'
at
Hbot.hs:6:34-41
(...)
My
(clearly
flawed)
understanding
of
the
signature
I've
specified
for
'turn'
means
*exactly*
that
a
is
Bounded.