
Hi,
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
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. https://github.com/fuzzy-id/my-xmonad/blob/master/My/PidProg.hs (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 Thomas.