git.iko.soy/typeable/swagger2
on master help sign in
Use overwrite strategy for HashMap SwaggerMonoid instances by default
commitab875b49baa185e9af43ec24a1cde3ced0a04ef2 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateThu 31 Dec 2015, 01:04 (11 years ago) parent38e2384
2 files changed+6−29
src/Data/Swagger/Internal.hs+1−29 src/Data/Swagger/Internal/Utils.hs+5
src/Data/Swagger/Internal.hs+1−29
@@ -784,43 +784,15 @@ instance SwaggerMonoid ParamLocation where
784784 swaggerMempty = ParamQuery
785785 swaggerMappend _ y = y
786786
787−instance SwaggerMonoid (HashMap Text Schema) where
787+instance SwaggerMonoid (HashMap FilePath PathItem) where
788788 swaggerMempty = HashMap.empty
789789 swaggerMappend = HashMap.unionWith mappend
790790
791−instance SwaggerMonoid (HashMap Text (Referenced Schema)) where
792− swaggerMempty = HashMap.empty
793− swaggerMappend = HashMap.unionWith swaggerMappend
794−
795791instance Monoid a => SwaggerMonoid (Referenced a) where
796792 swaggerMempty = Inline mempty
797793 swaggerMappend (Inline x) (Inline y) = Inline (x <> y)
798794 swaggerMappend _ y = y
799795
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−
824796instance SwaggerMonoid ParamAnySchema where
825797 swaggerMempty = ParamOther swaggerMempty
826798 swaggerMappend (ParamBody x) (ParamBody y) = ParamBody (swaggerMappend x y)
src/Data/Swagger/Internal/Utils.hs+5
@@ -1,5 +1,6 @@
11{-# LANGUAGE DefaultSignatures #-}
22{-# LANGUAGE FlexibleContexts #-}
3+{-# LANGUAGE FlexibleInstances #-}
34{-# LANGUAGE OverloadedStrings #-}
45{-# LANGUAGE RankNTypes #-}
56{-# LANGUAGE TypeOperators #-}
@@ -125,6 +126,10 @@ class SwaggerMonoid m where
125126instance SwaggerMonoid [a]
126127instance Ord k => SwaggerMonoid (Map k v)
127128
129+instance {-# OVERLAPPABLE #-} (Eq k, Hashable k) => SwaggerMonoid (HashMap k v) where
130+ swaggerMempty = mempty
131+ swaggerMappend = HashMap.unionWith (\_old new -> new)
132+
128133instance SwaggerMonoid Text where
129134 swaggerMempty = mempty
130135 swaggerMappend x "" = x