forked from argonaut-io/argonaut-hs
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from purescript-contrib/0.9-updates
Updates for PureScript 0.9.1
- Loading branch information
Showing
7 changed files
with
103 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
/.* | ||
!/.gitignore | ||
!/.jscsrc | ||
!/.jshintrc | ||
!/.travis.yml | ||
bower_components/ | ||
node_modules/ | ||
output/ | ||
dist/ | ||
tmp/ | ||
npm-debug.log | ||
test/test.js | ||
/bower_components/ | ||
/node_modules/ | ||
/output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
language: node_js | ||
sudo: false | ||
node_js: | ||
- 5 | ||
dist: trusty | ||
sudo: required | ||
node_js: 6 | ||
install: | ||
- npm install -g bower | ||
- npm install | ||
script: | ||
- npm test | ||
- bower install --production | ||
- npm run -s build | ||
- bower install | ||
- npm -s test | ||
after_success: | ||
- >- | ||
test $TRAVIS_TAG && | ||
node_modules/.bin/psc-publish > .pursuit.json && | ||
curl -X POST http://pursuit.purescript.org/packages \ | ||
-d @.pursuit.json \ | ||
-H 'Accept: application/json' \ | ||
-H "Authorization: token ${GITHUB_TOKEN}" | ||
echo $GITHUB_TOKEN | pulp login && | ||
echo y | pulp publish --no-push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "purescript-argonaut", | ||
"description": "PureScript version of Argonaut", | ||
"description": "PureScript's implementation of Argonaut", | ||
"authors": [ | ||
"Hardy Jones <>", | ||
"John A. De Goes <[email protected]>" | ||
|
@@ -11,12 +11,12 @@ | |
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"purescript-argonaut-traversals": "^0.7.0", | ||
"purescript-argonaut-core": "^0.2.1", | ||
"purescript-argonaut-codecs": "^0.6.0" | ||
"purescript-argonaut-codecs": "^1.0.0", | ||
"purescript-argonaut-core": "^1.0.0", | ||
"purescript-argonaut-traversals": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"purescript-console": "^0.1.0", | ||
"purescript-strongcheck": "^0.14.3" | ||
"purescript-console": "^1.0.0", | ||
"purescript-strongcheck": "^1.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
module Examples.Data.Argonaut.Record where | ||
|
||
import Data.Argonaut ((~>), (:=), (.?), jsonEmptyObject, printJson) | ||
import Data.Argonaut.Encode (EncodeJson, encodeJson) | ||
import Data.Argonaut.Decode (DecodeJson, decodeJson) | ||
import Data.Maybe (Maybe(..)) | ||
|
||
import Debug.Trace (print) | ||
|
||
newtype Foo = Foo | ||
{ foo :: Maybe Number | ||
, bar :: Maybe String | ||
} | ||
|
||
instance decodeJsonFoo :: DecodeJson Foo where | ||
decodeJson json = do | ||
obj <- decodeJson json | ||
foo <- obj .? "foo" | ||
bar <- obj .? "bar" | ||
pure $ Foo {foo: foo, bar: bar} | ||
|
||
instance encodeJsonFoo :: EncodeJson Foo where | ||
encodeJson (Foo f) | ||
= "bar" := f.bar | ||
~> "foo" := f.foo | ||
~> jsonEmptyObject | ||
|
||
instance showFoo :: Show Foo where | ||
show (Foo f) = "Foo {foo: " ++ show f.foo ++ ", bar:" ++ show f.bar ++ "}" | ||
|
||
foo :: Foo | ||
foo = Foo {foo: Just 42, bar: Nothing} | ||
|
||
main = do | ||
print $ "raw foo is: " ++ show foo | ||
print $ "encoded foo is: " ++ printJson (encodeJson foo) | ||
import Prelude | ||
|
||
import Data.Argonaut (class EncodeJson, class DecodeJson, Json, encodeJson, fromArray, decodeJson, jsonEmptyObject, (~>), (:=), (.?)) | ||
import Data.Either (Either) | ||
import Data.Traversable (traverse) | ||
|
||
newtype BlogPost = BlogPost | ||
{ id :: Int | ||
, title :: String | ||
, categories :: String | ||
, content :: String | ||
} | ||
|
||
instance decodeJsonBlogPost :: DecodeJson BlogPost where | ||
decodeJson json = do | ||
obj <- decodeJson json | ||
id <- obj .? "id" | ||
title <- obj .? "title" | ||
categories <- obj .? "categories" | ||
content <- obj .? "content" | ||
pure $ BlogPost { id, title, categories, content } | ||
|
||
instance encodeJson :: EncodeJson BlogPost where | ||
encodeJson (BlogPost post) | ||
= "id" := post.id | ||
~> "title" := post.title | ||
~> "categories" := post.categories | ||
~> "content" := post.content | ||
~> jsonEmptyObject | ||
|
||
type BlogPostArray = Array BlogPost | ||
|
||
decodeBlogPostArray :: Json -> Either String BlogPostArray | ||
decodeBlogPostArray json = decodeJson json >>= traverse decodeJson | ||
|
||
encodeBlogPostArray :: BlogPostArray -> Json | ||
encodeBlogPostArray bpa = fromArray $ encodeJson <$> bpa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"postinstall": "pulp dep install", | ||
"clean": "rimraf output && rimraf .pulp-cache", | ||
"build": "pulp build", | ||
"test": "pulp test" | ||
"build": "pulp build --censor-lib --strict", | ||
"test": "pulp build --include examples --censor-lib --strict && pulp test" | ||
}, | ||
"devDependencies": { | ||
"pulp": "^7.0.0", | ||
"purescript": "^0.7.6", | ||
"pulp": "^9.0.1", | ||
"purescript-psa": "^0.3.9", | ||
"purescript": "^0.9.1", | ||
"rimraf": "^2.4.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
module Data.Argonaut ( | ||
module Data.Argonaut.Combinators, | ||
module Data.Argonaut.Core, | ||
module Data.Argonaut.Decode, | ||
module Data.Argonaut.Encode, | ||
module Data.Argonaut.Parser, | ||
module Data.Argonaut.Printer, | ||
module Data.Argonaut.JCursor, | ||
module Data.Argonaut.Prisms, | ||
module Data.Argonaut.Traversals | ||
module Data.Argonaut | ||
( module Data.Argonaut.Core | ||
, module Data.Argonaut.Decode | ||
, module Data.Argonaut.Encode | ||
, module Data.Argonaut.JCursor | ||
, module Data.Argonaut.Parser | ||
, module Data.Argonaut.Printer | ||
, module Data.Argonaut.Prisms | ||
, module Data.Argonaut.Traversals | ||
) where | ||
|
||
import Data.Argonaut.Combinators | ||
import Data.Argonaut.Core | ||
import Data.Argonaut.Decode | ||
import Data.Argonaut.Encode | ||
import Data.Argonaut.Parser | ||
import Data.Argonaut.Printer | ||
import Data.Argonaut.JCursor | ||
import Data.Argonaut.Prisms | ||
import Data.Argonaut.Traversals | ||
|
||
import Data.Argonaut.Core (JArray, JAssoc, JBoolean, JNull, JNumber, JObject, JString, Json, foldJson, foldJsonArray, foldJsonBoolean, foldJsonNull, foldJsonNumber, foldJsonObject, foldJsonString, fromArray, fromBoolean, fromNull, fromNumber, fromObject, fromString, isArray, isBoolean, isNull, isNumber, isObject, isString, jsonEmptyArray, jsonEmptyObject, jsonFalse, jsonNull, jsonSingletonArray, jsonSingletonObject, jsonTrue, jsonZero, toArray, toBoolean, toNull, toNumber, toObject, toString) | ||
import Data.Argonaut.Decode (class DecodeJson, decodeJson, gDecodeJson, gDecodeJson', getField, (.?)) | ||
import Data.Argonaut.Encode (class EncodeJson, assoc, encodeJson, extend, gEncodeJson, gEncodeJson', (:=), (~>)) | ||
import Data.Argonaut.JCursor (JCursor(..), JsonPrim(..), cursorGet, cursorSet, downField, downIndex, exactNull, fail, fromPrims, inferEmpty, insideOut, primBool, primNull, primNum, primStr, primToJson, runJsonPrim, toPrims) | ||
import Data.Argonaut.Parser (jsonParser) | ||
import Data.Argonaut.Printer (class Printer, printJson) | ||
import Data.Argonaut.Prisms (_Array, _Boolean, _Null, _Number, _Object, _String) | ||
import Data.Argonaut.Traversals (_JsonArray, _JsonBoolean, _JsonNull, _JsonNumber, _JsonObject, _JsonString) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters