diff --git a/IHP/HaskellSupport.hs b/IHP/HaskellSupport.hs index 92f18cdfc..0bf56b06b 100644 --- a/IHP/HaskellSupport.hs +++ b/IHP/HaskellSupport.hs @@ -50,6 +50,7 @@ import qualified Data.Attoparsec.ByteString.Char8 as Attoparsec import Data.String.Conversions (cs, ConvertibleStrings (..)) import qualified Debug.Trace import qualified Data.Text as Text +import qualified Data.Map as Map import qualified Data.ByteString.Char8 as ByteString import qualified Data.Aeson.Key as Aeson @@ -86,6 +87,10 @@ instance IsEmpty UUID.UUID where isEmpty uuid = UUID.nil == uuid {-# INLINE isEmpty #-} +instance IsEmpty (Map a b) where + isEmpty = Map.null + {-# INLINE isEmpty #-} + ifOrEmpty :: (Monoid a) => Bool -> a -> a ifOrEmpty bool a = if bool then a else mempty {-# INLINE ifOrEmpty #-} @@ -445,4 +450,4 @@ allEnumValues = enumFrom (toEnum 0) instance ConvertibleStrings ByteString Aeson.Key where convertString byteString = Aeson.fromText (cs byteString) instance ConvertibleStrings Text Aeson.Key where - convertString text = Aeson.fromText text \ No newline at end of file + convertString text = Aeson.fromText text