这是我的电影数据类型的代码和保存它的数据库
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"]
我不断收到此错误
parse error (possibly incorrect indentation or mismatched brackets)
不知道为什么给我那个。不帮忙吗?
答案 0 :(得分:3)
问题与列表中的缩进有关。 Haskell非常关心空白,如果继续第二行,那么你需要缩进。另外,请确保您的字符串列表实际上是列表。另一个问题是您需要在数据声明中使用构造函数。尝试这样的事情:
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"]]