[haskell-llvm] [Haskell-cafe] LLVM, type-level?
Henning Thielemann
lemming at henning-thielemann.de
Wed Dec 8 11:19:40 EST 2010
On Wed, 8 Dec 2010, Lally Singh wrote:
> On Tue, Dec 7, 2010 at 1:31 PM, Henning Thielemann
> <lemming at henning-thielemann.de> wrote:
>>
>> On Tue, 7 Dec 2010, Lally Singh wrote:
>>
>>> Hey all,
>>>
>>> I'm generating a structure definition from input, and would like to
>>> generate some LLVM code that can use it. I see an 'alloca' function
>>> in LLVM.Core that may do the trick, but takes a static type (Ptr a),
>>> which I wouldn't have. Is there a dynamic variant? I'm currently
>>> generating a TypeDesc Struct type.
>>
>> How much flexibility do you need? Is the user really allowed to specify an
>> arbitrary 'struct' declaration? This could be a security hole.
>> If you really want it, I think you would have to use existential
>> quantification in order to construct a user defined type at runtime.
>
> Could you elaborate on this a bit more? Or is there an example
> somewhere I could look at?
Converting a value to a type is possible with the (continuation
passing) trick you have already seen in withString. You can look into
reifyIntegral in order to get an idea:
http://hackage.haskell.org/packages/archive/type-level/0.2.4/doc/html/src/Data-TypeLevel-Num-Sets.html#reifyIntegral
(It even does not require existentially quantified data constructors, but
uses functions with all quantification directly.)
More information about the Haskell-llvm
mailing list