Skip to content

Commit

Permalink
Fix Booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
paf31 committed Aug 18, 2015
1 parent 8ffa513 commit 3c6a761
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"dependencies": {
"purescript-console": "^0.1.0",
"purescript-foreign": "~0.7.0",
"purescript-generics": "~0.4.0"
"purescript-generics": "^0.5.0"
}
}
3 changes: 2 additions & 1 deletion src/Data/Foreign/Generic.purs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ readGeneric = map (fromJust <<< fromSpine) <<< go (toSignature (anyProxy :: Prox
go SigNumber f = map SNumber (readNumber f)
go SigInt f = map SInt (readInt f)
go SigString f = map SString (readString f)
go SigBoolean f = map SBoolean (readBoolean f)
go (SigArray el) f = do arr <- readArray f
els <- for arr \f -> do
e <- go (el unit) f
Expand All @@ -46,4 +47,4 @@ readGeneric = map (fromJust <<< fromSpine) <<< go (toSignature (anyProxy :: Prox

-- | Read a value which has a `Generic` type from a JSON String
readJSONGeneric :: forall a. (Generic a) => String -> F a
readJSONGeneric = parseJSON >=> readGeneric
readJSONGeneric = parseJSON >=> readGeneric
6 changes: 3 additions & 3 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ json = """
{
"tag": "Leaf",
"values": [
1
true
]
},
{
"tag": "Leaf",
"values": [
2
false
]
}
]
Expand All @@ -39,6 +39,6 @@ readTree :: forall a. (Generic a) => String -> F (Tree a)
readTree = readJSONGeneric

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

0 comments on commit 3c6a761

Please sign in to comment.