Skip to content

Instantly share code, notes, and snippets.

@maoe
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maoe/e5f72c3cf3687610fe5c to your computer and use it in GitHub Desktop.
Save maoe/e5f72c3cf3687610fe5c to your computer and use it in GitHub Desktop.
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Data.Aeson
import qualified Data.ByteString.Lazy as B
{- Generic Language extension -}
import GHC.Generics (Generic)
data Pull = Pull {
title :: String
} deriving (Show, Generic)
instance FromJSON Pull
instance ToJSON Pull
main = do
bstr <- (B.readFile "test.json")
loop bstr (100 :: Int)
where
loop _ 0 = return ()
loop bstr n = do
case decode bstr :: Maybe [Pull] of
Just ps -> mapM_ (putStrLn . title) ps
Nothing -> putStr "can't parse test.json"
loop bstr $ n-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment