[Haskell-cafe] Repeated function application

2008-02-21 Thread Ben Butler-Cole
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?

[Haskell-cafe] Circular enums

2008-02-02 Thread Ben Butler-Cole
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 ::

[Haskell-cafe] Circular enums - resend

2008-02-02 Thread Ben Butler-Cole
[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 =

Re: [Haskell-cafe] Circular enums

2008-02-02 Thread Ben Butler-Cole
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.