File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 18
18
"purescript-control" : " ~0.2.1" ,
19
19
"purescript-lens" : " ~0.7.0" ,
20
20
"purescript-optic" : " ~0.5.0" ,
21
- "purescript-index" : " ~0.3.0"
21
+ "purescript-index" : " ~0.3.0" ,
22
+ "purescript-integers" : " ~0.1.0"
22
23
},
23
24
"devDependencies" : {
24
25
"purescript-strongcheck" : " ~0.9.0"
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ module Data.Argonaut.Decode
32
32
)
33
33
import Data.Argonaut.Encode (encodeJson , EncodeJson )
34
34
import Data.Either (either , Either (..))
35
+ import Data.Int (Int (), fromNumber )
35
36
import Data.Maybe (maybe , Maybe (..))
36
37
import Data.Foldable (Foldable , foldl , foldMap , foldr )
37
38
import Data.Traversable (Traversable , traverse )
@@ -66,6 +67,9 @@ module Data.Argonaut.Decode
66
67
instance decodeJsonNumber :: DecodeJson Number where
67
68
decodeJson = foldJsonNumber (Left "Not a Number .") Right
68
69
70
+ instance decodeJsonInt :: DecodeJson Int where
71
+ decodeJson = foldJsonNumber (Left "Not a Number .") (Right <<< fromNumber )
72
+
69
73
instance decodeJsonString :: DecodeJson String where
70
74
decodeJson = foldJsonString (Left "Not a String .") Right
71
75
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ module Data.Argonaut.Encode
20
20
import Data.Char
21
21
import Data.Maybe
22
22
import Data.Either
23
+ import Data.Int (Int (), toNumber )
23
24
import Data.Foldable (foldr )
24
25
import Data.Tuple (Tuple (..))
25
26
@@ -49,6 +50,9 @@ module Data.Argonaut.Encode
49
50
instance encodeJsonJNumber :: EncodeJson Number where
50
51
encodeJson = fromNumber
51
52
53
+ instance encodeJsonInt :: EncodeJson Int where
54
+ encodeJson = fromNumber <<< toNumber
55
+
52
56
instance encodeJsonJString :: EncodeJson String where
53
57
encodeJson = fromString
54
58
@@ -65,4 +69,4 @@ module Data.Argonaut.Encode
65
69
encodeJson m = fromObject (encodeJson <$> m )
66
70
67
71
instance encodeMap :: (Ord a , EncodeJson a , EncodeJson b ) => EncodeJson (Map.Map a b ) where
68
- encodeJson = encodeJson <<< Map. toList
72
+ encodeJson = encodeJson <<< Map. toList
Original file line number Diff line number Diff line change @@ -506,6 +506,13 @@ instance decodeJsonNumber :: DecodeJson Number
506
506
```
507
507
508
508
509
+ #### ` decodeJsonInt `
510
+
511
+ ``` purescript
512
+ instance decodeJsonInt :: DecodeJson Int
513
+ ```
514
+
515
+
509
516
#### ` decodeJsonString `
510
517
511
518
``` purescript
@@ -629,6 +636,13 @@ instance encodeJsonJNumber :: EncodeJson Number
629
636
```
630
637
631
638
639
+ #### ` encodeJsonInt `
640
+
641
+ ``` purescript
642
+ instance encodeJsonInt :: EncodeJson Int
643
+ ```
644
+
645
+
632
646
#### ` encodeJsonJString `
633
647
634
648
``` purescript
You can’t perform that action at this time.
0 commit comments