PROPOSAL: add tryFdSeek to unix
Simon Marlow
marlowsd at gmail.com
Wed Jun 29 21:18:25 CEST 2011
On 29/06/11 20:02, John Lato wrote:
>
> > I'd like to propose adding a variant of fdSeek which returns errors
> > directly instead of throwing an exception.
> >
>
> Why wouldn't you just wrap it in Control.Exception.try instead? And
> what's
> so special about seeking that suggests that it needs an alternate entry
> point?
>
>
> (Disclosure: I'm one of the people who requested this originally)
>
> Wrapping a function like `fdSeek` in a `try` to get a non-exception
> variant is wasteful. Exceptions are a Haskell layer on top of the more
> fundamental library call, and people who want access to that call
> directly shouldn't have to unwrap extra cruft to do so. Nor should they
> have to re-implement basic functionality because the library doesn't
> expose it.
>
> fdSeek just happens to be a current need of mine. I would hope that
> this approach would be adopted across the board.
>
>
> (In other words, I'm opposed to this proposal.)
>
>
> I'm opposed to exceptions, but there's no way to avoid them because
> the library doesn't expose a direct interface.
I think it would make sense to refactor the unix package into a very
thin "just the foreign imports" layer, and then the current unix as a
layer on top of that.
It doesn't make a great deal of sense to do this for just one function,
though. It would stick out like a sore thumb in the API.
Cheers,
Simon
More information about the Libraries
mailing list