
On 2015年01月25日 21:09, Dmitriy Matrosov wrote:
Hi.
Sorry for big delay, rewriting my previous solution takes a lot of time.
On 2015年01月20日 23:14, Brandon Allbery wrote:
then there is no (Show a, Read a) constraint. It will come up only, when i mention PersistentExtension in one of case branches, but, on the other hand, may be i can avoid
That would be expected, I believe; if you mentioned it, it must apply to the whole instance, not just one case branch. But I'm not quite clear on what you are saying here.
I mean, that i already have contraint (ExtensionClass a) in e.g.
instance (ExtensionClass a) => ExtensionClass (Maybe a) where initialValue = Nothing
then if type a had Show and Read instances, then (Maybe a) will had them too and i may define 'extensionType = PersistentExtension' in (Maybe a) instance. If type a had no Show and Read instances, then i may only define (Maybe a) to be a StateExtension . Thus, theoretically, (ExtensionClass a) contraint is enough, and i want to express above condition on (Maybe a) extensionType value with only that contraint. I can't express it by pattern-matching on type a's StateExtension data contructor, because that will bring up (Show a, Read a) constraint on (Maybe a) instance. I.e. i, probably, can't do it with condition at data level. Then, may be, i can make a condition at type level somehow?
Hm, i think, i miss something here. There should be: if type a had Show and Read instances * and have 'extensionType = PersistentExtension' * , then (Maybe a) * may * had it too. If type a had no Show and Read instances, then i may only define (Maybe a) to be a StateExtension .