
Hi everyone, I have a task that involves parsing a flat-file into a vector from the Data.Vector package. In the interest of keeping things simple, I first used Attoparsec.Text's version of "many" and then converted the resulting list to a vector: import qualified Data.Vector as V import Data.Attoparsec.Text as A import Control.Applicative getData = do results <- A.many someParser return (V.fromList results) It runs quickly, but I naively thought I could outperform it by reworking "many" to build a vector directly, instead of having to build a list first and then convert it to a vector: manyVec :: Alternative f => f a -> f (V.Vector a) manyVec v = many_v where many_v = some_v <|> pure V.empty some_v = V.cons <$> v <*> many_v Unfortunately, manyVec either quickly leads to a stack space overflow, or it takes an enormous amount of time to run. Does anyone know of a better way to build up a vector from parsing results? Thanks for any tips or insight, Eric