Hallo ich bin neu in Haskell und ich habe Probleme.Kann nicht erwartet Typ d mit tatsächlichen Typ b
Ich möchte ein Verfahren schaffen, die für eine Partida und für eine Liste von Partidas (Facturas) zu tun, so haben wir diesen Code gültig ist:
data Bebida a b where {
Bebida::(Integral a, Fractional b)=>{codigo::a, nombre::[Char], precio::b } -> Bebida a b
}
data Partida a b c where {
ParMult:: (Integral a, Integral c, Fractional b) => {cantidad::c, bebida::Bebida a b} -> Partida a b c;
ParUnit:: (Integral a, Integral c, Fractional b) => {bebida::Bebida a b} -> Partida a b c
}
type Factura a b c = [Partida a b c]
class Preciable a where
precioe :: (Fractional d) => a -> d
instance (Integral a, Fractional b, Integral c) => Preciable (Partida a b c) where
precioe (ParMult n b) = (fromIntegral(n)*(precio b))
precioe (ParUnit b) = (precio b)
instance (Integral a, Integral c, Fractional b, Eq b) => Preciable (Factura a b c) where
precioe f = sum [precioe x | x<-f]
Ich weiß nicht, warum gibt mir diese Fehler. Kann mir jemand helfen, mir zu sagen, warum Haskell mir diesen Fehler gibt?
Vielen Dank für Ihre Hilfe !!
'precioe :: (Fractional d) => a -> d' verspricht für Arbeit * jede * 'd' überhaupt, durch den Code gewählt * Aufruf * 'precioe'. Ihre Implementierungen geben dem Anrufer nicht die Freiheit, sondern erzwingen, dass "d" der Typ ist, der in Ihren "Partida" - und "Factura" -Typen gebacken wird. – amalloy