Skip to content

Commit

Permalink
Merge pull request #1849 from digitallyinduced/amitaibu-patch-4
Browse files Browse the repository at this point in the history
Implement `isEmpty` for `Data.Map`
  • Loading branch information
mpscholten authored Oct 20, 2023
2 parents 7c55c8e + 7411f4b commit 0782f1b
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 0782f1b

Please sign in to comment.