Skip to content

Commit 3c6a761

Browse files
committed
Fix Booleans
1 parent 8ffa513 commit 3c6a761

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"dependencies": {
1414
"purescript-console": "^0.1.0",
1515
"purescript-foreign": "~0.7.0",
16-
"purescript-generics": "~0.4.0"
16+
"purescript-generics": "^0.5.0"
1717
}
1818
}

src/Data/Foreign/Generic.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ readGeneric = map (fromJust <<< fromSpine) <<< go (toSignature (anyProxy :: Prox
2626
go SigNumber f = map SNumber (readNumber f)
2727
go SigInt f = map SInt (readInt f)
2828
go SigString f = map SString (readString f)
29+
go SigBoolean f = map SBoolean (readBoolean f)
2930
go (SigArray el) f = do arr <- readArray f
3031
els <- for arr \f -> do
3132
e <- go (el unit) f
@@ -46,4 +47,4 @@ readGeneric = map (fromJust <<< fromSpine) <<< go (toSignature (anyProxy :: Prox
4647

4748
-- | Read a value which has a `Generic` type from a JSON String
4849
readJSONGeneric :: forall a. (Generic a) => String -> F a
49-
readJSONGeneric = parseJSON >=> readGeneric
50+
readJSONGeneric = parseJSON >=> readGeneric

test/Main.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ json = """
2121
{
2222
"tag": "Leaf",
2323
"values": [
24-
1
24+
true
2525
]
2626
},
2727
{
2828
"tag": "Leaf",
2929
"values": [
30-
2
30+
false
3131
]
3232
}
3333
]
@@ -39,6 +39,6 @@ readTree :: forall a. (Generic a) => String -> F (Tree a)
3939
readTree = readJSONGeneric
4040

4141
main = do
42-
case readTree json :: F (Tree Int) of
42+
case readTree json :: F (Tree Boolean) of
4343
Right tree -> log (gShow tree)
4444
Left err -> print err

0 commit comments

Comments
 (0)