[xmonad] darcs patches: Support for extensible state in contrib modules

Don Stewart dons at galois.com
Mon Oct 26 18:50:38 EDT 2009

> On Mon, Oct 26, 2009 at 11:09:20AM -0700, Don Stewart wrote:
> > This has been a long time coming.
> > I think we first discussed this in April 2007.
> > 
> > Can you characterize what changes to the core (if any) were required to
> > support this?
> I added a `M.Map String StateExtension' field to XState to hold the
> state, where StateExtension is an existential data type which can hold
> values that are members of a type class. The string representation of
> the value's type is used as the key in the map. This can create
> problems when multiple modules store a common data type such as an
> Int. To prevent this I added instructions to create a separate data
> type for that. This should not create name conflicts as long as one
> automatically derives Typeable.

Ok. This same approach is used in Yi. It called it the "dynamic symbol
table" approach in the Yi paper, iirc. It's a fine approach in a
statically typed language.

> Another thing I had to add was a list of type witnesses in XConf that
> is used to make values persistent between restarts when the type is an
> instance of Read. Currently this has to be explicitly specified when
> one makes a data type an instance of the type class since I didn't
> find a way to distinguish between Readable and non-Readable values
> automatically(not even with IncoherentInstances).  I'd appreciate any
> suggestions on this issue though.
> Finally, I made some modifications to the restart process to make
> values persistent.
> The actual interface for using this feature is done in a contrib
> module, since it does not really belong in core.

> This whole thing could have been implemented by (ab)using the
> layoutHook thus not needing any core changes, but this would be
> somewhat crude and since the additions to core are only about ~50
> lines, including comments, I think this is the better way to realize
> this.


More information about the xmonad mailing list