On Thu, Dec 10, 2015 at 8:35 AM, Dan Stromberg <strombrg@gmail.com> wrote:

My thought was that going over the list of filenames+sizes and adding prefix hashes where available, would be easier to make robust, than attempting to get prefix hashes for all and zipping the results.

Is that not correct?
 
No, that's not correct. And the reason is that zipping is a pure computation (to use the jargon).

The errors can only come from file I/O.

Tupling incrementally and tupling all at once (namely, zipping) result in identical values.

Neither can fault unless the code goes out of its way into un-idiomatic, un-Haskelly territory.
 
Should I use a Maybe to deal with files that don't hash, so there will always be a one-to-one correspondence, allowing a zip?

Yes, to be precise, instead of a function :: FilePath -> IO String that could possibly throw IO exceptions, you'd write a FilePath -> IO (Maybe String) that's exception-free because it catches them.

Thanks.
 
Anytime.

 

--
Dan Stromberg

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners