On Fri, 2 Nov 2007, Felipe Lessa wrote: > On 11/2/07, Stuart Cook <[EMAIL PROTECTED]> 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. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe