[Xmonad] fixing warnings with stricter type?

David Roundy droundy at darcs.net
Wed May 23 15:56:33 EDT 2007


Maybe we should replace

data Stack a = Empty
             | Node { focus  :: !a        -- focused thing in this set
                    , left   :: [a]       -- clowns to the left
                    , right  :: [a] }     -- jokers to the right
    deriving (Show, Read, Eq)

with something like:

type Stack a = Maybe (NonEmptyStack a)
data NonEmptyStack a = Node { focus  :: !a        -- focused thing in this set
                            , left   :: [a]       -- clowns to the left
                            , right  :: [a] }     -- jokers to the right

Then (modify Empty f) could just be (fmap f), and (modify d f) becomes
(Just . maybe d . fmap f), which seems cleaner to me.  This also allows
nice use of pattern matching in the Maybe monad.

I like Maybe.
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Xmonad mailing list