[Haskell-cafe] HDF5 binding (was: why is ghci trying to load hsc file ??)

James Cook mokus at deepbondi.net
Mon Apr 4 16:46:02 CEST 2011


On Apr 3, 2011, at 10:43 PM, mauricio.antunes at gmail.com wrote:

>>>> I worked out a small hdf5 binding using cabal and bindings-DSL and
>>>> sqlite3 as my example.
>
>>> I just wanted to add that I also started an HDF5 binding recently
>>> (using hsc2hs only).  It does more than enough for me ATM, so I  
>>> don't
>>> develop it actively, but if you want to pursue this (and I think
>>> it would be a useful addition to Hackage), we may share experience
>>> and code.  My binding is part of a bigger project, but I meant to
>>> split it out anyway.
>
>> What an interesting coincidence, that makes at least three of
>> us. Apparently it's an idea whose time has come.  Mine is also an
>> incomplete low-level binding but is currently under semi-active
>> development and I aim to make it cover the entire hdf5.h interface.
>> If anyone is interested in it I've put it on github at:
>>
>> https://github.com/mokus0/bindings-hdf5
>>
>
> Bindings to the full hdf5 were supposed to be in the example set for
> bindings-DSL. It doesn't use pkg-config, though, and hdf5 developers
> didn't like the idea of adding support. I wanted reference bindings-*
> libraries to be free of linking problems some users might not be able
> to solve or understand, so I gave up.

That seems strange to me - pkg-config is such a useful system, and  
"support" for it is incredibly easy to add and practically zero- 
maintenance.   Was it that they didn't find it worth the programmer  
time to figure out how to add pkg-config support or did they have  
specific objections?  All it seems to take is to generate a file with  
about 10 lines of text and install it to the right place.

In any case, though, the fact that current versions doesn't support it  
means that a Haskell binding package has to work around that for  
several years to come, since most "stable" linux distros wouldn't pick  
up an updated version for quite some time.

Currently I've got a "template" hdf5.pc file in the source tree which  
can be customized and dropped into the appropriate directory.  It's a  
lot less manual than it ought to be, but it's at least a lot less ugly  
than hard-coding my development machine's include and lib paths.   
Eventually my plan is to use a cabal flag to control whether it looks  
for hdf5 as using "pkgconfig-depends" or just "extra-libs", with some  
Setup.hs logic to check whether the former will work and set the flag  
appropriately.

Incidentally, I've thought many times before that it sure would be  
great if cabal's backtracking search would consider more than just  
haskell package dependencies.  In this case, it would be really nice  
if it would backtrack on an unsatisfiable pkg-config dependency.  In  
the past I've come across cases where it would have been very helpful  
to support backtracking on "buildable: False".  Maybe I'll take a look  
one of these days at how hard that would be to change.  I suspect that  
to do so in a backward-compatible way would take a lot of work though,  
because of the way Cabal exposes its internal types to Setup.hs files.

-- James



More information about the Haskell-Cafe mailing list