Skip to content

Commit

Permalink
added Monoid instance for Css
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyday567 committed Mar 6, 2015
1 parent e2e86aa commit e101a66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Clay/Stylesheet.hs
@@ -1,4 +1,6 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
module Clay.Stylesheet where

import Control.Applicative
Expand Down Expand Up @@ -61,6 +63,10 @@ rule a = S (tell [a])

type Css = StyleM ()

instance Monoid Css where
mempty = pure ()
mappend = liftA2 mappend

-- | Add a new style property to the stylesheet with the specified `Key` and
-- value. The value can be any type that is in the `Val' typeclass, with other
-- words: can be converted to a `Value`.
Expand Down
3 changes: 2 additions & 1 deletion src/Test.hs
Expand Up @@ -6,8 +6,9 @@ import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit.Base ((@?=))

import Clay.Render (renderWith, compact)
import Data.Monoid

main :: IO ()
main = defaultMain
[ testCase "empty Clay produces empty compact CSS" $ renderWith compact [] (return ()) @?= ""
[ testCase "mempty produces empty compact CSS" $ renderWith compact [] mempty @?= ""
]

0 comments on commit e101a66

Please sign in to comment.