Lets see declaration of a new data type used to deal with reverse list in Haskell:
import Data.Monoid
data RevList a = Nil | RCons (RevList a) a deriving (Eq, Show)
instance Monoid a => Monoid (RevList a) where
mempty = Nil
instance Semigroup a => Monoid (RevList a) where
Nil <> RCons (RevList a) a = RCons (RevList a) a
RCons (RevList a) a <> RNil = RCons (RevList a) a
Nil <> Nil = Nil
The problem I'm troubled with is a compilation failure which description looks as follows:
`<>' is not a (visible) method of class `Monoid'
First I've tried to create a Monoid instance without any declaration of a Semigroup instance, but it caused another failure managed after reading this question. So, what's wrong with '<>' in the current stuff? Be sure, I'm aware of missing Monoid function like mappend or mconcat to be added to Monoid instance code as compulsory ones.