[Haskell-cafe] Execution of external command

Don Stewart dons at galois.com
Thu Dec 13 16:18:46 EST 2007


qdunkan:
> > it seems that script may be not terminated if its output isn't read, so
> > better code should be
> >
> > (_, h, g, _) <- runInteractiveCommand "script params"
> > result <- hGetLine h
> > hGetContents h >>= evaluate.length
> > hGetContents g >>= evaluate.length
> 
> Tangent here, but does anyone else think that something like
> hGetContentsEagerly would be handy in System.IO?  When I am reading
> lots of little files I worry about open file limits.  And besides, it
> seems like unsafeInterleaveIO can result in IO exceptions coming from
> pure code, so why use it if you don't have to?

I'll put a System.IO.Strict up on the weekend.
Until then, perhaps use, as I sometimes do:

    import qualified Data.ByteString as S

    hGetContentsStrict = S.unpack `fmap` S.hGetContents

Cheers,
    Don


More information about the Haskell-Cafe mailing list