[Haskell-cafe] Getting started - help

applebiz89 applebiz89 at hotmail.com
Thu Apr 30 11:04:46 EDT 2009

Hey thanks, that was really helpful actually. I know it must be annoying for
you, and im sorry but ive done what you said, try and compile it to see if
it does and fix it. I have tried every possible way of using brackets in
different place's etc (as u can tell Im not good with haskell at all) but it
still isnt, it must be to do with my data type.

-- Film as datatype

data Film = String String Int [String]

-- List of films

testDatabase :: [Film]
testDatabase = ["Casino Royale", "Martin Campbell" ,2006, ["Garry", "Dave",
"Zoe"] ]

I get this error:

*** Expression     : ["Casino Royale","Martin
*** Term           : [("Garry","Dave","Zoe")]
*** Type           : [([Char],[Char],[Char])]
*** Does not match : [Char]

Thanks alot!


Tillmann Rendel-3 wrote:
> Hi,
> applebiz89 wrote:
>> data Film = Film String String Int String 
>> with this as the data. 
>> testDatabase :: [Film] 
>> testDatabase = [("Casino Royale", "Martin Campbell",2006, "Garry, Dave,
>> Zoe")] 
> Try to compile this part of the program, to get a feeling for whether 
> you are on the right track. If it does not compile, try to find out 
> what's wrong and correct it so that it compiles.
> As you already noted in a different mail, you plan to change the 
> representation of the list of fans to a list of strings (instead of a 
> single string with commas). That is a good idea! So change the data 
> declaration, and change the definition of testDatabase to this new 
> design. Try to compile that program.
> Now you can add some utility functions to work with your database. This 
> will make it much easier to write a correct user interface later. For 
> example, write a function
>    isFan :: [Film] -> String -> String -> Bool
> which checks whether someone is a fan of a film in your database. In 
> other words,
>    isFan testDatabase "Garry" "Casino Royale"
> should be True, but
>    isFan testDatabase "Peter" "Matrix"
> should be False.
> Another useful utility function could be
>    becomeFan :: String -> String -> [Film] -> [Film]
> which adds the information that someone is a fan of some film to an 
> existing database. Note that this function does not do any user 
> interaction, but gets the name of the fan and the name of the film as 
> arguments.
> Think about which other utility functions you could use. Try them out in 
> ghci. When you have done that, you can write a user interface which asks 
> for input on the command line and uses the utility functions to keep 
> track of the current database.
>    Tillmann
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

View this message in context: http://www.nabble.com/Getting-started---help-tp23314466p23318195.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list