[Haskell-cafe] Is this haskelly enough?

David F. Place d at vidplace.com
Tue Jul 17 21:56:58 EDT 2007


On Jul 17, 2007, at 7:10 PM, Bjorn Bringert wrote:

> maxsubarrays = maximumBy (compare `on` sum) . (>>= tails) . inits
>
> Though I avoided using the list monad in the first solution, since  
> I thought it would make the code less understandable for a beginner.

I felt uncomfortable seeing this.  Let me see if I can explain why.   
Isn't the use of monads here unnecessary and obscure?   The use of  
inits, tails and maximumBy ground the function to a list  
representation.  There seems no hope of generalizing it to other  
monads.  The use of >>= is just an obscure way of saying (flip  
concatMap).

   ___________________
(---o-------o-o-o---o-o-o----(
David F. Place
mailto:d at vidplace.com




More information about the Haskell-Cafe mailing list