Commit 0e60cc42 authored by Mart Lubbers's avatar Mart Lubbers Committed by Camil Staps

Make SVGICCColor and SVGLength newtypes to resolve overlapping instances

parent 4cbc1614
......@@ -351,8 +351,8 @@ from Data.GenEq import generic gEq
| FillOpacityInherit
:: SVGFillRule = FillNonzero | FillEvenodd | FillInherit
:: SVGFuncIRI = IRI String // url(<IRI>)
:: SVGICCColor :== (String,[SVGNumber]) // (<color-profile-name>,<color-values>), the <color-values> list must not be empty
:: SVGLength :== (SVGNumber,SVGLengthUnit)
:: SVGICCColor = SVGICCColor String [SVGNumber] // (<color-profile-name>,<color-values>), the <color-values> list must not be empty
:: SVGLength = SVGLength SVGNumber SVGLengthUnit
:: SVGLengthAdjust = Spacing | SpacingAndGlyphs
:: SVGLengthUnit = EM | EX | PX | IN | CM | MM | PT | PC | PERCENT
:: SVGLineCap = CapButt | CapRound | CapSquare | CapInherit
......@@ -415,7 +415,7 @@ instance toString SVGTransform
instance toString SVGZoomAndPan
derive gEq HtmlTag, HtmlAttr
derive gEq SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan
derive gEq SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan, SVGICCColor, SVGLength
/*
* This html class makes it possible to use either strings, or html as description/message/instruction
......
......@@ -737,10 +737,10 @@ instance toString SVGColor where
toString (SVGColorText name) = name
svgICCColorSize :: !SVGICCColor -> Int
svgICCColorSize (profile,values) = 12 + size profile + svgNumbersSize values
svgICCColorSize (SVGICCColor profile values) = 12 + size profile + svgNumbersSize values
instance toString SVGICCColor where
toString (profile,values) = "icc-color(" +++ profile +++ " " +++ glue_list " " (map toString values) +++ ")"
toString (SVGICCColor profile values) = concat ["icc-color(", profile, " ", glue_list " " (map toString values), ")"]
svgFillOpacitySize :: !SVGFillOpacity -> Int
svgFillOpacitySize (FillOpacity nr) = size nr // number
......@@ -765,10 +765,10 @@ instance toString SVGFuncIRI where
toString (IRI url) = "url(" +++ url +++ ")"
svgLengthSize :: !SVGLength -> Int
svgLengthSize (nr,unit) = size nr + svgLengthUnitSize unit
svgLengthSize (SVGLength nr unit) = size nr + svgLengthUnitSize unit
instance toString SVGLength where
toString (nr,unit) = toString nr +++ toString unit
toString (SVGLength nr unit) = toString nr +++ toString unit
svgLengthAdjustSize :: !SVGLengthAdjust -> Int
svgLengthAdjustSize Spacing = 7 // "spacing"
......@@ -1082,4 +1082,4 @@ escapeStr str
= str
derive gEq HtmlTag, HtmlAttr
derive gEq SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan
derive gEq SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan, SVGICCColor, SVGLength
......@@ -2,12 +2,12 @@ definition module Text.HTML.GenJSON
from Data.Maybe import :: Maybe
from Text.HTML import :: HtmlTag, :: HtmlAttr
from Text.HTML import :: SVGElt, :: SVGAttr, :: SVGAlign, :: SVGColor, :: SVGDefer, :: SVGFillOpacity, :: SVGFuncIRI, :: SVGLengthAdjust
from Text.HTML import :: SVGLengthUnit, :: SVGLineCap, :: SVGFillRule, :: SVGLineJoin, :: SVGMeetOrSlice, :: SVGStrokeMiterLimit, :: SVGPaint
from Text.HTML import :: SVGElt, :: SVGAttr, :: SVGAlign, :: SVGColor, :: SVGDefer, :: SVGFillOpacity, :: SVGFuncIRI, :: SVGLengthAdjust, :: SVGICCColor
from Text.HTML import :: SVGLengthUnit, :: SVGLineCap, :: SVGFillRule, :: SVGLineJoin, :: SVGMeetOrSlice, :: SVGStrokeMiterLimit, :: SVGPaint, :: SVGLength
from Text.HTML import :: SVGStrokeDashArray, :: SVGStrokeDashOffset, :: SVGStrokeWidth, :: SVGTransform, :: SVGZoomAndPan
from Text.GenJSON import generic JSONEncode, generic JSONDecode, :: JSONNode
derive JSONEncode HtmlTag, HtmlAttr
derive JSONEncode SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan
derive JSONEncode SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan, SVGICCColor, SVGLength
derive JSONDecode HtmlTag, HtmlAttr
derive JSONDecode SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan
derive JSONDecode SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan, SVGICCColor, SVGLength
......@@ -3,6 +3,6 @@ implementation module Text.HTML.GenJSON
import Text.HTML, Text.GenJSON
derive JSONEncode HtmlTag, HtmlAttr
derive JSONEncode SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan
derive JSONEncode SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan, SVGICCColor, SVGLength
derive JSONDecode HtmlTag, HtmlAttr
derive JSONDecode SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan
derive JSONDecode SVGElt, SVGAttr, SVGAlign, SVGColor, SVGDefer, SVGFillOpacity, SVGFuncIRI, SVGLengthAdjust, SVGLengthUnit, SVGLineCap, SVGFillRule, SVGLineJoin, SVGMeetOrSlice, SVGStrokeMiterLimit, SVGPaint, SVGStrokeDashArray, SVGStrokeDashOffset, SVGStrokeWidth, SVGTransform, SVGZoomAndPan, SVGICCColor, SVGLength
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment