Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created February 26, 2017 22:07
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 tmcw/243c7a267142862e4c1de7dd124aabb8 to your computer and use it in GitHub Desktop.
Save tmcw/243c7a267142862e4c1de7dd124aabb8 to your computer and use it in GitHub Desktop.
{-# LANGUAGE DeriveGeneric, OverloadedStrings #-}
import GHC.Generics
import System.Directory
import System.IO
import Prelude
import Data.Either
import Data.Aeson
import qualified Data.ByteString.Lazy as B
{- data Chart =
Chart (Array Entry) deriving (Show, Generic) -}
data Entry =
Entry { artist :: !String
, change :: !String
} deriving (Show, Generic)
instance FromJSON Entry
instance ToJSON Entry
readAndParse :: FilePath -> IO ()
readAndParse filePath =
case (eitherDecode <$> B.readFile filePath) of
Left val -> print "yes"
Right err -> print "no"
main = do
fileList <- getDirectoryContents "./charts"
(map readAndParse fileList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment