<br><div class="gmail_quote">Henning Thielemann wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Bryan O&#39;Sullivan schrieb:<div><div>

</div><div class="h5"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have a source base that contains a number of source files that use APIs that vary by platform: every platform provides select, most provide poll, BSDs provide kqueue, and Linux provides epoll. I already have autoconf tests for these functions, and I&#39;d like to use the results of those autoconf checks to determine which modules to compile, but I am unable to figure out how to do this in my .cabal or .buildinfo file. (I /could/ have explicit os conditionals in there, but that&#39;s ugly.)<br>


<br>
Right now, I&#39;m just building all of the modules, and conditionally giving them bodies as follows:<br>
<br>
module System.Event.EPoll where<br>
#if defined(HAVE_EPOLL)<br>
...<br>
#endif<br>
<br>
The trouble with this is twofold. I have to export everything in the module (because its contents vary depending on where I compile it), and the CPP macros there are ugly. Is there a better solution?<br>
</blockquote></div></div>
This means that modules with the same name have different set of functions, depending on OS? I think this is generally unsafe, because other packages would have to check what API to expect according to the OS.<br></blockquote>

<div><br>I agree. This definitely causes problems. In fact, I believe just such CPP results in difficulty using the network package with Happstack on the Mac by ifdef-ing out the IPv6 support.<br><br>  <a href="http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64540">http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64540</a><br>

<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Whereever possible I try to use conditional Hs-Source-Dirs in Cabal for selecting OS specific modules, but all of the directories must contain the same set of module names and modules with the same name must have the same interface.<br>


If modules have different APIs then I would give them different names and put them even in different packages. Then, say, presence of package poll-bsd means to the package user, that BSD functionality is available. Whether he is actually running BSD or whether the package simulates BSD functions doesn&#39;t matter.<br>

</blockquote><div><br>Another option is to move the CPP to Haskell, so that all the functions are the same and the capability check is dynamic. This isn&#39;t necessarily better, of course.<br><br>Regards,<br>Sean <br></div>

</div>