1

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.

David
  • 674
  • 6
  • 19

1 Answers1

1

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 [].

chi
  • 111,837
  • 3
  • 133
  • 218