mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Use newtype deriving for Invisible
This commit is contained in:
parent
39c272d85f
commit
59e4cc28f7
12
Invisible.hs
12
Invisible.hs
@ -1,3 +1,5 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- |
|
||||
-- Module : XMonadContrib.Invisible
|
||||
@ -23,7 +25,7 @@ module XMonadContrib.Invisible (
|
||||
-- $usage
|
||||
-- A data type to store the layout state
|
||||
|
||||
data Invisible m a = I (m a)
|
||||
newtype Invisible m a = I (m a) deriving (Monad, Functor)
|
||||
|
||||
instance (Functor m, Monad m) => Read (Invisible m a) where
|
||||
readsPrec _ s = [(fail "Read Invisible", s)]
|
||||
@ -31,14 +33,6 @@ instance (Functor m, Monad m) => Read (Invisible m a) where
|
||||
instance Monad m => Show (Invisible m a) where
|
||||
show _ = ""
|
||||
|
||||
instance (Functor m, Monad m) => Monad (Invisible m) where
|
||||
return a = I (return a)
|
||||
m >>= f = m >>= f
|
||||
fail s = I (fail s)
|
||||
|
||||
instance (Functor m, Monad m) => Functor (Invisible m) where
|
||||
fmap f (I x) = I (fmap f x)
|
||||
|
||||
whenIJust :: (Monad m) => Invisible Maybe a -> (a -> m ()) -> m ()
|
||||
whenIJust (I (Just x)) f = f x
|
||||
whenIJust (I Nothing) _ = return ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user