-- Types
type Title = String
type Actor = String
type Cast = [Actor]
type Year = Int
type Fan = String
type Fans = [Fan]
type Period = (Year, Year)
type Database = [Film]
testDatabase :: Database
testDatabase = [("The Gunman", ["Idris Elba", "Sean Penn", " Javier Bardem"],
2015,["Garry", "Dave", "Zoe", "Kevin", "Emma"]),("The Shawshank Redemption", ["Tim Robbins", "Morgan Freeman", "Bob Gunton"],1994, ["Bill", "Jo", "Garry"]),
("The Dark Knight", ["Christian Bale", "Heath Ledger","Aaron Eckhart"], 2008, ["Zoe","Heidi", "Jo", "Emma", "Liz", "Sam", "Olga", "Kevin", "Tim"]),
("Inception", ["Leonardo DiCaprio", "Ellen Page"], 2010, ["Jo", "Emma", "Zack", "Olga", "Kevin"])]
displayAllFilms :: Database ->[(Title, Cast, Year, Fans)]
displayAllFilms [] = []
displayAllFilms ((i, j, k, l): xs)
|l == [] = (i, j, k, []) : displayAllFilms xs
|otherwise = (i, j, k, l) : displayAllFilms xs
我收到此错误>我不知道该怎么办。什么是错误?
*Main> displayAllFilms
<interactive>:13:1:
No instance for (Show (Database -> [(Title, Cast, Year, Fans)]))
arising from a use of `print'
Possible fix:
add an instance declaration for
(Show (Database -> [(Title, Cast, Year, Fans)]))
In a stmt of an interactive GHCi command: print it
答案 0 :(得分:4)
查看错误消息; ghci告诉您,您正在尝试打印数据库 - &gt;类型的函数。 [(标题,演员,年份,粉丝)] 并且它不知道如何做到这一点。
据推测,您尝试打印displayAllFilms
,而您可能意味着displayAllFilms testDatabase