[Haskell-cafe] Code review: efficiency question
brianh at metamilk.com
Mon May 1 19:12:48 EDT 2006
I started off writing the following piece of monadic code:
drawModal :: Control -> ManagerM ()
drawModal c = do -- details omitted
-- Prolog style coding...
drawModals :: [Control] -> ManagerM ()
drawModals  = return ()
drawModals (c:cs) = do
then it struck me that I should have not bothered with drawModals and
instead should just have used:
mapM_ drawModal (reverse cs)
However, while this looks more elegant, it is less efficient?
In other words, how much optimization can one assume when writing Haskell
I'm trying to get a rough idea so I can decide whether to write helper
functions such as drawModals in future or whether I should always just use
the most elegant code instead.
More information about the Haskell-Cafe