Skip to content

Commit

Permalink
Implement isEmpty for Data.Map
Browse files Browse the repository at this point in the history
  • Loading branch information
amitaibu authored Oct 20, 2023
1 parent e66f966 commit 7411f4b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion IHP/HaskellSupport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 #-}
Expand Down Expand Up @@ -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
convertString text = Aeson.fromText text

0 comments on commit 7411f4b

Please sign in to comment.