[Haskell-cafe] Iteratee performance
Thomas Schilling
nominolo at googlemail.com
Wed Mar 17 19:17:13 EDT 2010
As a general style tip, since you're using language extensions anyway
> {-# LANGUAGE RankNTypes, ScopedTypeVariables #-}
you might want to add "BangPatterns", so you can put the strictness
annotation directly on the argument. Either by doing this:
go !n = ...
or later on:
let !n' = ...
return I.Cont ...
> cnt = go 0
> where
> go n = I.IterateeG $ \ch ->
> case ch of
> (I.EOF Nothing) -> return $ I.Done n ch
> (I.EOF (Just e)) -> return $ I.Cont cnt (Just e)
> (I.Chunk (I.WrapBS s)) -> do
> let n' = n + S.count '\n' s
> return $ n' `seq` I.Cont (go n') Nothing
>
More information about the Haskell-Cafe
mailing list