I have data type:
data Stuff s = Stuff { name :: s, idx :: Int }
And want to make this into a monoid w/ the following implementations:
tmappend :: Stuff s -> Stuff t -> Stuff (s,t)
tmappend s1 s2 = Stuff (name s1, name s2) (idx s1 + idx s2)
tzero :: Stuff ()
tzero = Stuff () 0
Note it's possible to get arbitrarily nested tuples through mconcat
.
But tmappend is currently violating the type signature of mappend
. Is this actually a monoid? Can it be made into one with a better type representation.