Retrieve number of screens.

How do you retrieve the number of screens currently being used. I have tried: screenCount :: Int screenCount = do wsx <- gets windowset return (length (W.screens wsx)) however it gives an error: xmonad.hs:60:4: Couldn't match expected type `Int' against inferred type `m b' In a stmt of a 'do' expression: wsx <- gets windowset In the expression: do wsx <- gets windowset return (length (W.screens wsx)) In the definition of `screenCount': screenCount = do wsx <- gets windowset return (length (W.screens wsx)) I used XMonad.Actions.CycleWS's screenBy as a guide: screenBy :: Int -> X (ScreenId) screenBy d = do ws <- gets windowset --let ss = sortBy screen (screens ws) let now = screen (current ws) return $ (now + fromIntegral d) `mod` fromIntegral (length (screens ws)) Regards, Mike

On Nov 27, 2009, at 19:20 , Mike Sampson wrote:
How do you retrieve the number of screens currently being used. I have tried:
screenCount :: Int
The type has to be in the X monad; try declaring it as X Int. (More specifically, the error message is telling you that you used a do expression, which produces a result in some monad ("m b"), but you declared the type as Int.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

XMonad.Layout.IndependentScreens exports the countScreens value for this purpose. Cheers, ~d

Thanks
The type has to be in the X monad; try declaring it as X Int. (More specifically, the error message is telling you that you used a do expression, which produces a result in some monad ("m b"), but you declared the type as Int.)
XMonad.Layout.IndependentScreens exports the countScreens value for this purpose.
Both replies were very helpful. Regards, Mike
participants (3)
-
Brandon S. Allbery KF8NH
-
Mike Sampson
-
wagnerdm@seas.upenn.edu