[Haskell-cafe] Comments and suggestions on code
Jonathan Cast
jonathanccast at fastmail.fm
Fri Jan 11 22:17:55 EST 2008
On 11 Jan 2008, at 2:24 PM, Andre Nathan wrote:
> processEntry :: DirStream -> IO ()
> processEntry ds = do
> entry <- readDirStream ds
> if entry =~ "^[0-9]+$"
> then do
> putStrLn entry
> processEntry ds
> else
> if entry == "" then return () else processEntry ds
>
> bar :: IO ()
> bar = do
> ds <- openDirStream "."
> processEntry ds
> closeDirStream ds
This is a 200% increase in code size for a 75% decrease in execution
time. (And, in general, the complexity can be much higher). That's
an engineering tradeoff, and one you'll have to decide yourself;
there's not much that can be done to make it go away.
jcc
More information about the Haskell-Cafe
mailing list