From 02fc57a0cb053c2e599f2cc8fccd33e06bf93152 Mon Sep 17 00:00:00 2001 From: Hans-Peter Deifel <hpd@hpdeifel.de> Date: Fri, 8 Mar 2019 08:52:20 +0100 Subject: [PATCH] Add Eq and Show instances to SumBag This is a requirement for its use in copar and also allows for testing, since `shouldBe` from hspec requires those two instances. --- src/Data/SumBag.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Data/SumBag.hs b/src/Data/SumBag.hs index 163db8d..7173dfe 100644 --- a/src/Data/SumBag.hs +++ b/src/Data/SumBag.hs @@ -16,6 +16,10 @@ import qualified Data.List.NonEmpty as NE type SumBag a = Tree a data Tree a = Leaf | Node (MetaData a) (Element a) (Tree a) (Tree a) + deriving (Show) + +instance (Ord a, Eq a) => Eq (Tree a) where + x == y = toAscList x == toAscList y type role Tree nominal @@ -23,11 +27,13 @@ data MetaData a = MetaData { nodeSize :: Int , nodeSum :: a } + deriving (Show) data Element a = Element { value :: a , multiplicity :: NE.NonEmpty a } + deriving (Show) empty :: SumBag a -- GitLab