aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Util
diff options
context:
space:
mode:
authorAdam Vogt <vogt.adam@gmail.com>2009-12-08 02:05:06 +0100
committerAdam Vogt <vogt.adam@gmail.com>2009-12-08 02:05:06 +0100
commit46993804cde7b3766fdc214144600310937a834c (patch)
tree9ef25f615a7fd0d693409f6426d17db6dde7500c /XMonad/Util
parent1beaad7b2eaf40dbde3174a0ac9d3e891482c57f (diff)
downloadXMonadContrib-46993804cde7b3766fdc214144600310937a834c.tar.gz
XMonadContrib-46993804cde7b3766fdc214144600310937a834c.tar.xz
XMonadContrib-46993804cde7b3766fdc214144600310937a834c.zip
Golf / style change in U.ExtensibleState
Ignore-this: c35bd85baae4700e14417ac7e07de959 darcs-hash:20091208010506-1499c-555a4c881b1f83658460c18a6745eeb94205fe6e.gz
Diffstat (limited to 'XMonad/Util')
-rw-r--r--XMonad/Util/ExtensibleState.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/XMonad/Util/ExtensibleState.hs b/XMonad/Util/ExtensibleState.hs
index 0ac05d6..331dd4b 100644
--- a/XMonad/Util/ExtensibleState.hs
+++ b/XMonad/Util/ExtensibleState.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE PatternGuards #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Util.ExtensibleState
@@ -26,6 +27,7 @@ import Data.Typeable (typeOf,Typeable,cast)
import qualified Data.Map as M
import XMonad.Core
import qualified Control.Monad.State as State
+import Data.Maybe (fromMaybe)
-- ---------------------------------------------------------------------
-- $usage
@@ -96,13 +98,10 @@ get = getState' undefined -- `trick' to avoid needing -XScopedTypeVariables
case v of
Just (Right (StateExtension val)) -> return $ toValue val
Just (Right (PersistentExtension val)) -> return $ toValue val
- Just (Left str) -> case extensionType (undefined `asTypeOf` k) of
- PersistentExtension x -> do
- let val = maybe initialValue id $
- cast =<< safeRead str `asTypeOf` (Just x)
- put (val `asTypeOf` k)
- return val
- _ -> return $ initialValue
+ Just (Left str) | PersistentExtension x <- extensionType k -> do
+ let val = fromMaybe initialValue $ cast =<< safeRead str `asTypeOf` Just x
+ put (val `asTypeOf` k)
+ return val
_ -> return $ initialValue
safeRead str = case reads str of
[(x,"")] -> Just x