[haskell-llvm] Limitation of API - omissions or design?
Henning Thielemann
lemming at henning-thielemann.de
Wed Dec 15 23:51:55 EST 2010
Maciej Piechotka schrieb:
> I tried to use Haskell + LLVM binding to it to write university
> compilers assignment and I run into some problems with API:
>
> - Many functions are non-existing or not exported.
It's also a problem of LLVM that not all LLVM functions are exported by
the LLVM interface to C. Haskell can only call the C interface, not the
C++ one.
> For example it seems
> to be not possible to create array containing other things that 0 and -1
> other then String.
I have already successfully worked with arrays. Can you please show a
piece of code that does not do what it should?
> The constOf function is also not exported.
The constOf function is exported, but for some unknown reason Haddock
does not show it.
> - Higher API enforces type safety, which is good thing if one uses LLVM
> to DSL - however if LLVM is used as backend it causes problems as I
> don't know types at compile time and checking is part of other part of
> code.
You can use Rank2Types in order to construct Haskell types at runtime.
The technique is illustrated by converting a Haskell number to a Haskell
type level number:
http://hackage.haskell.org/packages/archive/type-level/0.2.4/doc/html/src/Data-TypeLevel-Num-Sets.html#reifyIntegral
> GADTs allows workaround problem but
> - Higher API cannot jump into lower API for a few instructions but uses
> all-or-nothing approach. Normally it would be good thing if not the
> previous problems.
Maybe if you show a specific problem we can turn Nothing to All. Note
that there is another Haskell LLVM interface that, as far as I know, is
not as strongly typed and is used for the GHC LLVM backend.
http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/Backends/LLVM
More information about the Haskell-llvm
mailing list