0 | module Text.CSS.Percentage
3 | import Derive.Prelude
4 | import Derive.Refined
6 | %language ElabReflection
10 | IsPercentage : Double -> Bool
11 | IsPercentage x = 0 <= x && x <= 100
16 | record Percentage where
17 | constructor MkPercentage
19 | {auto 0 prf : Holds IsPercentage value}
21 | %runElab derive "Percentage" [Show,Eq,Ord,RefinedDouble]
24 | Interpolation Percentage where
25 | interpolate (MkPercentage v) = show v ++ "%"
35 | {auto _ : Cast Percentage a}
37 | -> {auto 0 prf : Holds IsPercentage v}
39 | perc v = cast $
MkPercentage v