Skip to content

Commit ff4a4ca

Browse files
Hashable for attributes
1 parent 160f787 commit ff4a4ca

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lucid-svg.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ library
2323
build-depends: base >= 4.5 && < 4.10,
2424
blaze-builder >= 0.4 && < 0.5,
2525
bytestring >= 0.10 && < 0.11,
26+
hashable >= 1.1 && < 1.3,
2627
text >= 0.11 && < 1.3,
2728
unordered-containers >= 0.2 && < 0.2.7
2829
hs-source-dirs: src

src/Lucid/Svg/Core.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import qualified Blaze.ByteString.Builder as BB
3636
import qualified Blaze.ByteString.Builder.Html.Utf8 as BB
3737
import qualified Data.ByteString.Lazy as LB
3838
import Data.ByteString.Lazy (ByteString)
39+
import Data.Hashable (Hashable(..))
3940
import Data.HashMap.Strict (HashMap)
4041
import qualified Data.HashMap.Strict as M
4142
import Data.Monoid
@@ -51,6 +52,9 @@ import qualified Data.Text.Lazy.Encoding as LT
5152
data Attribute = Attribute !Text !Text
5253
deriving (Show,Eq)
5354

55+
instance Hashable Attribute where
56+
hashWithSalt salt (Attribute a b) = salt `hashWithSalt` a `hashWithSalt` b
57+
5458
-- | Type of an SVG element.
5559
newtype Element = Element (HashMap Text Text -> Builder)
5660

0 commit comments

Comments
 (0)