Skip to content

Updates for PureScript 0.9.1 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
language: node_js
sudo: false
node_js:
- 4
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 &&
npm install bower -g &&
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
10 changes: 5 additions & 5 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Hardy Jones <>",
"John A. De Goes <[email protected]>"
],
"description": "Core of purescript-argonaut library, it provides basic types, folds and combinators for `Json`",
"description": "Core of the purescript-argonaut library, providing basic types, folds, and combinators for `Json`",
"keywords": [
"purescript",
"argonaut",
Expand All @@ -18,11 +18,11 @@
},
"license": "MIT",
"dependencies": {
"purescript-enums": "^0.7.0",
"purescript-functions": "^0.1.0",
"purescript-maps": "^0.5.0"
"purescript-enums": "^1.0.0",
"purescript-functions": "^1.0.0",
"purescript-maps": "^1.0.0"
},
"devDependencies": {
"purescript-strongcheck": "^0.14.0"
"purescript-strongcheck": "^1.0.0"
}
}
10 changes: 5 additions & 5 deletions package.json
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",
"build": "pulp build --censor-lib --strict",
"test": "pulp test"
},
"devDependencies": {
"pulp": "^5.0.2",
"purescript": "^0.7.6",
"rimraf": "^2.4.4"
"pulp": "^9.0.0",
"purescript-psa": "^0.3.9",
"purescript": "^0.9.1",
"rimraf": "^2.5.0"
}
}
6 changes: 3 additions & 3 deletions src/Data/Argonaut/Core.purs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ module Data.Argonaut.Core

import Prelude

import Data.Tuple (Tuple())
import Data.Tuple (Tuple)
import Data.Maybe (Maybe(..))
import Data.Function
import Data.Function.Uncurried (Fn5, runFn5, Fn7, runFn7)

import qualified Data.StrMap as M
import Data.StrMap as M

-- | A Boolean value inside some JSON data. Note that this type is exactly the
-- | same as the primitive `Boolean` type; this synonym acts only to help
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Argonaut/Parser.purs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Data.Argonaut.Parser (jsonParser) where

import Data.Argonaut.Core (Json())
import Data.Function (Fn3(), runFn3)
import Data.Argonaut.Core (Json)
import Data.Either (Either(..))
import Data.Function.Uncurried (Fn3, runFn3)

foreign import _jsonParser :: forall a. Fn3 (String -> a) (Json -> a) String a

Expand Down
6 changes: 3 additions & 3 deletions src/Data/Argonaut/Printer.purs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Data.Argonaut.Printer (Printer, printJson) where
module Data.Argonaut.Printer where

import Prelude
import Data.Argonaut.Core (Json())

import Data.Argonaut.Core (Json)

class Printer a where
printJson :: Json -> a

instance printerString :: Printer String where
printJson = show

45 changes: 22 additions & 23 deletions test/Test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ module Test.Main where

import Prelude

import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Console (log)
import Data.Maybe (Maybe(..))
import Data.Maybe.Unsafe (fromJust)

import Data.Argonaut.Core (Json, JNull, toObject, toArray, toString, toNumber, toBoolean, toNull, fromObject, foldJsonObject, fromNumber, fromArray, foldJsonArray, fromString, foldJsonString, foldJsonNumber, fromBoolean, foldJsonBoolean, fromNull, foldJsonNull, foldJson, isObject, isArray, isString, isNumber, isBoolean, isNull)
import Data.Argonaut.Parser (jsonParser)
import Data.Argonaut.Printer (printJson)
import Data.Array as A
import Data.Either (isLeft, isRight, Either(..))
import Data.Tuple (Tuple(..))
import Data.Foldable (for_)
import qualified Data.Array as A
import qualified Data.StrMap as M
import Data.Maybe (Maybe(..), fromJust)
import Data.StrMap as M
import Data.Tuple (Tuple(..))

import Data.Argonaut.Core
import Data.Argonaut.Parser
import Data.Argonaut.Printer
import Partial.Unsafe (unsafePartial)

import Test.StrongCheck (assert, (<?>), quickCheck, Result())
import Test.StrongCheck (SC, assert, (<?>), quickCheck, Result())

foreign import thisIsNull :: Json
foreign import thisIsBoolean :: Json
Expand All @@ -26,7 +26,7 @@ foreign import thisIsArray :: Json
foreign import thisIsObject :: Json
foreign import nil :: JNull

isTest :: Eff _ Unit
isTest :: SC () Unit
isTest = do
assert (isNull thisIsNull <?> "Error in null test")
assert (isBoolean thisIsBoolean <?> "Error in boolean test")
Expand All @@ -35,7 +35,7 @@ isTest = do
assert (isArray thisIsArray <?> "Error in array test")
assert (isObject thisIsObject <?> "Error in object test")

foldTest :: Eff _ Unit
foldTest :: SC () Unit
foldTest = do
assert (foldFn thisIsNull == "null" <?> "Error in foldJson null")
assert (foldFn thisIsBoolean == "boolean" <?> "Error in foldJson boolean")
Expand All @@ -44,7 +44,6 @@ foldTest = do
assert (foldFn thisIsArray == "array" <?> "Error in foldJson array")
assert (foldFn thisIsObject == "object" <?> "Error in foldJson object")


foldFn :: Json -> String
foldFn = foldJson
(const "null")
Expand All @@ -55,7 +54,7 @@ foldFn = foldJson
(const "object")

cases :: Array Json
cases =
cases =
[ thisIsNull
, thisIsBoolean
, thisIsNumber
Expand All @@ -64,7 +63,7 @@ cases =
, thisIsObject
]

foldXXX :: Eff _ Unit
foldXXX :: SC () Unit
foldXXX = do
assert ((foldJsonNull "not null" (const "null") <$> cases) ==
["null", "not null", "not null", "not null", "not null", "not null"] <?>
Expand All @@ -88,7 +87,7 @@ foldXXX = do
"Error in foldJsonObject")


fromTest :: Eff _ Unit
fromTest :: SC () Unit
fromTest = do
assert ((foldJsonNull false (const true) (fromNull nil)) <?> "Error in fromNull")
quickCheck (\bool -> foldJsonBoolean Nothing Just (fromBoolean bool) == Just bool <?> "Error in fromBoolean")
Expand All @@ -105,7 +104,7 @@ fromTest = do
in (foldJsonObject Nothing Just (fromObject sm) == Just sm)
<?> "Error in fromObject")

toTest :: Eff _ Unit
toTest :: SC () Unit
toTest = do
assert (assertion toNull thisIsNull "Error in toNull")
assert (assertion toBoolean thisIsBoolean "Error in toBoolean")
Expand All @@ -117,25 +116,25 @@ toTest = do
assertion :: forall a. (Eq a) => (Json -> Maybe a) -> Json -> String -> Result
assertion fn j msg =
let forCases = A.catMaybes (fn <$> cases)
exact = A.singleton $ fromJust $ fn j
exact = A.singleton $ unsafePartial fromJust $ fn j
in forCases == exact <?> msg


parserTest :: Eff _ Unit
parserTest :: SC () Unit
parserTest = do
assert ((isRight (jsonParser "{\"foo\": 1}")) <?> "Error in jsonParser")
assert ((isLeft (jsonParser "\\\ffff")) <?> "Error in jsonParser")

printJsonTest :: Eff _ Unit
printJsonTest :: SC () Unit
printJsonTest = do
for_ cases (assert <<< assertion)
where
assertion :: Json -> Result
assertion j = ((jsonParser (printJson j)) == Right j) <?> "Error in printJson"

main :: Eff _ Unit
main :: SC () Unit
main = do
log "isXxx tests"
log "isXxx tests"
isTest
log "foldJson tests"
foldTest
Expand All @@ -147,5 +146,5 @@ main = do
toTest
log "jsonParser tests"
parserTest
log "printJson tests"
log "printJson tests"
printJsonTest