[Haskell-cafe] Why Haskell?

Neil Mitchell ndmitchell at gmail.com
Sun Jul 23 08:56:54 EDT 2006


> sequence [] = return []
> sequence (action:actions) = do x <- action
>                                xs <- sequence actions
>                                return (x:xs)
> sequence_ [] = return ()
> sequence_ (action:actions) = do action
>                                 sequence_ actions

So, by appending an underscore at the end of a name, you massively
improve the runtime behaviour of the program. That to me sounds like a
hack :)

Would it not be possible to add a GHC rule like the following:

forall a b . sequence a >> b  = sequence_ a >> b

I'm not sure if thats correct, a valid rule definition, or semantics
preserving, but if it was it would be nice :)



More information about the Haskell-Cafe mailing list