Package

purescript-simple-json

Repository
justinwoo/purescript-simple-json
License
MIT
Uploaded by
justinwoo
Published on
2017-09-21T20:34:44Z

Build Status

A simple Foreign/JSON library based on the Purescript's RowToList feature.

Requires compiler version 0.11.6 or greater.

Usage

See the API Docs or the tests for usage.

Usage Example

I use this in my simple-rpc-telegram-bot project to read configs quickly and easily:

newtype FilePath = FilePath String
derive instance ntFP :: Newtype FilePath _
derive newtype instance rfFP :: ReadForeign FilePath

newtype Token = Token String
derive instance ntT :: Newtype Token _
derive newtype instance rfT :: ReadForeign Token

newtype Id = Id Int
derive instance ntI :: Newtype Id _
derive newtype instance rfI :: ReadForeign Id

type Config =
  { token :: Token
  , torscraperPath :: FilePath
  , master :: Id
  }

getConfig :: IO (F Config)
getConfig = liftAff $ readJSON <$> readTextFile UTF8 "./config.json"