darcs patch: Add a LayoutCombinator class and a CombinedLayout and ...

forget the previous stuff. also this one has some issues (doFirst must
be implemented!), but you can see the result:
instance LayoutCombinator PerWorkspace a where
chooser (PerWorkspace wsIds) = do
t <- getCurrentTag
return $ if t `elem` wsIds then DoFirst else DoSecond
doFirst (PerWorkspace _) = True
this is PerWorkspace!
cheers,
andrea
Tue Jan 29 20:29:03 CET 2008 Andrea Rossato

On Tue, Jan 29, 2008 at 08:41:28PM +0100, Andrea Rossato wrote:
Tue Jan 29 20:29:03 CET 2008 Andrea Rossato
* Add a LayoutCombinator class and a CombinedLayout and port PerWorkspace to the new system
just to let you know that this will be amended. I'm going to remove the necessity of implementing doFirst (it was needed just to decide which layout description to use)! andrea

On Jan 29, 2008 2:57 PM, Andrea Rossato
On Tue, Jan 29, 2008 at 08:41:28PM +0100, Andrea Rossato wrote:
Tue Jan 29 20:29:03 CET 2008 Andrea Rossato
* Add a LayoutCombinator class and a CombinedLayout and port PerWorkspace to the new system just to let you know that this will be amended. I'm going to remove the necessity of implementing doFirst (it was needed just to decide which layout description to use)!
Yes, this is a problem with PerWorkspace in particular -- the description method is pure, but the chooser method must be in the X monad to have access to the current stackset, in order to figure out which workspace is current. So in order to get the description method right, the decision of chooser must be cached as part of the data type so that description can show the description for the correct layout. This is what PerWorkspace used to do. This only means that PerWorkspace is not a particularly good example of the power of CombinedLayout, but in general I think CombinedLayout is great. There is another problem with PerWorkspace which I will detail in a later e-mail. To make a long story short, PerWorkspace is an awful, ugly hack, and I'm sorry now that I wrote it. =) I'd like to propose moving this functionality into the core, but in a later e-mail I will detail my arguments for this along with a patch and various proofs of safety. -Brent

On Tue, Jan 29, 2008 at 05:33:04PM -0500, Brent Yorgey wrote:
On Jan 29, 2008 2:57 PM, Andrea Rossato
wrote: On Tue, Jan 29, 2008 at 08:41:28PM +0100, Andrea Rossato wrote:
Tue Jan 29 20:29:03 CET 2008 Andrea Rossato
* Add a LayoutCombinator class and a CombinedLayout and port PerWorkspace to the new system just to let you know that this will be amended. I'm going to remove the necessity of implementing doFirst (it was needed just to decide which layout description to use)!
Yes, this is a problem with PerWorkspace in particular -- the description method is pure, but the chooser method must be in the X monad to have access to the current stackset, in order to figure out which workspace is current. So in order to get the description method right, the decision of chooser must be cached as part of the data type so that description can show the description for the correct layout. This is what PerWorkspace used to do.
I don't know about the second issue, but this is not a big one, I think: just provide your combineDescription method: combineDescription :: (LayoutClass l1 a, LayoutClass l2 a) => lc a -> l1 a -> l2 a -> String call the right "description l1" inside it and you should be done. Am I missing something? BTW, there shouldn't be awful layout combinators: if you cannot write a cmobinator with that class probably the bug is in the class...;) (and we can fix it!) Cheers, Andrea

On Tue, Jan 29, 2008 at 05:33:04PM -0500, Brent Yorgey wrote:
On Jan 29, 2008 2:57 PM, Andrea Rossato
wrote: On Tue, Jan 29, 2008 at 08:41:28PM +0100, Andrea Rossato wrote:
Tue Jan 29 20:29:03 CET 2008 Andrea Rossato
* Add a LayoutCombinator class and a CombinedLayout and port PerWorkspace to the new system just to let you know that this will be amended. I'm going to remove the necessity of implementing doFirst (it was needed just to decide which layout description to use)!
Yes, this is a problem with PerWorkspace in particular -- the description method is pure, but the chooser method must be in the X monad to have access to the current stackset, in order to figure out which workspace is current. So in order to get the description method right, the decision of chooser must be cached as part of the data type so that description can show the description for the correct layout. This is what PerWorkspace used to do.
sorry, my previous mail was probably sent too early (I'm tire after a day of type class hacking :)... yes, the fact that we need to implement the "chooser" inside the X monad is a bit ugly. Originally i though it as a pure method, and I changed it because I could not implement PerWorkspace, otherwise. If you can come up with a cleaner solution that would be graet. sorry for the noise.... i'm going to bed now. Andrea

On Tue, Jan 29, 2008 at 05:33:04PM -0500, Brent Yorgey wrote:
Yes, this is a problem with PerWorkspace in particular -- the description method is pure, but the chooser method must be in the X monad to have access to the current stackset, in order to figure out which workspace is current. So in order to get the description method right, the decision of chooser must be cached as part of the data type so that description can show the description for the correct layout. This is what PerWorkspace used to do.
just thinking aloud: a hack could be to use the "sendToSecond" method to intercept the message and change the chooser accordingly. ok. I'll shut up. Andrea

On Tue, Jan 29, 2008 at 05:33:04PM -0500, Brent Yorgey wrote:
On Jan 29, 2008 2:57 PM, Andrea Rossato
wrote: On Tue, Jan 29, 2008 at 08:41:28PM +0100, Andrea Rossato wrote:
Tue Jan 29 20:29:03 CET 2008 Andrea Rossato
* Add a LayoutCombinator class and a CombinedLayout and port PerWorkspace to the new system just to let you know that this will be amended. I'm going to remove the necessity of implementing doFirst (it was needed just to decide which layout description to use)!
Yes, this is a problem with PerWorkspace in particular -- the description method is pure, but the chooser method must be in the X monad to have access to the current stackset, in order to figure out which workspace is current. So in order to get the description method right, the decision of chooser must be cached as part of the data type so that description can show the description for the correct layout. This is what PerWorkspace used to do.
this is REALLY the last one. If you really want it I can give you a: chooseWithState :: lc a -> XState -> X ComboChooser ;) andrea
participants (2)
-
Andrea Rossato
-
Brent Yorgey