But this gives an errorSo I have (stripped down)The specific case is to be able to contain a SourceText, in the context of HsLitHi allI am experimenting with Trees that Grow [1] in the context of the GHC HsSyn AST, and wanting to express that a given extension point needs to have certain properties.
data GHCX
type family XHsString x
type instance XHsString GHCX = SourceText
class HasSourceText a where
-- Provide setters to mimic existing constructors
noSourceText :: a
sourceText :: String -> a
getSourceText :: a -> SourceText
instance HasSourceText (XHsString GHCX) where
noSourceText = NoSourceText
sourceText s = SourceText s
getSourceText a = a
compiler/hsSyn/HsExtension.hs:80:10: error:
• Illegal type synonym family application in instance:
XHsString GHCX
• In the instance declaration for ‘HasSourceText (XHsString GHCX)’Is there some way to achieve this, or is it simply impossible?The full work-in-progress source is here[2]RegardsAlan