21 Dec 2012 06:40
monoid pair of monoids?
Christopher Howard <christopher.howard <at> frigidcode.com>
2012-12-21 05:40:13 GMT
2012-12-21 05:40:13 GMT
In my current pondering of the compose-able objects them, I was thinking
it would be useful to have the follow abstractions: Monoids, which were
themselves tuples of Monoids. The idea was something like so:
code:
--------
import Data.Monoid
instance Monoid (Socket2 a b) where
mempty = Socket2 (mempty, mempty)
Socket2 (a, b) `mappend` Socket2 (w, x) = Socket2 (a `mappend` w, b
`mappend` x)
data Socket2 a b = Socket2 (a, b)
--------
However, this does not compile because of errors like so:
code:
--------
Sockets.hs:9:21:
No instance for (Monoid a)
arising from a use of `mempty'
In the expression: mempty
In the first argument of `Socket2', namely `(mempty, mempty)'
In the expression: Socket2 (mempty, mempty)
--------
(Continue reading)
RSS Feed