Reputation: 49
This is my function:
bestLocByArtiest :: String -> [Review] -> Double
bestLocByArtiest art = rev
where gmloc = [gemZaalByArtiest art, gemFestByArtiest art, gemOpenByArtiest art]
rev = max gmloc
This is the error i get:
Review.hs:101:24:
Couldn't match type `[Review] -> Double' with `Review'
Expected type: [Review] -> Double
Actual type: [[Review] -> Double] -> [[Review] -> Double]
In the expression: rev
In an equation for `bestLocByArtiest':
bestLocByArtiest art
= rev
where
gmloc = [gemZaalByArtiest art, ....]
rev = max gmloc
So I was hoping somebody could explain me what this error means and what I have to change in my code to solve it.
EDIT By changing max to maximum i got this new error:
Review.hs:103:21:
No instance for (Ord ([Review] -> Double))
arising from a use of `maximum'
Possible fix:
add an instance declaration for (Ord ([Review] -> Double))
In the expression: maximum gmloc
In an equation for `rev': rev = maximum gmloc
In an equation for `bestLocByArtiest':
bestLocByArtiest art
= rev
where
gmloc = [gemZaalByArtiest art, ....]
rev = maximum gmloc
What does this mean?
Upvotes: 0
Views: 815
Reputation: 122496
Given that bestLocByArtiest
is called with a String
the type of rev
needs to be [Review] -> Double
. However it's actually [[Review] -> Double] -> [[Review] -> Double]
. That's basically what the error message says.
So to fix it you either need to change the type signature of bestLocByArtiest
or you need to modify what rev
does. That involves looking at the types of max
, gmloc
and the individual elements in gmloc
to make sure it does what you want.
Upvotes: 1