
On Sat, Dec 28, 2013 at 2:04 AM, Herbert Valerio Riedel
On 2013-12-28 at 01:11:40 +0100, Ben Millwood wrote:
On Sun, Dec 22, 2013 at 12:02:16PM -0800, John Lato wrote:
On Dec 22, 2013 7:28 AM, "Herbert Valerio Riedel"
wrote: On 2013-12-22 at 11:32:20 +0100, Thomas Schilling wrote:
Either I should be able to check at compile time, or I should get a defined exception call which then must be handled by the library. In either case it should be documented with the function.
It might be worth adding more information to the Haddock-comments mentioning the respective `HAVE_*` CPP symbol and whether a fallback-implementation is used.
Moreover, the use of `error` to signal non-existing implementations could be reconsidered (e.g. maybe switch to a properly thrown "call-not-implemented" exception)
This would definitely be better than calling error. Personally I would prefer conditional exports, as it would turn up errors sooner.
John L.
What does client code look like, if this is your implementation strategy? Note that the network package recently changed to *stop* conditionally exporting things, because it led to bad error messages (yes, your error is caught at compile time, but it's not so clear what it *is*) and ugly client code. See e.g. https://github.com/haskell/network/issues/40
btw, as a compromise, one could export the symbol always (even if its body is exception-throwing stub) and at the same time enable a '{-# WARNING #-}' for that symbol for the not-implemented; that way one gets both, a stable API as well as compile-time warnings...
I didn't see this before I replied to Ben, but I think this is a fine solution.