我在想什么(answers entry)
在totnChars entry = myLoop (answers entry)
中的用法。这是否意味着该条目必须是answers
?但entry
的Entryt
类型不是entry
?理解一个Haskell函数
type Question = [Char]
type Answer = [Char]
type Music = [Char]
data Entryt = MyEntry {
questions :: [Question],
answers :: [Answer],
music :: Music,
time :: Float
} deriving (Show, Eq)
totnChars :: Entryt -> Int
totnChars entry = myLoop (answers entry)
myLoop :: [Answer] -> Int
myLoop [] = 0
myLoop (x:rest) = (nChars x 0) + (myLoop rest)
'answers'的类型是'Entryt - > [Answer]'。 – pyon
我们通过明确书写(答案条目)获得了什么? – DoubleOseven