Ich versuche (PolyA a) und (PolyB a) zu Instanzen der Klasse Polynom, wo ich Coeffs, Coeffs, CoeffsB, CoeffsB implementieren möchte. Ich bin nicht ganz sicher, was ich falsch mache, weil ich eine Fehlermeldung bekomme, dass meine Funktionen für die Klasse Polynom nicht sichtbar sind. Irgendwelche Hilfe bitte?Haskell Typ Klasseninstanziation
class Polynomial p where
--default implementations
data PolyA a = Coeffs [a]
deriving (Show)
data PolyB a = Const a | X (PolyB a) a
deriving (Show)
--instances
instance Polynomial (PolyA a) where
coeffs (Coeffs f)=f
fromCoeffs f= Coeffs f
instance Polynomial (PolyB a) where
coeffsB (Const f)= [f]
coeffsB (X f a)= coeffsB f ++ [a]
fromCoeffsB [] = error "Wrong Input!"
fromCoeffsB [f]= Const f
fromCoeffsB [email protected](_:t)= X (fromCoeffsB (init lis)) (last lis)
Sie haben in der 'class' Deklaration keine Funktionen definiert. – user2407038