Programming style (or: too clever by half?)

2003-11-12 Thread Graham Klyne
I just spotted a possible idiom for something that seems to pop up from time to time: foldr const But I can't help feeling that this code is perversely obscure. Does it have any advantages over the more obvious form suggested below? [[ headOrSomething = foldr const headOrSomething1 _ (x:_)

Re: Programming style (or: too clever by half?)

2003-11-12 Thread Andrew Pimlott
On Wed, Nov 12, 2003 at 02:54:32PM +, Graham Klyne wrote: I just spotted a possible idiom for something that seems to pop up from time to time: foldr const But I can't help feeling that this code is perversely obscure. Clever. I usually end up with something like listToMaybe

Re: Programming style (or: too clever by half?)

2003-11-12 Thread Hal Daume III
this is the same as the function 'fromMaybe' in Data.Maybe. the 'maybe' function in that library is also incredibly useful. On Wed, 12 Nov 2003, Andrew Pimlott wrote: On Wed, Nov 12, 2003 at 02:54:32PM +, Graham Klyne wrote: I just spotted a possible idiom for something that seems to