mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-31 20:21:51 -07:00
Simplify instance declarations
Many instance declarations can now be derived either by DerivingVia or GeneralizedNewtypeDeriving.
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, PatternGuards #-}
|
||||
{-# LANGUAGE DeriveFoldable #-}
|
||||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE PatternGuards #-}
|
||||
-----------------------------------------------------------------------------
|
||||
-- |
|
||||
-- Module : XMonad.Layout.Mosaic
|
||||
@@ -179,16 +183,7 @@ normalize :: Fractional a => [a] -> [a]
|
||||
normalize x = let s = sum x in map (/s) x
|
||||
|
||||
data Tree a = Branch (Tree a) (Tree a) | Leaf a | Empty
|
||||
|
||||
instance Foldable Tree where
|
||||
foldMap _f Empty = mempty
|
||||
foldMap f (Leaf x) = f x
|
||||
foldMap f (Branch l r) = foldMap f l `mappend` foldMap f r
|
||||
|
||||
instance Functor Tree where
|
||||
fmap f (Leaf x) = Leaf $ f x
|
||||
fmap f (Branch l r) = Branch (fmap f l) (fmap f r)
|
||||
fmap _ Empty = Empty
|
||||
deriving (Functor, Show, Foldable)
|
||||
|
||||
instance Semigroup (Tree a) where
|
||||
Empty <> x = x
|
||||
|
Reference in New Issue
Block a user