Reputation: 674
I have the following type:
data SomeType = Var String
deriving (Eq,Show)
newtype TypeA = TypeA [(String, SomeType)]
deriving (Eq,Show)
Also, I have a function:
fun1 :: TypeA -> TypeA -> TypeA
I can use this function for mappend
.
I don't understand, how to implement Monoid interface in my case.
Upvotes: 1
Views: 296
Reputation: 116174
If you already have fun1
, just add an instance:
instance Monoid TypeA where
mempty = .... -- fill this with the neutral element
mappend = fun1
Probably, you want mempty = TypeA []
.
Upvotes: 1