From e85b0920a06ad019754e1cb8e72eb6cc34cdeedc Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Thu, 12 Jul 2007 19:50:34 +0200 Subject: use of existential types for plugin support This patch, which *changes the configuration format*, adds easy plugin support by using an existential type for storing the list of commands to be executed. Adding a plugin is just a matter of writing the appropriate instance of the Exec class, after importing Commands.hs. I must thank Claus Reinke for the help in understanding the mysteries of reading existential types. The Read instance of Runnable must be credited to him. See here: http://www.haskell.org/pipermail/haskell-cafe/2007-July/028227.html darcs-hash:20070712175034-d6583-f10174bb3b0a9b4f6e08d05052c18f30e539b319.gz --- Config.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Config.hs') diff --git a/Config.hs b/Config.hs index 1ab01c9..b2aae29 100644 --- a/Config.hs +++ b/Config.hs @@ -16,9 +16,12 @@ module Config ( -- * Configuration -- $config Config (..) , defaultConfig + , runnableTypes ) where import Commands +import {-# SOURCE #-} Runnable + -- $config -- Configuration data type and default configuration @@ -33,7 +36,7 @@ data Config = , height :: Int -- ^ Window height , align :: String -- ^ text alignment , refresh :: Int -- ^ Refresh rate in tenth of seconds - , commands :: [(Command,Int)] -- ^ For setting the command, the command argujments + , commands :: [Runnable] -- ^ For setting the command, the command argujments -- and refresh rate for the programs to run (optional) , sepChar :: String -- ^ The character to be used for indicating -- commands in the output template (default '%') @@ -52,7 +55,10 @@ defaultConfig = , height = 15 , align = "left" , refresh = 10 - , commands = [(Memory [],10)] + , commands = [Run $ Memory [] 10] , sepChar = "%" , template = "Uptime: %uptime% ** %date% %memory%" } + +runnableTypes :: (Command,()) +runnableTypes = undefined :: (Command,()) -- cgit v1.2.3