
On Thu, 9 Apr 2009 11:42:44 +0200
Quentin Moser
instance Monoid (Query (Endo WindowSet)) where mempty = return $ Endo id mappend m1 m2 = do ws <- Query $ lift $ gets windowset ws' <- m1 >>= ($ ws) . appEndo ws'' <- m2 >>= ($ ws') . appEndo Query $ lift $ modify $ \s -> s {windowset = ws''} return $ Endo $ const ws''
My example is wrong. I think this version should be correct:
instance Monoid (Query (Endo WindowSet)) where mempty = return $ Endo id mappend m1 m2 = do endo1 <- m1 ws' <- appEndo endo1 <$> getWS setWS ws'
endo2 <- m1 ws'' <- appEndo endo1 <$> getWS setWS ws''
return $ Endo $ const ws''
The point is for the Query parts and Endo Windowset parts do be interleaved and manipulate the same windowset.