Skip to content

Instantly share code, notes, and snippets.

@neektza
Created April 14, 2017 17:34
Show Gist options
  • Save neektza/cf49d0ff9dfd3d2b8ae54bffadb5a8da to your computer and use it in GitHub Desktop.
Save neektza/cf49d0ff9dfd3d2b8ae54bffadb5a8da to your computer and use it in GitHub Desktop.
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