[Haskell-cafe] using an external application

Henning Thielemann lemming at henning-thielemann.de
Fri Nov 2 05:17:41 EDT 2007


On Fri, 2 Nov 2007, Felipe Lessa wrote:

> On 11/2/07, Stuart Cook <scook0 at gmail.com> wrote:
> > The solution would be to use a version of "readFile" that works in a
> > stricter way, by reading the file when it's told to, but I don't have
> > an implementation handy.
>
> I guess this does the job:
>
> > readFile' fp = do
> >   contents <- readFile fp
> >   let ret (x:xs) = x `seq` ret xs
> >       ret []     = return contents
> >   ret contents
>
> Maybe the "x `seq`" part isn't necessary at all.

Awful. It reminds me on MatLab where the developers have implemented many
automatisms which do arbitrary clever things in every corner case, but
nothing consistent, because they thought programmers want it that way.
Then the programmers must write wrappers in order to get functions with
consistent behaviour around the fully automated functions.

The "unlazying" procedure looks much like the "lazying" one, and I wonder
whether it would be a good idea to eventually add "readFileStrict",
"getContentStrict" and "hGetContentStrict" to the standard library.


More information about the Haskell-Cafe mailing list