0
我需要解析iCalendar格式,這基本上是Google日曆和幾乎所有日曆應用程序使用的格式。解析iCalendar格式
我發現這個包iCalendar Hackage
但我無法弄清楚如何使用parseICalendar
功能在這個包,如果有人能告訴我什麼,我做錯了,這將是巨大的。
主要是我無法弄清楚如何構建一個參數的類型DecodingFunctions
parseICalendar :: DecodingFunctions
-> FilePath --^Used in error messages.
-> ByteString
-> Either String ([VCalendar], [String])
我的努力:
module CalendarReader
(getCalendar
, getSummary
) where
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy as B -- package "bytestring"
import qualified Text.ICalendar as ICal -- package "iCalendar"
import qualified Data.Map as Map -- package "containers"
import Network.HTTP.Simple -- package "http-conduit"
import qualified Time -- local module
import Constants
getCalendar :: IO B.ByteString
getCalendar = do
request <- parseRequest $ "GET" ++ calendarURL
response <- httpLBS request
return $ getResponseBody response
getSummary :: B.ByteString -> Time.DateTime -> Int -> String
getSummary cal dateTime dayOffset = summary
where
summary = "Event Summary"
((ICal.VCalendar { ICal.vcEvents = vcEvents' }), _) = ICal.parseICalendar ?missingArgument? logFile cal
是的,這個工程。什麼花了我額外的時間,雖然是搞清楚,我需要導入Data.default爲def – BinaryHexer