xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
589 stars 274 forks source link

xmonad-contrib part of "Make extensibleState primarily keyed by TypeRep instead of type names" #600

Open liskin opened 3 years ago

liskin commented 3 years ago

Description

We've been using the String we get out of show . typeOf as key in extensibleState, but that has a somewhat serious bug: it shows unqualified type names, so if two modules use the same type name, their extensible states will be stored in one place and get overwritten all the time.

To fix this, the extensibleState map is now primarily keyed by the TypeRep themselves, with fallback to String for not yet deserialized data. XMonad.Core now exports showExtType which serializes type names qualified, and this is used in writeStateToFile.

A simpler fix would be to just change the serialization of type names in XMonad.Util.ExtensibleState, but I'm afraid that might slows things down: Most types used here will start with "XMonad.", and that's a lot of useless linked-list pointer jumping.

Fixes: https://github.com/xmonad/xmonad-contrib/issues/94 Related: https://github.com/xmonad/xmonad/pull/326


I must admit I don't really like the code, especially the xmonad-contrib part. There's the assumption that a Right key maps to a Right value, and Left key to Left value, but enforcing that in the types probably means adding a another field to the XState.

Checklist