Re: PROPOSAL: add tryFdSeek to unix

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. John

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

On Wed, Jun 29, 2011 at 12:18 PM, Simon Marlow
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.
Agreed on both counts.

On Wed, Jun 29, 2011 at 9:09 PM, Bryan O'Sullivan
On Wed, Jun 29, 2011 at 12:18 PM, Simon Marlow
wrote: 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.
Agreed on both counts.
+1

On 29 June 2011 21:18, Simon Marlow
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.
We could use bindings-DSL for this foreign imports layer: http://hackage.haskell.org/package/bindings-DSL Bas
participants (4)
-
Bas van Dijk
-
Bryan O'Sullivan
-
John Lato
-
Simon Marlow