क्या एक दूसरे के संदर्भ में परिभाषित डिफ़ॉल्ट प्रकार के उदाहरण हैं? मैं इस काम के तरह कुछ पाने के लिए कोशिश कर रहा हूँ:डिफ़ॉल्ट प्रकार के उदाहरण एक दूसरे को संदर्भित करते हैं
{-# 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 =()