[Haskell-beginners] Simple Haskell daemon

Chaddaï Fouché chaddai.fouche at gmail.com
Tue Nov 16 14:37:52 EST 2010


On Tue, Nov 16, 2010 at 2:18 AM, Amy de Buitléir <amy at nualeargais.ie> wrote:
> I've written a very simple daemon, and it's working just fine. But I'd
> appreciate it if someone could take a look at it and tell me if any of the code
> I've written is... stupid. (I'm trying to get more comfortable with this monad
> stuff.) Thank you in advance.
>
> Daemon.hs
> ---------
> module Daemon where
>
> import System.Exit
> import System.IO.Unsafe
> import System.Posix.Signals
> import Control.Concurrent
>
> class DaemonState a where
>  initialise :: IO a
>  work :: a -> IO a
>  finalise :: a -> IO ()

To use a typeclass there is pretty strange and doesn't have much
advantage, it would be much easier and nicer to just write start to
take some functions as parameters (why would there be only one
instance for each type...). In other words it works but is only a
perversion of the idea of typeclass without any practical advantages.
On the other hand if you had some strange pedagogical requirements,
feel free to ignore this !

-- 
Jedaï


More information about the Beginners mailing list