3

hmatrixパッケージには、次の型ファミリ コードが含まれています。

type family BoundsOf x

type instance BoundsOf (a->a) = Int
type instance BoundsOf (a->a->a) = (Int,Int)

GHC 7.6 では、これは正常にコンパイルされます。

GHC 7.7 (7.8 につながる) では、次のようになります。

lib/Numeric/ContainerBoot.hs:515:15:
    Conflicting family instance declarations:
      BoundsOf (a -> a) -- Defined at lib/Numeric/ContainerBoot.hs:515:15
      BoundsOf (a -> a -> a)
        -- Defined at lib/Numeric/ContainerBoot.hs:516:15

ここでいう「対立」とはどのようなものでしょうか。これらのインスタンスの問題はわかりません。


更新:これは最小限の例Test.hsです:

{-# LANGUAGE TypeFamilies #-}
module Test where

type family BoundsOf x

type instance BoundsOf (a->a) = Int
type instance BoundsOf (a->a->a) = (Int,Int)

それを試す:

ghci Test.hs       # 7.6, all fine
ghci-7.7 Test.hs   # fails
4

2 に答える 2

1

Akio Takano は、GHC 7.6で型族宣言の使用を強制Intするプログラム例を構築することに成功しました。IO String

type family F a
type instance F (a -> a) = Int
type instance F (a -> a -> a) = IO String

http://ghc.haskell.org/trac/ghc/ticket/8162またはhttps://github.com/takano-akio/type-family-overlapを参照してください。

于 2013-08-23T14:32:54.347 に答える