summaryrefslogtreecommitdiffstats
path: root/Wm.hs
diff options
context:
space:
mode:
authorDon Stewart <dons@cse.unsw.edu.au>2007-03-07 04:33:07 +0100
committerDon Stewart <dons@cse.unsw.edu.au>2007-03-07 04:33:07 +0100
commit698697cfa3185b0d7e1be28101b67a6850587eb7 (patch)
tree57acc8c643e155fc9d36e409c3723912308b2141 /Wm.hs
parent225d634ab3c92dcf39bdc4576cecd936a8fad970 (diff)
downloadmetatile-698697cfa3185b0d7e1be28101b67a6850587eb7.tar
metatile-698697cfa3185b0d7e1be28101b67a6850587eb7.zip
Wm -> W, all good monads have single capital letter names. comment the W.hs file
darcs-hash:20070307033307-9c5c1-2e7136f75725d311a8d19838b46e7fa89c3e4dc9
Diffstat (limited to 'Wm.hs')
-rw-r--r--Wm.hs70
1 files changed, 0 insertions, 70 deletions
diff --git a/Wm.hs b/Wm.hs
deleted file mode 100644
index 6b30ac1..0000000
--- a/Wm.hs
+++ /dev/null
@@ -1,70 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module : Wm.hs
--- Copyright : (c) Spencer Janssen 2007
--- License : BSD3-style (see LICENSE)
---
--- Maintainer : sjanssen@cse.unl.edu
--- Stability : unstable
--- Portability : not portable, uses cunning newtype deriving
---
------------------------------------------------------------------------------
---
--- The Wm monad, a state monad transformer over IO, for the window manager state.
---
-
-module Wm where
-
-import Data.Sequence
-import Control.Monad.State
-import System.IO (hFlush, hPutStrLn, stderr)
-import Graphics.X11.Xlib
-
-data WmState = WmState
- { display :: Display
- , screenWidth :: !Int
- , screenHeight :: !Int
- , windows :: Seq Window
- }
-
-newtype Wm a = Wm (StateT WmState IO a)
- deriving (Monad, MonadIO{-, MonadState WmState-})
-
-runWm :: Wm a -> WmState -> IO (a, WmState)
-runWm (Wm m) = runStateT m
-
---
--- | Lift an IO action into the Wm monad
---
-io :: IO a -> Wm a
-io = liftIO
-
---
--- | Lift an IO action into the Wm monad, discarding any result
---
-io_ :: IO a -> Wm ()
-io_ f = liftIO f >> return ()
-
-trace msg = io $ do
- hPutStrLn stderr msg
- hFlush stderr
-
-withIO :: (forall b. (a -> IO b) -> IO b) -> (a -> Wm c) -> Wm c
-withIO f g = do
- s <- Wm get
- (y, s') <- io $ f $ \x -> runWm (g x) s
- Wm (put s')
- return y
-
-getDisplay = Wm (gets display)
-
-getWindows = Wm (gets windows)
-
-getScreenWidth = Wm (gets screenWidth)
-
-getScreenHeight = Wm (gets screenHeight)
-
-setWindows x = Wm (modify (\s -> s {windows = x}))
-
-modifyWindows :: (Seq Window -> Seq Window) -> Wm ()
-modifyWindows f = Wm (modify (\s -> s {windows = f (windows s)}))