diff options
author | Daniel Schoepe <daniel.schoepe@gmail.com> | 2009-11-07 11:38:32 +0100 |
---|---|---|
committer | Daniel Schoepe <daniel.schoepe@gmail.com> | 2009-11-07 11:38:32 +0100 |
commit | 9dc3d316e89770ddb9cf620ba95b2db8a8997aba (patch) | |
tree | 3a3807bb8137d7cd8dafd345f07a369c839a8e5f /XMonad | |
parent | 0baf18c83a50c016620a2a3ce845e04499672f71 (diff) | |
download | XMonadContrib-9dc3d316e89770ddb9cf620ba95b2db8a8997aba.tar.gz XMonadContrib-9dc3d316e89770ddb9cf620ba95b2db8a8997aba.tar.xz XMonadContrib-9dc3d316e89770ddb9cf620ba95b2db8a8997aba.zip |
Store deserialized data after reading in X.U.ExtensibleState
Ignore-this: 192beca56e9437292bd3f16451ae9e66
darcs-hash:20091107103832-7f603-c018a51111ff17ac621a531d17d616b895c2e2b2.gz
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Util/ExtensibleState.hs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/XMonad/Util/ExtensibleState.hs b/XMonad/Util/ExtensibleState.hs index caae704..43da23b 100644 --- a/XMonad/Util/ExtensibleState.hs +++ b/XMonad/Util/ExtensibleState.hs @@ -92,14 +92,17 @@ getState = getState' undefined -- `trick' to avoid needing -XScopedTypeVariables getState' :: ExtensionClass a => a -> X a getState' k = do v <- gets $ M.lookup (show . typeOf $ k) . extensibleState - return $ case v of - Just (Right (StateExtension val)) -> toValue val - Just (Right (PersistentExtension val)) -> toValue val - Just (Left str) -> case extensionType (undefined `asTypeOf` k) of - PersistentExtension x -> maybe initialValue id $ - cast =<< safeRead str `asTypeOf` (Just x) - _ -> initialValue - _ -> initialValue + 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) + putState (val `asTypeOf` k) + return val + _ -> return $ initialValue + _ -> return $ initialValue safeRead str = case reads str of [(x,"")] -> Just x _ -> Nothing |