Entries type: Re: tar-package was: Re: modules of cabal-install

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue Feb 24 08:19:49 EST 2009

On Tue, 2009-02-24 at 13:57 +0100, Christian Maeder wrote:
> Duncan Coutts wrote:
> >> Manipulating Entries is also not a typical user task. (Maybe the type
> >> Entries should just be "[Either String Entry]", but the given type is
> >> fine, as it only allows a final failure string)
> > 
> > Yeah I think only one failure is good.
>  data Entries = Entries [Entry] (Maybe String)
> or
>  directly using "([Entry], Maybe String)"

Sadly that does not account for streaming. We may not discover the error
until we've processed 100 megabytes of tar file. So we cannot give top
level access to an error that might happen at the end.

> is an alternative, where "Nothing" indicates no failure. This would
> avoid the extra folding and mapping on Entries

The nice thing about the current Entries is that it models the failure
modes and works lazily.

> and maybe "unpack" could then work on [Entry] only.

True, though it's also convenient that unpack just raises any entry
errors as IO errors. Converting Entries to [Entry] requires reading the
whole thing (to check there are no errors), again defeating
lazyness/streaming which would mean we could not work with large tar
files in constant space.


More information about the Libraries mailing list