Use newtype deriving for Invisible

This commit is contained in:
Spencer Janssen 2007-10-01 15:15:55 +00:00
parent 39c272d85f
commit 59e4cc28f7

View File

@ -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 ()