module Data.Niagra.Value
(
Value(..),
inherit,
initial,
none,
v
)
where
import Data.Monoid
import Data.Niagra.Builder
class Value a where
build :: a -> Builder
instance Value String where
build = fromString
instance Value Builder where
build = id
instance Value [Builder] where
build = f mempty True
where
f a _ [] = a
f a True (x:xs) = f x False xs
f a False (x:xs) = f (a <> sp <> x) False xs
instance Value (Builder, Builder) where
build (a,b) = a <> sp <> b
instance Value (Builder, Builder, Builder) where
build (a,b,c) = a <> sp <> b <> sp <> c
instance Value (Builder, Builder, Builder, Builder) where
build (a,b,c,d) = a <> sp <> b <> sp <> c <> sp <> d
instance Value (Builder, Builder, Builder, Builder, Builder) where
build (a,b,c,d,e) = a <> sp <> b <> sp <> c <> sp <> d <> sp <> e
instance Value (Builder, Builder, Builder, Builder, Builder, Builder) where
build (a,b,c,d,e,f) = a <> sp <> b <> sp <> c <> sp <> d <> sp <> e <> sp <> f
instance Value (Builder, Builder, Builder, Builder, Builder, Builder, Builder) where
build (a,b,c,d,e,f,g) = a <> sp <> b <> sp <> c <> sp <> d <> sp <> e <> sp <> f <> sp <> g
instance Value (Builder, Builder, Builder, Builder, Builder, Builder, Builder, Builder) where
build (a,b,c,d,e,f,g,h) = a <> sp <> b <> sp <> c <> sp <> d <> sp <> e <> sp <> f <> sp <> g <> sp <> h
inherit :: Builder
inherit = "inherit"
initial :: Builder
initial = "initial"
none :: Builder
none = "none"
v :: String -> Builder
v = fromString
sp :: Builder
sp = singleton ' '