module CssParser.Norm whereimport CssParser.Preludeimport GHC.Genericsclass GNorm f where gnorm :: f a -> f ainstance GNorm V1 where gnorm x = case x of {}instance GNorm U1 where gnorm U1 = U1instance (Norm c) => GNorm (K1 i c) where gnorm (K1 a) = K1 $ normalize ainstance (GNorm a, Constructor c) => GNorm (M1 C c a) where gnorm (M1 x) = M1 $ gnorm xinstance (GNorm a, Selector s) => GNorm (M1 S s a) where gnorm (M1 x) = M1 $ gnorm xinstance (GNorm a) => GNorm (M1 D d a) where gnorm (M1 x) = M1 $ gnorm xinstance (GNorm a, GNorm b) => GNorm (a :+: b) where gnorm (L1 x) = L1 $ gnorm x gnorm (R1 x) = R1 $ gnorm xinstance (GNorm a, GNorm b) => GNorm (a :*: b) where gnorm (a :*: b) = gnorm a :*: gnorm binstance GNorm UChar where gnorm = idinstance GNorm UDouble where gnorm = idinstance GNorm UFloat where gnorm = idinstance GNorm UInt where gnorm = idinstance GNorm UWord where gnorm = idclass Norm a where normalize :: a -> a default normalize :: (Generic a, GNorm (Rep a)) => a -> a normalize = gNormalizeDefaultgNormalizeDefault :: (Generic a, GNorm (Rep a)) => a -> agNormalizeDefault = to . gnorm . frominstance Norm a => Norm [a] where normalize = fmap normalizeinstance Norm a => Norm (Maybe a) where normalize = fmap normalizeinstance Norm a => Norm (NonEmpty a) where normalize = fmap normalizeinstance Norm () where normalize = idinstance Norm Text where normalize = idinstance Norm LText where normalize = idinstance Norm Integer where normalize = idnormUntilConst :: (Norm a, Eq a) => a -> anormUntilConst a = let a' = normalize a in if a' == a then a' else normUntilConst a'