From 77c1821ed6e70668f02e0f5f28e11262209d0ded Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Mon, 9 Nov 2020 16:24:54 +0000 Subject: [PATCH] X.L.LayoutModifier: (wip) Add class InspectLayoutModifier --- XMonad/Layout/LayoutModifier.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/XMonad/Layout/LayoutModifier.hs b/XMonad/Layout/LayoutModifier.hs index a0157801f9..874509479e 100644 --- a/XMonad/Layout/LayoutModifier.hs +++ b/XMonad/Layout/LayoutModifier.hs @@ -1,4 +1,5 @@ {-# LANGUAGE DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses, PatternGuards #-} +{-# LANGUAGE ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- | @@ -26,10 +27,15 @@ module XMonad.Layout.LayoutModifier ( -- $usage -- * The 'LayoutModifier' class - LayoutModifier(..), ModifiedLayout(..) + LayoutModifier(..), ModifiedLayout(..), + + -- * The 'InspectLayoutModifier' class + InspectLayoutModifier(..) ) where import Control.Monad +import Data.Maybe ( fromMaybe ) +import Data.Typeable ( cast ) import XMonad import XMonad.StackSet ( Stack, Workspace (..) ) @@ -278,3 +284,11 @@ data ModifiedLayout m l a = ModifiedLayout (m a) (l a) deriving ( Read, Show ) -- the above does not parenthesize (m a) and (l a), which is obviously -- incorrect. +-- | TODO +class InspectLayoutModifier l a where + inspectModifier :: (LayoutModifier m a, Typeable m) => l a -> Maybe (m a) + +-- | TODO +instance (InspectLayoutModifier l a, Typeable m, Typeable a) + => InspectLayoutModifier (ModifiedLayout m l) a where + inspectModifier (ModifiedLayout m l) = fromMaybe (inspectModifier l) (cast m)