Skip to content

Simplify genJCursor, update deps #17

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 2 commits into from
Jun 7, 2018
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
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
},
"license": "MIT",
"dependencies": {
"purescript-argonaut-core": "#compiler/0.12",
"purescript-argonaut-codecs": "#compiler/0.12",
"purescript-profunctor-lenses": "#compiler/0.12"
"purescript-argonaut-core": "^4.0.0",
"purescript-argonaut-codecs": "^4.0.0",
"purescript-profunctor-lenses": "^4.0.0"
},
"devDependencies": {
"purescript-strongcheck": "#compiler/0.12"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"test": "pulp test"
},
"devDependencies": {
"pulp": "^12.0.1",
"pulp": "^12.2.0",
"purescript": "^0.12.0",
"purescript-psa": "^0.6.0",
"purescript": "^0.11.1",
"rimraf": "^2.5.4"
"rimraf": "^2.6.2"
}
}
7 changes: 2 additions & 5 deletions src/Data/Argonaut/JCursor/Gen.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ import Control.Monad.Gen as Gen
import Control.Monad.Rec.Class (class MonadRec)

import Data.Argonaut.JCursor (JCursor(..))
import Data.Char as C
import Data.String as S
import Data.String.Gen (genUnicodeString)

genJCursor :: forall m. MonadGen m => MonadRec m => Lazy (m JCursor) => m JCursor
genJCursor = Gen.resize (min 10) $ Gen.sized genJCursor'
where
genJCursor' size
| size > 0 = Gen.resize (_ - 1) (Gen.choose genField genIndex)
| otherwise = pure JCursorTop
genField = JField <$> genString <*> defer \_ -> genJCursor
genField = JField <$> genUnicodeString <*> defer \_ -> genJCursor
genIndex = JIndex <$> Gen.chooseInt 0 1000 <*> defer \_ -> genJCursor
genString = S.fromCharArray <$> Gen.unfoldable genChar
genChar = C.fromCharCode <$> Gen.chooseInt 0 65535