Created
April 14, 2017 17:34
-
-
Save neektza/cf49d0ff9dfd3d2b8ae54bffadb5a8da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Meetup.Types.Event where | |
import Data.Text | |
import Data.Aeson | |
import Control.Applicative ((<$>), (<*>)) | |
import Control.Monad (mzero) | |
import Data.ByteString.Lazy | |
data Event = Event { name :: Text | |
, created :: Int | |
, event_url :: Text | |
} deriving (Show, Eq) | |
instance FromJSON Event where | |
parseJSON (Object v) = Event | |
<$> v .: "name" | |
<*> v .: "created" | |
<*> v .: "event_url" | |
parseJSON _ = mzero | |
-- Sample | |
sampleEvent = do | |
sample_event_json <- Data.ByteString.Lazy.readFile "responses/event.json" | |
let event = decode sample_event_json :: Maybe Event | |
return event |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment