0

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?

1
  • 1
    max does maximum of two, not of a list of N elements. You want maximum. Also, you don't seem to be accepting your second argument (the [Review]). Commented Dec 18, 2013 at 17:01

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.