[Haskell-beginners] Defining ExtensionClass (Maybe a) instance in xmonad.
sgf.dma at gmail.com
Sun Jan 25 21:07:31 UTC 2015
On 2015年01月25日 21:09, Dmitriy Matrosov wrote:
> 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
> and i may define 'extensionType = PersistentExtension' in (Maybe a)
> 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
> with only that contraint. I can't express it by pattern-matching on type
> 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
> 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 .
More information about the Beginners