Reputation: 127
Here is my code and there are so many things wrong about it that i can't see. What is the problem? or what "are" the problems?? I get these errors for several lines:
In the sixth argument of `NBaum', namely
data NBaum a = NBlatt a | NKnoten a [NBaum a]
deriving(Eq,Show)
tree :: NBaum String
tree =
NBaum "Sonne"
(NKnoten "Erde"
(NBlatt "MOND" )
)
(NBlatt "Merkur" )
(NBlatt "Venus" )
(NKnoten "MARS"
(NBlatt "PHOBOS" )
(NBlatt "DEIMOS" )
)
(NKnoten "JUPITER"
(NBlatt "Io" )
(NBlatt "EUROPA" )
(NBlatt "GANYMED" )
(NBlatt "KALLISTO" )
)
Upvotes: 0
Views: 114
Reputation: 476503
The problem is that if you describe a list []
, you do this between square brackets separated with commas, like [1,4,2,5]
. Not between round brackets: that is a tuple.
tree :: NBaum String
tree = NKnoten "Sonne" [
NKnoten "Erde" [NBlatt "MOND"],
NBlatt "Merkur",
NBlatt "Venus",
NKnoten "MARS" [
NBlatt "PHOBOS",
NBlatt "DEIMOS"
],
NKnoten "JUPITER" [
NBlatt "Io",
NBlatt "EUROPA",
NBlatt "GANYMED",
NBlatt "KALLISTO"
]
]
Furthermore - as is highlighted in the code fragment - you (probably accidentally) - wrote the type name (NBaum
) instead of constructor name (NKnoten
) at the first object (the "Sonne"
).
Upvotes: 4