0

here is my code for my film Data Type and a database to hold it

data Film = String [String] Int [String]
    deriving (Eq,Ord,Show,Read) 

testDatabase :: [Film]
testDatabase = ["Casino Royale" 
"Daniel Craig", "Eva Green", "Judi Dench"
2006
"Garry", "Dave", "Zoe", "Kevin", "Emma"

"Cowboys & Aliens"
"Harrison Ford", "Daniel Craig", "Olivia Wilde"
2011
"Bill", "Jo", "Garry", "Kevin", "Olga", "Liz"]

and i keep getting this error

parse error (possibly incorrect indentation or mismatched brackets)

No idea why its giving me that. ANy help guys?

1
  • You are missing a comma after "Emma" and before "Cowboys & Aliens". Oh, you are missing commas with each newline. Also, you haven't constructed your film values, all you've defined is a list of strings. Commented Mar 11, 2015 at 2:35

1 Answer 1

3

The problem has to do with the indentation in your list. Haskell cares a lot about whitespace, and if you continue onto a second line, then you need to indent. Also, make sure that your lists of strings are actually lists. A different issue is that you need a constructor in your data declaration. Try something like this:

data Film = Film String [String] Int [String]
    deriving (Eq,Ord,Show,Read) 

testDatabase :: [Film]
testDatabase = [Film "Casino Royale" 
    ["Daniel Craig", "Eva Green", "Judi Dench"]
    2006
    ["Garry", "Dave", "Zoe", "Kevin", "Emma"]
    , Film "Cowboys & Aliens"
    ["Harrison Ford", "Daniel Craig", "Olivia Wilde"]
    2011
    ["Bill", "Jo", "Garry", "Kevin", "Olga", "Liz"]]
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.