字符\ US的词汇错误

时间:2011-10-19 22:39:49

标签: haskell filter

我需要用高阶函数重新制作这个函数。我不知道如何改变lookupTitle,但另一个我已经改变了。但我在bookAuthors上收到了错误。

type Title = String
type Author = String
data Product = Book Title Author
                   | Video Author
                   | CD Title Integer Author
                   deriving (Eq,Show)

getTitle (Book title _ ) = title
getTitle (Video title  ) = title
getTitle (CD title _ _ ) = title

getTitles l = map (\x->getTitle x) l
lookupTitle _ [] = Nothing
lookupTitle x (y:ys) | getTitle y == x = Just y
                     | otherwise       = lookupTitle x ys

lookupTitles a b = map (\x->lookupTitle x b) a

 bookAuthors l = filter author l 
                       where author (Book _ _) = True
                                  author _ = False

为什么?

1 个答案:

答案 0 :(得分:2)

看起来像是缩进问题。 This编译没有错误。