ghc 7.4.1 のllvm-3.0.0.0パッケージを介して llvm で構造体を作成し、その中の要素にアクセスしようとしていますが、いくつかの毛むくじゃらの型に遭遇しています。これがサンプル コードです。構造体の 2 番目の要素を取得しようとしています (つまり、Word32
TestStruct.
{-# LANGUAGE TypeOperators #-}
import LLVM.Core
import Data.Word
type TestStruct = Struct (Word16 :& Word32 :& Word64)
getTestPtr :: Value (Ptr TestStruct) -> CodeGenFunction r (Value (Ptr Word32))
getTestPtr u = getElementPtr u (0 :: Word32, (1 :: Word32, ()))
しかし、ghc 7.4.1 で次のエラーが発生します。
Test.hs:8:16:
Overlapping instances for llvm-3.0.0.0:LLVM.Core.Instructions.GetField
(Word32, Word64) i Word32
arising from a use of `getElementPtr'
Matching instances:
instance [overlap ok] (llvm-3.0.0.0:LLVM.Core.Instructions.GetField
as i b,
Succ i i') =>
llvm-3.0.0.0:LLVM.Core.Instructions.GetField (a, as) i' b
-- Defined in `llvm-3.0.0.0:LLVM.Core.Instructions'
instance [overlap ok] llvm-3.0.0.0:LLVM.Core.Instructions.GetField
(a, as) D0 a
-- Defined in `llvm-3.0.0.0:LLVM.Core.Instructions'
(The choice depends on the instantiation of `i'
To pick the first instance above, use -XIncoherentInstances
when compiling the other instance declarations)
In the expression: getElementPtr u (0 :: Word32, (0 :: Word32, ()))
In an equation for `getTestPtr':
getTestPtr u = getElementPtr u (0 :: Word32, (0 :: Word32, ()))
Test.hs:8:16:
No instances for (Data.TypeLevel.Num.Sets.PosI Word32,
Data.TypeLevel.Num.Ops.IsZero Word32 yz,
DivMod10 Word32 yi yl)
arising from a use of `getElementPtr'
Possible fix:
add instance declarations for
(Data.TypeLevel.Num.Sets.PosI Word32,
Data.TypeLevel.Num.Ops.IsZero Word32 yz,
DivMod10 Word32 yi yl)
In the expression: getElementPtr u (0 :: Word32, (0 :: Word32, ()))
In an equation for `getTestPtr':
getTestPtr u = getElementPtr u (0 :: Word32, (0 :: Word32, ()))