0 | module Text.CSS.Percentage
2 | import public Literal
4 | import Derive.Literal
5 | import Derive.Prelude
7 | %language ElabReflection
11 | IsPercentage : Double -> Bool
12 | IsPercentage x = 0 <= x && x <= 100
17 | record Percentage where
18 | constructor MkPercentage
20 | {auto 0 prf : Holds IsPercentage value}
22 | %runElab derive "Percentage" [Show,Eq,Ord,DoubleLit]
25 | Interpolation Percentage where
26 | interpolate (MkPercentage v) = show v ++ "%"
36 | {auto _ : Cast Percentage a}
38 | -> {auto 0 prf : Holds IsPercentage v}
40 | perc v = cast $
MkPercentage v
44 | {auto _ : Cast Percentage a}
46 | -> {auto 0 prf : Holds IsPercentage v}