Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 7
- data CalendarProp = Prodid String | Version deriving (Show, Eq)
- data Calendar = Calendar CalendarProp CalendarProp [Event] deriving (Show, Eq)
- data Event = Event [EventProp] deriving (Show, Eq)
- data EventProp = Dtstamp DateTime | Dtstart DateTime | Uid String | Dtend DateTime | Description String | Summary String | Location String deriving (Show, Eq)
- -- 8
- pEndLine = token "\n"
- pString = greedy (satisfy (/='\n'))
- pDtstamp = token "DTSTAMP:" *> (Dtstamp <$> parseDateTime) <* pEndLine
- pDtstart = token "DTSTART:" *> (Dtstart <$> parseDateTime) <* pEndLine
- pDtend = token "DTEND:" *> (Dtend <$> parseDateTime) <* pEndLine
- pUid = token "UID:" *> (Uid <$> pString) <* pEndLine
- pDescription = token "DESCRIPTION:" *> (Description <$> pString) <* pEndLine
- pSummary = token "SUMMARY:" *> (Summary <$> pString) <* pEndLine
- pLocation = token "LOCATION:"*> (Location <$> pString) <* pEndLine
- pProdid = token "PRODID:" *> (Prodid <$> pString) <* pEndLine
- pVersion = token "VERSION:" *> (Version <$ token "2.0") <* pEndLine
- pCalProp = pVersion <|> pProdid
- pEventProp :: Parser Char EventProp
- pEventProp = pDtstamp <|> pDtstart <|> pDtend <|> pUid <|> pDescription <|> pSummary <|> pLocation
- pEventProps :: Parser Char [EventProp]
- pEventProps = many pEventProp
- pEventProps2 :: Parser Char Event
- pEventProps2 = Event <$> many pEventProp
- pEvent :: Parser Char Event
- pEvent = Event <$ token "BEGIN:VEVENT:\n" *> pEventProps <* token "END:VEVENT\n"
- pEvents = many pEvent
- pCalendar = Calendar <$> pCalProp <*> pCalProp <*> pEvents
- parseCalendar :: Parser Char Calendar
- parseCalendar = token "BEGIN:VCALENDAR\n" *> pCalendar <* token "END:VCALENDAR\n"
- eS = "BEGIN:VEVENT\nUID:19970610T172345Z-AF23B2@example.com\nDTSTAMP:19970610T172345Z\nDTSTART:19970714T170000Z\nDTEND:19970715T040000Z\nSUMMARY:Bastille Day Party\nEND:VEVENT\n"
- ePS2 = "BEGIN:VEVENT\nUID:19970610T172345Z-AF23B2@example.com\nDTSTAMP:19970610T172345Z\nDTSTART:19970714T170000Z\nDTEND:19970715T040000Z\nSUMMARY:Bastille Day Party\n"
- ePS = "UID:19970610T172345Z-AF23B2@example.com\nDTSTAMP:19970610T172345Z\nDTSTART:19970714T170000Z\nDTEND:19970715T040000Z\nSUMMARY:Bastille Day Party\n"
Add Comment
Please, Sign In to add comment