Skip to content

Commit

Permalink
Merge branch 'master' into add-datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
f-f authored Jul 3, 2024
2 parents d5f83d5 + b55c8bb commit e2a4cbf
Show file tree
Hide file tree
Showing 14 changed files with 727 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable

- name: Setup PureScript dependencies
run: npm i --global [email protected] spago@next purescm@next
run: npm i --global [email protected] spago@next purescm@latest

- name: Build source
run: spago build
Expand Down
18 changes: 18 additions & 0 deletions json/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package:
name: json
dependencies:
- prelude
- arrays
- functions
- integers
- maybe
- either
- tuples
- foldable-traversable
- gen
- strings
- unfoldable
test:
main: Test.JSON.Main
dependencies:
- assert
2 changes: 1 addition & 1 deletion json/src/JSON.purs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Data.Function.Uncurried (runFn2, runFn3, runFn7)
import Data.Int as Int
import Data.Maybe (Maybe(..))
import JSON.Internal (JArray, JObject, JSON)
import JSON.Internal (JArray, JObject, JSON) as Exports
import JSON.Internal (JArray, JObject, JSON, isNull) as Exports
import JSON.Internal as Internal

-- | Attempts to parse a string as a JSON value. If parsing fails, an error message detailing the
Expand Down
31 changes: 31 additions & 0 deletions json/src/JSON.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(library (JSON foreign)
(export _null
fromBoolean
fromInt
fromString
fromJArray
fromJObject
print
printIndented)
(import (chezscheme)
(only (JSON.Internal foreign) json-stringify))

(define (coerce x) x)

(define _null 'null)

(define fromBoolean coerce)

(define fromInt inexact)

(define fromString coerce)

(define fromJArray coerce)

(define fromJObject coerce)

(define print json-stringify)

(define printIndented json-stringify)

)
9 changes: 9 additions & 0 deletions json/src/JSON/Array.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(library (JSON.Array foreign)
(export singleton)
(import (chezscheme)
(prefix (purs runtime srfi :214) srfi:214:))

(define (singleton x) (srfi:214:flexvector x))

)

2 changes: 2 additions & 0 deletions json/src/JSON/Internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ export const _index = (nothing, just, ix, arr) =>
ix >= 0 && ix < arr.length ? just(arr[ix]) : nothing;

export const _append = (xs, ys) => xs.concat(ys);

export const isNull = (json) => json == null;
2 changes: 2 additions & 0 deletions json/src/JSON/Internal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,5 @@ foreign import _append
JArray
JArray
JArray

foreign import isNull :: JSON -> Boolean
Loading

0 comments on commit e2a4cbf

Please sign in to comment.