In ghci:
Data.Semigroup> 0.1 :: Sum Double
<interactive>:2:1: error: [GHC-39999]
• No instance for ‘Fractional (Sum Double)’
arising from the literal ‘0.1’
• In the expression: 0.1 :: Sum Double
In an equation for ‘it’: it = 0.1 :: Sum Double
Is this an oversight, or is there a principled reason not to make this instance? (I know that addition is not associative for Double
-- but instance Monoid (Sum Double)
, the actually problematic instance for that objection, already exists anyway!)
Sum
: you essentially have to implement all the instances forinstance C a => C (Sum a)
for all classes, except the ones you override. Especially ifC
is from another package, that is thus complicated, and often makesSum
less powerful. – Kevel