0
我正試圖重寫一個從一個或多個網頁中抓取信息並將其轉換爲閃存卡的小程序。小片段在這裏:Haskell中的IO操作的復現
-- | this takes a string and produces IO [Tag String]
getVerbePage x = fmap parseTags $ openURL $ "http://leconjugueur.lefigaro.fr/conjugaison/verbe/" ++ x ++ ".html"
main = do
tags <- getVerbePage "aller"
-- | from here I do whatever I like with a clean [Tag String]
在一段時間我都沒有問題做一個,在IO轉到做循環,然後我做什麼,我需要與純函數。我真的不知道如何在經常性的方式做到這一點,基本上就是我後:
-- | this takes a string and produces IO [Tag String]
getVerbePage x = fmap parseTags $ openURL $ "http://leconjugueur.lefigaro.fr/conjugaison/verbe/" ++ x ++ ".html"
main = do
verbsString <- getLine -- | example input "aller pouvoir"
let verbs = splitOn " " verbsString -- | list of strings
pages <- getVerbePages verbs
-- | from here use pure functions on pages, which would be type [[Tag String]]
getVerbePages :: [String] -> [[Tag String]] -- | I guess.
getVerbePages ps = ??????
的問題是我怎麼寫了在PS中每個字符串getVerbePages循環和清潔退貨嗎?我已經能夠做到遞歸動作以及所有到目前爲止的好處,非常適合Haskell newb,但我不明白在重複執行IO動作時所有這些都是如何工作的。
乾杯,這就是我一直在尋找的東西,在我的初學者書中還沒有達到,只是去追趕它。 'getAllPages VS = MAPM getVerbePage vs' 'getVerbePage X = FMAP parseTags $的OpenURL $ 「http://leconjugueur.lefigaro.fr/conjugaison/verbe/」 ++ X ++名 「.html」' 由於一堆。 – MalucoMarinero