Я попробовал следующий код
class Group a where
(.+.) :: a -> a -> a
(.-.) :: a -> a -> a
zero :: a
opposite :: a -> a
x .-. y = x .+. opposite y
opposite x = zero .-. x
{-# MINIMAL (.+.), zero, (opposite | (.-.)) #-}
instance Fractional a => Group a where
x .+. y = x + y
zero = 0 :: a
opposite = negate :: a -> a
Но при загрузке в GHCi я получаю следующую ошибку:
group1.hs:11:26: error:
• Illegal instance declaration for ‘Group a’
(All instance types must be of the form (T a1 ... an)
where a1 ... an are *distinct type variables*,
and each type variable appears at most once in the instance head.
Use FlexibleInstances if you want to disable this.)
• In the instance declaration for ‘Group a’
|
11 | instance Fractional a => Group a where
|
Что я делаю не так?