Permalink
Browse files

Merge pull request #6 from singpolyma/master

Instances for Maybe and Bool
  • Loading branch information...
2 parents fe9316e + 8c84581 commit db7778e0fba6edc25c8edfd3acc24c01b7d0f435 @bos committed Nov 20, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 Data/Text/Buildable.hs
View
10 Data/Text/Buildable.hs
@@ -16,6 +16,7 @@ module Data.Text.Buildable
Buildable(..)
) where
+import Data.Monoid (mempty)
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Ratio (Ratio, denominator, numerator)
import Data.Text.Format.Functions ((<>))
@@ -139,6 +140,11 @@ instance (Show a) => Buildable (Shown a) where
build = fromString . show . shown
{-# INLINE build #-}
+instance (Buildable a) => Buildable (Maybe a) where
+ build Nothing = mempty
+ build (Just v) = build v
+ {-# INLINE build #-}
+
instance Buildable TimeOfDay where
build = build . Shown
{-# INLINE build #-}
@@ -163,3 +169,7 @@ instance Buildable WordPtr where
instance Buildable (Ptr a) where
build = build . ptrToWordPtr
+
+instance Buildable Bool where
+ build True = fromText "True"
+ build False = fromText "False"

0 comments on commit db7778e

Please sign in to comment.