I have the following for an HTML font tag:
data Color = HexColor Int | RGBColor Int Int Int | ColorString String deriving Show
data FontAttribute = Size Int | Face String | FontColor Color deriving Show
data Font = Font [FontAttribute] deriving Show
I construct one like so:
Font [Size 23,Face "Arial",Color (RGBColor 240 23 43)]
My concern is that the FontColor
data/value constructor which has type FontAttribute requires a Color type as an argument. This means that Color is a generic type attribute for any kind of tag, and a specific tag has a specific subset of attributes (in this case Font has FontAttribute, which can be Size, Face or FontColor). Is there a clearer way to express this, or is my implementation sound?
Font
s described by any number and combination orFontAttribute
s?Font [Face "Arial", Face "Impact"]
doesn't seem terribly useful... – user395760FontColor Color
data generator, is there a clearer way to express that a FontColor is a Color as well as a FontAttribute. I'm not sure. – Aram Kocharyan