Skip to content
Snippets Groups Projects
Commit 02fc57a0 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

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.
parent 9b761979
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,10 @@ import qualified Data.List.NonEmpty as NE ...@@ -16,6 +16,10 @@ import qualified Data.List.NonEmpty as NE
type SumBag a = Tree a type SumBag a = Tree a
data Tree a = Leaf | Node (MetaData a) (Element a) (Tree 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 type role Tree nominal
...@@ -23,11 +27,13 @@ data MetaData a = MetaData ...@@ -23,11 +27,13 @@ data MetaData a = MetaData
{ nodeSize :: Int { nodeSize :: Int
, nodeSum :: a , nodeSum :: a
} }
deriving (Show)
data Element a = Element data Element a = Element
{ value :: a { value :: a
, multiplicity :: NE.NonEmpty a , multiplicity :: NE.NonEmpty a
} }
deriving (Show)
empty :: SumBag a empty :: SumBag a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment