
11 Mar
2012
11 Mar
'12
12:10 p.m.
On Sunday 11 March 2012, 16:57:30, Peter Hall wrote:
Can someone remind me why I can't do this:
data Digit = D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 deriving (Eq, Ord, Show)
instance Num [Digit] where ... -- This isn't allowed
It's because the language standard says that the types in the instance head must be of the form T a1 ... ak with `T' a type constructor and the ai distinct type variables. Why that is, I don't know. You can make an instance Num [Digit] where ... if you enable {-# LANGUAGE FlexibleInstances #-} That's a harmless extension allowing instances of that form.