Skip to content

Instantly share code, notes, and snippets.

@tmcw tmcw/rearrange.hs Secret
Created Feb 26, 2017

Embed
What would you like to do?
{-# 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
You can’t perform that action at this time.