Czy istnieje sposób na domyślne zdefiniowanie instancji typu względem siebie? Próbuję coś jak to Działanie:Domyślne instancje typu odnoszące się do siebie
{-# 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
ale to nie działa:
Couldn't match type `Bar Int 'B' with `Bool'
In the expression: True
In an equation for `test': test = True
Należy pamiętać, że to nie działa albo:
test :: Bar Int B
test =()