Skip to content

Instantly share code, notes, and snippets.

@dredozubov
Created May 8, 2015 14:04
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 dredozubov/7a5e559d77ed580b2e75 to your computer and use it in GitHub Desktop.
Save dredozubov/7a5e559d77ed580b2e75 to your computer and use it in GitHub Desktop.
import qualified Data.ByteString as BS
data Config = Config {
cfg_home :: Maybe FilePath
}
instance FromJSON Config where
parseJSON (Object o) = ...
main = do
jsonContents <- BS.readFile "your-config-file.json"
let decoded = (eitherDecode jsonContents :: Either String Config)
case decoded of
(Left err) -> print "error"
(Right v) -> doWhateverYouDo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment