這是我被分配到調試一個Haskell程序的一部分:在Haskell中,this @(Sentence string _)= do`是什麼意思?
process :: Sentence -> IO()
process [email protected](Sentence string _) = do
render string
render "==>"
render $ translate this
render = putStrLn
data Sentence = Sentence String Task
translate :: Sentence -> String ; Incomplete Definition
translate (Sentence string task)
| ...
| ...
| ...
| ...
這個節目,我不理解或認識的唯一部分是之前,我從來沒有見過[email protected]
行process [email protected](Sentence string _) = do
我也不太確定(Sentence string _)
中的下劃線是什麼意思。
你是說我需要在這個@語句之後添加一個條件來捕獲不匹配的輸入嗎? – CodyBugstein 2013-03-07 20:00:43
請注意,這通常被稱爲「as-pattern」,但有些人稱之爲「at-pattern」的想法並不令人驚訝。 – 2013-03-07 20:50:04
@ ThomasM.DuBuisson你說的沒錯,我真的應該知道我有多少次盯着AST節點的模式:P – DarkOtter 2013-03-07 22:42:40