3 ms·
Everything makes sense to me until the Dual definitions: newtype Dual a = Dual {getDual :: a} instance Semigroup s => Dual s where (Dual a <> Dual b) =
by singron 4y ago
Everything makes sense to me until the Dual definitions:
newtype Dual a = Dual {getDual :: a}
instance Semigroup s => Dual s where
(Dual a <> Dual b) = Dual (b <> a)
instance Monoid m => Dual m where
mempty = Dual (mempty)
These are declaring instances of Dual, but they are providing method definitions for Semigroup and Monoid as if they were declaring instances for those types. I plugged this into ghc and I couldn't get this to compile either way. This isn't using an extension or some more obscure language than haskell is it?
- tczMUFlmoNk 4y agoLikely meant to be lifting instances of Semigroup and Monoid through Dual: newtype Dual a = Dual {getDual :: a} instance Semigroup s => Semigroup (Dual s) where (Dual a) <> (Dual b) = Dual (b <> a) instance Monoid m => Monoid (Dual m) where mempty = Dual (mempty)