module Graphics.Curves.Attribute where
data Assignment a
= forall f b. HasAttribute f a => f b := b
| forall f b. HasAttribute f a => f b :~ (b -> b)
infix 0 :=, :~
class HasAttribute f a where
modifyAttribute :: f b -> (b -> b) -> a -> a
setAttribute :: f b -> b -> a -> a
setAttribute t x = modifyAttribute t (const x)
infixl 7 `with`
with :: a -> [Assignment a] -> a
with x as = foldl assign x as
where
assign :: a -> Assignment a -> a
assign a (t := x) = setAttribute t x a
assign a (t :~ f) = modifyAttribute t f a