[Haskell-beginners] More type errors I'm having trouble with

Kim-Ee Yeoh ky3 at atamo.com
Thu Dec 10 02:39:30 UTC 2015


On Thu, Dec 10, 2015 at 8:35 AM, Dan Stromberg <strombrg at 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 at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151210/d5c6f411/attachment-0001.html>


More information about the Beginners mailing list