Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Typeable constraint to a few LayoutClass instances #398

Merged
merged 1 commit into from
Nov 9, 2020

Conversation

liskin
Copy link
Member

@liskin liskin commented Nov 4, 2020

Description

This enables adding the Typeable constraint to LayoutClass itself
(xmonad/xmonad#242)
which in turn enables querying the current layout state. That might be
useful to e.g. show the current X.L.WorkspaceDir in xmobar.

Example usage: liskin/dotfiles@6ea6c52

Checklist

  • I've read CONTRIBUTING.md

  • I tested my changes with xmonad-testing

  • I updated the CHANGES.md file

  • I updated the XMonad.Doc.Extending file (if appropriate)

before merging, I need to finish the above checklist tasks, but I'd like to gather feedback first

@byorgey
Copy link
Member

byorgey commented Nov 7, 2020

Seems reasonable to me.

@liskin liskin force-pushed the layoutclass-typeable branch 2 times, most recently from 7b69cc9 to 0c3dc7f Compare November 9, 2020 10:37
@liskin
Copy link
Member Author

liskin commented Nov 9, 2020

I thought some more about this and decided that it's best if we merge this as is. This PR doesn't really change or enable anything, so it doesn't make sense to add documentation and changelog entry for it.

I changed the commit message to say:

This is a preparation commit that fixes the compile failures that would result in merging that change to xmonad. For this to be generally useful we first need to merge (and ideally also release) that xmonad change,
and then we'll need some documentation and perhaps a type class to help find the right LayoutModifier in the tree of ModifiedLayouts and Choices. That will come later.

So that's my plan now. Get these two preparatory changes merged and released in the right order, and then add a InspectLayoutModifier class, something along these lines:

class InspectLayoutModifier l a where
    inspectModifier :: (LayoutModifier m a, Typeable m) => l a -> Maybe (m a)

instance (LayoutClass l a, LayoutModifier m a, Typeable m, Typeable a) => InspectLayoutModifier (ModifiedLayout m l) a where
    inspectModifier l = case cast l of
        Just (ModifiedLayout m (_ :: l a)) -> Just m
        Nothing -> Nothing

If you still find my plan reasonable, I think this is now ready to be merged and xmonad/xmonad#242 can then be merged as well.

@byorgey
Copy link
Member

byorgey commented Nov 9, 2020

I think it's still worth a brief note in the CHANGELOG, since in theory anyone using these instances may have things break if they don't already have a Typeable constraint.

@byorgey
Copy link
Member

byorgey commented Nov 9, 2020

However, overall I think the plan sounds reasonable.

This enables adding the Typeable constraint to LayoutClass itself
(xmonad/xmonad#242) which in turn enables
querying the current layout state. That might be useful to e.g. show the
current X.L.WorkspaceDir in xmobar.

This is a preparation commit that fixes the compile failures that would
result in merging that change to xmonad. For this to be generally useful
we first need to merge (and ideally also release) that xmonad change,
and then we'll need some documentation and perhaps a type class to help
find the right LayoutModifier in the tree of ModifiedLayouts and
Choices. That will come later.
@liskin liskin force-pushed the layoutclass-typeable branch from 0c3dc7f to b989655 Compare November 9, 2020 16:37
@liskin
Copy link
Member Author

liskin commented Nov 9, 2020

You've got a point. :-)

Here:

   * Several `LayoutClass` instances now have an additional `Typeable`
    constraint which may break some advanced configs. The upside is that we
    can now add `Typeable` to `LayoutClass` in `XMonad.Core` and make it
    possible to introspect the current layout and its modifiers.

force-pushed.

@byorgey byorgey merged commit e042bcc into xmonad:master Nov 9, 2020
@liskin liskin deleted the layoutclass-typeable branch November 9, 2020 20:56
@liskin liskin mentioned this pull request Nov 18, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants