10
既定の型インスタンスを相互に定義する方法はありますか?私はこの作業のようなものを取得しようとしている:お互いを参照する既定の型インスタンス
{-# LANGUAGE DataKinds, KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
data Tag = A | B | C
class Foo (a :: *) where
type Bar a (b :: Tag)
type Bar a A =()
type Bar a B = Bar a A
type Bar a C = Bar a A
instance Foo Int where
type Bar Int A = Bool
test :: Bar Int B
test = True
をしかし、これは動作しません。これはどちらか動作しないことを
Couldn't match type `Bar Int 'B' with `Bool'
In the expression: True
In an equation for `test': test = True
注:
test :: Bar Int B
test =()