I'd like to implement custom messages to be handled by a custom layout.
data ModifySideContainer = IncrementLeftColumnContainer | IncrementRightColumnContainer deriving Typeable
instance Message ModifySideContainer
I'm not too sure how to handle the custom message within pureMessage
(https://hackage.haskell.org/package/xmonad-0.13/docs/XMonad-Core.html#v:pureMessage)
This is my current pureMessage implementation (within the custom layout):
pureMessage l@(MiddleColumn sr mcc deltaInc _) m = msum [
fmap resize (fromMessage m),
fmap incmastern (fromMessage m)
]
where
resize Expand = l {splitRatio = (min 0.5 $ sr + deltaInc)}
resize Shrink = l {splitRatio = (max 0 $ sr - deltaInc)}
incmastern (IncMasterN x) = l { middleColumnCount = max 0 (mcc+x) }
I don't quite understand how this logic works (I've copied it from somewhere), what is msum
doing here? I guess I'll know once I find the instance declaration of mplus
for Maybe
.