Skip to content

Commit b73e22f

Browse files
authored
Merge pull request #46 from purescript/bump
Prepare for 2.0 release
2 parents 6dfb111 + 910caae commit b73e22f

File tree

15 files changed

+98
-65
lines changed

15 files changed

+98
-65
lines changed

bower.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"purescript-foldable-traversable": "^2.0.0",
2727
"purescript-functions": "^2.0.0",
2828
"purescript-integers": "^2.0.0",
29-
"purescript-strings": "^2.0.0"
29+
"purescript-lists": "^2.1.0",
30+
"purescript-strings": "^2.0.0",
31+
"purescript-transformers": "^2.0.0"
3032
},
3133
"devDependencies": {
3234
"purescript-console": "^2.0.0"

examples/Applicative.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, logShow)
7+
import Control.Monad.Except (runExcept)
78

89
import Data.Foreign (F)
910
import Data.Foreign.Class (class IsForeign, readJSON, readProp)
@@ -19,5 +20,5 @@ instance pointIsForeign :: IsForeign Point where
1920
<*> readProp "z" value
2021

2122
main :: Eff (console :: CONSOLE) Unit
22-
main = logShow $
23+
main = logShow $ runExcept $
2324
readJSON """{ "x": 1, "y": 2, "z": 3 }""" :: F Point

examples/Complex.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, logShow)
7+
import Control.Monad.Except (runExcept)
78

89
import Data.Foreign (F)
910
import Data.Foreign.Class (class IsForeign, readJSON, readProp)
@@ -52,4 +53,4 @@ instance listItemIsForeign :: IsForeign ListItem where
5253
main :: Eff (console :: CONSOLE) Unit
5354
main = do
5455
let json = """{"foo":"hello","bar":true,"baz":1,"list":[{"x":1,"y":2},{"x":3,"y":4,"z":999}]}"""
55-
logShow $ readJSON json :: F SomeObject
56+
logShow $ runExcept $ readJSON json :: F SomeObject

examples/Either.purs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
module Examples.Either where
22

33
import Prelude
4+
45
import Control.Monad.Eff (Eff)
5-
import Data.Either (Either)
6+
import Control.Monad.Eff.Console (logShow, CONSOLE)
7+
import Control.Monad.Except (runExcept)
68

9+
import Data.Either (Either)
710
import Data.Foreign (F, parseJSON)
811
import Data.Foreign.Class (class IsForeign, readEitherR, readProp)
912

10-
import Control.Monad.Eff.Console (logShow, CONSOLE)
11-
1213
data Point = Point Number Number Number
1314

1415
instance showPoint :: Show Point where
@@ -23,10 +24,10 @@ type Response = Either (Array String) Point
2324

2425
main :: forall eff. Eff (console :: CONSOLE | eff) Unit
2526
main = do
26-
logShow do
27+
logShow $ runExcept do
2728
json <- parseJSON """{ "x":1, "y": 2, "z": 3}"""
2829
readEitherR json :: F Response
2930

30-
logShow do
31+
logShow $ runExcept do
3132
json <- parseJSON """["Invalid parse", "Not a valid y point"]"""
3233
readEitherR json :: F Response

examples/JSONArrays.purs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, logShow)
7+
import Control.Monad.Except (runExcept)
78

89
import Data.Foreign (F)
910
import Data.Foreign.Class (readJSON)
1011

1112
main :: Eff (console :: CONSOLE) Unit
1213
main = do
13-
logShow $ readJSON """["hello", "world"]""" :: F (Array String)
14-
logShow $ readJSON """[1, 2, 3, 4]""" :: F (Array Number)
14+
logShow $ runExcept $ readJSON """["hello", "world"]""" :: F (Array String)
15+
logShow $ runExcept $ readJSON """[1, 2, 3, 4]""" :: F (Array Number)

examples/JSONSimpleTypes.purs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, log, logShow)
7+
import Control.Monad.Except (runExcept)
78

89
import Data.Foreign (F, unsafeFromForeign)
910
import Data.Foreign.Class (readJSON, write)
@@ -12,9 +13,9 @@ import Data.Foreign.Class (readJSON, write)
1213
-- out of the box.
1314
main :: Eff (console :: CONSOLE) Unit
1415
main = do
15-
logShow $ readJSON "\"a JSON string\"" :: F String
16-
logShow $ readJSON "42" :: F Number
17-
logShow $ readJSON "true" :: F Boolean
16+
logShow $ runExcept $ readJSON "\"a JSON string\"" :: F String
17+
logShow $ runExcept $ readJSON "42" :: F Number
18+
logShow $ runExcept $ readJSON "true" :: F Boolean
1819
log $ unsafeFromForeign $ write "a JSON string"
1920
log $ unsafeFromForeign $ write 42.0
2021
log $ unsafeFromForeign $ write true

examples/MaybeNullable.purs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, log, logShow)
7+
import Control.Monad.Except (runExcept)
78

89
import Data.Foreign (F, unsafeFromForeign)
910
import Data.Foreign.Class (readJSON, write)
@@ -14,7 +15,7 @@ import Data.Maybe (Maybe(..))
1415
-- using Maybe types.
1516
main :: Eff (console :: CONSOLE) Unit
1617
main = do
17-
logShow $ unNull <$> readJSON "null" :: F (Null Boolean)
18-
logShow $ unNull <$> readJSON "true" :: F (Null Boolean)
18+
logShow $ unNull <$> runExcept (readJSON "null" :: F (Null Boolean))
19+
logShow $ unNull <$> runExcept (readJSON "true" :: F (Null Boolean))
1920
log $ unsafeFromForeign $ write $ Null Nothing :: Null Boolean
2021
log $ unsafeFromForeign $ write $ Null $ Just true

examples/Nested.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, logShow)
7+
import Control.Monad.Except (runExcept)
78

89
import Data.Foreign (F)
910
import Data.Foreign.Class (class IsForeign, readJSON, readProp)
@@ -32,4 +33,4 @@ instance fooIsForeign :: IsForeign Foo where
3233

3334
main :: Eff (console :: CONSOLE) Unit
3435
main = do
35-
logShow $ readJSON """{ "foo": { "bar": "bar", "baz": 1 } }""" :: F Foo
36+
logShow $ runExcept $ readJSON """{ "foo": { "bar": "bar", "baz": 1 } }""" :: F Foo

examples/Objects.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, log, logShow)
7+
import Control.Monad.Except (runExcept)
78

89
import Data.Foreign (F, writeObject, unsafeFromForeign)
910
import Data.Foreign.Class (class AsForeign, class IsForeign, (.=), readJSON, readProp, write)
@@ -31,5 +32,5 @@ instance pointIsForeign :: IsForeign Point where
3132

3233
main :: Eff (console :: CONSOLE) Unit
3334
main = do
34-
logShow $ readJSON """{ "x": 1, "y": 2 }""" :: F Point
35+
logShow $ runExcept $ readJSON """{ "x": 1, "y": 2 }""" :: F Point
3536
log $ unsafeFromForeign $ write $ Point { x: 1.0, y: 2.0 }

examples/ParseErrors.purs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Prelude
44

55
import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, logShow)
7+
import Control.Monad.Except (runExcept)
78

89
import Data.Foreign (F)
910
import Data.Foreign.Class (class IsForeign, readJSON, readProp)
@@ -26,15 +27,15 @@ main = do
2627

2728
-- When trying to parse invalid JSON we catch an exception from
2829
-- `JSON.parse` and pass it on.
29-
logShow $ readJSON "not even JSON" :: F String
30+
logShow $ runExcept $ readJSON "not even JSON" :: F String
3031

3132
-- When attempting to coerce one type to another we get an error.
32-
logShow $ readJSON "26" :: F Boolean
33+
logShow $ runExcept $ readJSON "26" :: F Boolean
3334

3435
-- When parsing fails in an array, we're told at which index the value that
3536
-- failed to parse was, along with the reason the value didn't parse.
36-
logShow $ readJSON "[1, true, 3]" :: F (Array Boolean)
37+
logShow $ runExcept $ readJSON "[1, true, 3]" :: F (Array Boolean)
3738

3839
-- When parsing fails in an object, we're the name of the property which
3940
-- failed to parse was, along with the reason the value didn't parse.
40-
logShow $ readJSON """{ "x": 1, "y": false }""" :: F Point
41+
logShow $ runExcept $ readJSON """{ "x": 1, "y": false }""" :: F Point

0 commit comments

Comments
 (0)