git.iko.soy/typeable/swagger2
on master help sign in
Use overwrite strategy for HashMap SwaggerMonoid instances by default
ab875b4Nickolay Kudasov
src/Data/Swagger/Internal.hs+1−29
@@ -784,43 +784,15 @@ instance SwaggerMonoid ParamLocation where
784 swaggerMempty = ParamQuery
784 swaggerMempty = ParamQuery
785 swaggerMappend _ y = y
785 swaggerMappend _ y = y
786
786
787−instance SwaggerMonoid (HashMap Text Schema) where
787+instance SwaggerMonoid (HashMap FilePath PathItem) where
788 swaggerMempty = HashMap.empty
788 swaggerMempty = HashMap.empty
789 swaggerMappend = HashMap.unionWith mappend
789 swaggerMappend = HashMap.unionWith mappend
790
790
791−instance SwaggerMonoid (HashMap Text (Referenced Schema)) where
792− swaggerMempty = HashMap.empty
793− swaggerMappend = HashMap.unionWith swaggerMappend
794−
795instance Monoid a => SwaggerMonoid (Referenced a) where
791instance Monoid a => SwaggerMonoid (Referenced a) where
796 swaggerMempty = Inline mempty
792 swaggerMempty = Inline mempty
797 swaggerMappend (Inline x) (Inline y) = Inline (x <> y)
793 swaggerMappend (Inline x) (Inline y) = Inline (x <> y)
798 swaggerMappend _ y = y
794 swaggerMappend _ y = y
799
795
800−instance SwaggerMonoid (HashMap Text Param) where
801− swaggerMempty = HashMap.empty
802− swaggerMappend = HashMap.unionWith mappend
803−
804−instance SwaggerMonoid (HashMap Text Response) where
805− swaggerMempty = HashMap.empty
806− swaggerMappend = flip HashMap.union
807−
808−instance SwaggerMonoid (HashMap Text SecurityScheme) where
809− swaggerMempty = HashMap.empty
810− swaggerMappend = flip HashMap.union
811−
812−instance SwaggerMonoid (HashMap FilePath PathItem) where
813− swaggerMempty = HashMap.empty
814− swaggerMappend = HashMap.unionWith mappend
815−
816−instance SwaggerMonoid (HashMap HeaderName Header) where
817− swaggerMempty = HashMap.empty
818− swaggerMappend = flip HashMap.union
819−
820−instance SwaggerMonoid (HashMap HttpStatusCode (Referenced Response)) where
821− swaggerMempty = HashMap.empty
822− swaggerMappend = flip HashMap.union
823−
824instance SwaggerMonoid ParamAnySchema where
796instance SwaggerMonoid ParamAnySchema where
825 swaggerMempty = ParamOther swaggerMempty
797 swaggerMempty = ParamOther swaggerMempty
826 swaggerMappend (ParamBody x) (ParamBody y) = ParamBody (swaggerMappend x y)
798 swaggerMappend (ParamBody x) (ParamBody y) = ParamBody (swaggerMappend x y)
src/Data/Swagger/Internal/Utils.hs+5
@@ -1,5 +1,6 @@
1{-# LANGUAGE DefaultSignatures #-}
1{-# LANGUAGE DefaultSignatures #-}
2{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
3+{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE RankNTypes #-}
5{-# LANGUAGE RankNTypes #-}
5{-# LANGUAGE TypeOperators #-}
6{-# LANGUAGE TypeOperators #-}
@@ -125,6 +126,10 @@ class SwaggerMonoid m where
125instance SwaggerMonoid [a]
126instance SwaggerMonoid [a]
126instance Ord k => SwaggerMonoid (Map k v)
127instance Ord k => SwaggerMonoid (Map k v)
127
128
129+instance {-# OVERLAPPABLE #-} (Eq k, Hashable k) => SwaggerMonoid (HashMap k v) where
130+ swaggerMempty = mempty
131+ swaggerMappend = HashMap.unionWith (\_old new -> new)
132+
128instance SwaggerMonoid Text where
133instance SwaggerMonoid Text where
129 swaggerMempty = mempty
134 swaggerMempty = mempty
130 swaggerMappend x "" = x
135 swaggerMappend x "" = x