[Haskell-beginners] Defining ExtensionClass (Maybe a) instance in xmonad.

Thomas Bach thbach at students.uni-mainz.de
Tue Jan 20 22:17:49 UTC 2015


sadly, I don't have an answer to all your technical
question. Furthermore, I consider myself to be a Haskell starter so I
cannot answer your questions concerning idiomatic code properly. But
here is an answer anyway. :)

Dmitriy Matrosov <sgf.dma at gmail.com> writes:

>  On 2015年01月19日 17:55, Brandon Allbery wrote:
> […]
> I want to define generic way for restarting something,
> spawned by xmonad.
> […]
> I may define a data type containing required start/stop
> functions and depending on some identifier (ProcessID
> actually):

I had kind of the same problem and went for the this option,
i.e. defining a data type. But I implemented this via a pid file which gets
saved on xmonad start up. This way these program can even survive a
restart of the XServer properly.

(see Config.hs in the same repo for an example of how I use them.)

However, I don't see the point in defining the data type to contain
start/stop functions. These will be the same for most of the
programs, won't they?

> […]
> or i can define interface, which all identifiers should
> support:

This makes sense if you want to prepare to have a whole group of
different instances. We cannot know whether or not this is your case. If
you want to be prepared for this – i.e. over-engineer the whole thing –
I'd probably go this path.

Define a class which asks its instances to have a start/stop function
and so on. Then you can define an instance which xmobar and probably a
whole lot of other programs will nicely fit.

Hope this helps


More information about the Beginners mailing list