Skip to content

Commit 58035ea

Browse files
authored
Merge pull request #6 from feramhq/master
Upgrade dependencies for PureScript 0.12
2 parents 52e69a7 + 66b7e99 commit 58035ea

File tree

7 files changed

+79
-56
lines changed

7 files changed

+79
-56
lines changed

bower.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "purescript-yaml-next",
3-
"version": "0.1.0",
43
"moduleType": [
54
"node"
65
],
@@ -14,15 +13,16 @@
1413
],
1514
"dependencies": {
1615
"js-yaml": "^3.4.6",
17-
"purescript-functions": "^3.0.0",
18-
"purescript-foreign": "^4.0.0",
19-
"purescript-foreign-generic": "^4.1.0",
20-
"purescript-unsafe-coerce": "^3.0.0",
21-
"purescript-argonaut-core": "^3.1.0"
16+
"purescript-argonaut-core": "^4.0.1",
17+
"purescript-foreign": "^5.0.0",
18+
"purescript-foreign-generic": "^7.0.0",
19+
"purescript-functions": "^4.0.0",
20+
"purescript-ordered-collections": "^1.1.0",
21+
"purescript-unsafe-coerce": "^4.0.0"
2222
},
2323
"devDependencies": {
24-
"purescript-console": "^3.0.0",
25-
"purescript-spec": "^1.0.0",
26-
"purescript-argonaut-codecs": "^3.0.1"
24+
"purescript-argonaut-codecs": "^4.0.2",
25+
"purescript-console": "^4.1.0",
26+
"purescript-spec": "^3.0.0"
2727
}
2828
}

package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
"license": "SEE LICENSE FILE",
44
"repository": "",
55
"private": true,
6-
"contributors": [ ],
6+
"contributors": [],
77
"main": "main.js",
88
"scripts": {
99
"postinstall": "bower install",
1010
"build": "pulp build"
1111
},
12-
"devDependencies": {
13-
},
12+
"devDependencies": {},
1413
"dependencies": {
15-
"js-yaml": "^3.4.6"
14+
"js-yaml": "^3.12.0"
1615
}
1716
}

src/Data/YAML/Foreign/Decode.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module Data.YAML.Foreign.Decode (
33
parseYAMLToJson
44
) where
55

6-
import Data.Foreign (F, Foreign, ForeignError(..), fail)
7-
import Data.Foreign.Generic (genericDecode)
8-
import Data.Foreign.Generic.Class (class GenericDecode)
9-
import Data.Foreign.Generic.Types (Options)
6+
import Foreign (F, Foreign, ForeignError(..), fail)
7+
import Foreign.Generic (genericDecode)
8+
import Foreign.Generic.Class (class GenericDecode)
9+
import Foreign.Generic.Types (Options)
1010
import Data.Function.Uncurried (Fn3, runFn3)
1111
import Data.Generic.Rep (class Generic)
1212
import Prelude ((>=>), (<<<), pure, (>>=))
@@ -17,7 +17,7 @@ foreign import parseYAMLImpl :: forall r. Fn3 (String -> r) (Foreign -> r) Strin
1717

1818
-- | Attempt to parse a YAML string, returning the result as foreign data.
1919
parseYAML :: String -> F Foreign
20-
parseYAML yaml = runFn3 parseYAMLImpl (fail <<< JSONError) pure yaml
20+
parseYAML yaml = runFn3 parseYAMLImpl (fail <<< ForeignError) pure yaml
2121

2222
-- | Attempt to parse a YAML string, returning the result as Json
2323
parseYAMLToJson :: String -> F Json

src/Data/YAML/Foreign/Encode.purs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ module Data.YAML.Foreign.Encode (
99

1010
import Data.Map as M
1111
import Data.Map (Map)
12-
import Data.StrMap as StrMap
13-
import Data.StrMap (StrMap)
1412
import Data.Array (toUnfoldable)
1513
import Data.Function.Uncurried (Fn4, runFn4)
1614
import Data.List (List)
@@ -54,11 +52,8 @@ instance eqYValue :: Eq YValue where
5452
class ToYAML a where
5553
toYAML :: a -> YValue
5654

57-
instance strMapToYAML :: (ToYAML a) => ToYAML (StrMap a) where
58-
toYAML strMap = YObject $ StrMap.fold (\acc key value -> M.insert key (toYAML value) acc) M.empty strMap
59-
6055
instance mapToYAML :: (ToYAML a) => ToYAML (Map String a) where
61-
toYAML m = YObject $ M.mapWithKey (\key value -> toYAML value) m
56+
toYAML m = YObject $ map (\value -> toYAML value) m
6257

6358
instance booleanToYAML :: ToYAML Boolean where
6459
toYAML = YBoolean

test/Instances.purs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import Data.Argonaut.Core (toObject, toString)
55
import Data.Argonaut.Decode (getField)
66
import Data.Argonaut.Decode.Class (class DecodeJson)
77
import Data.Either (Either(..))
8-
import Data.Generic (class Generic, gShow, gEq)
8+
import Data.Generic.Rep (class Generic)
9+
import Data.Generic.Rep.Eq (genericEq)
10+
import Data.Generic.Rep.Show (genericShow)
911
import Data.Maybe (maybe)
1012
import Prelude (class Eq, class Show, bind, pure, ($))
1113

@@ -23,17 +25,17 @@ data GeoObject = GeoObject
2325
, coverage :: Number
2426
}
2527

26-
derive instance genericGeoObject :: Generic GeoObject
27-
instance showGeoObject :: Show GeoObject where show = gShow
28-
instance eqGeoObject :: Eq GeoObject where eq = gEq
28+
derive instance genericGeoObject :: Generic GeoObject _
29+
instance showGeoObject :: Show GeoObject where show = genericShow
30+
instance eqGeoObject :: Eq GeoObject where eq = genericEq
2931

30-
derive instance genericPoint :: Generic Point
31-
instance showPoint :: Show Point where show = gShow
32-
instance eqPoint :: Eq Point where eq = gEq
32+
derive instance genericPoint :: Generic Point _
33+
instance showPoint :: Show Point where show = genericShow
34+
instance eqPoint :: Eq Point where eq = genericEq
3335

34-
derive instance genericMobility :: Generic Mobility
35-
instance showMobility :: Show Mobility where show = gShow
36-
instance eqMobility :: Eq Mobility where eq = gEq
36+
derive instance genericMobility :: Generic Mobility _
37+
instance showMobility :: Show Mobility where show = genericShow
38+
instance eqMobility :: Eq Mobility where eq = genericEq
3739

3840
instance geoJson :: DecodeJson GeoObject where
3941
decodeJson s = do

test/Main.purs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
module Test.Main where
22

33
import Data.Map as Map
4-
import Data.StrMap as StrMap
5-
import Control.Monad.Eff (Eff)
64
import Control.Monad.Except (runExcept)
75
import Data.Argonaut.Decode (class DecodeJson, decodeJson)
86
import Data.Either (Either(..))
97
import Data.Map (Map)
10-
import Data.StrMap (StrMap)
118
import Data.YAML.Foreign.Decode (parseYAMLToJson)
129
import Data.YAML.Foreign.Encode (printYAML)
10+
import Effect
1311
import Prelude (Unit, discard, pure, ($), (<<<), (>>=))
1412
import Test.Instances (GeoObject(..), Mobility(..), Point(..))
1513
import Test.Spec (describe, it)
1614
import Test.Spec.Assertions (shouldEqual)
1715
import Test.Spec.Reporter.Console (consoleReporter)
18-
import Test.Spec.Runner (RunnerEffects, run)
16+
import Test.Spec.Runner (run)
1917

2018
yamlInput :: String
2119
yamlInput = """
@@ -45,54 +43,54 @@ yamlInput = """
4543
"""
4644

4745
yamlOutput :: String
48-
yamlOutput = """- Mobility: Fix
46+
yamlOutput = """- Coverage: 10
47+
Mobility: Fix
48+
Name: House
4949
Points:
5050
- X: 10
5151
Y: 10
5252
- X: 20
5353
Y: 10
5454
- X: 5
5555
Y: 5
56-
Coverage: 10
57-
Name: House
5856
Scale: 9.5
59-
- Mobility: Fix
57+
- Coverage: 10
58+
Mobility: Fix
59+
Name: Tree
6060
Points:
6161
- X: 1
6262
Y: 1
6363
- X: 2
6464
Y: 2
6565
- X: 0
6666
Y: 0
67-
Coverage: 10
68-
Name: Tree
6967
Scale: 1
7068
"""
7169

7270

7371
yamlMapOutput :: String
7472
yamlMapOutput = """key:
75-
- Mobility: Fix
73+
- Coverage: 10
74+
Mobility: Fix
75+
Name: House
7676
Points:
7777
- X: 10
7878
Y: 10
7979
- X: 20
8080
Y: 10
8181
- X: 5
8282
Y: 5
83-
Coverage: 10
84-
Name: House
8583
Scale: 9.5
86-
- Mobility: Fix
84+
- Coverage: 10
85+
Mobility: Fix
86+
Name: Tree
8787
Points:
8888
- X: 1
8989
Y: 1
9090
- X: 2
9191
Y: 2
9292
- X: 0
9393
Y: 0
94-
Coverage: 10
95-
Name: Tree
9694
Scale: 1
9795
"""
9896

@@ -106,8 +104,6 @@ yamlToData s = case runExcept $ parseYAMLToJson s of
106104
Left err -> Left "Could not parse yaml"
107105
Right json -> decodeJson json
108106

109-
testStrMap :: StrMap (Array GeoObject)
110-
testStrMap = StrMap.singleton "key" parsedData
111107

112108
testMap :: Map String (Array GeoObject)
113109
testMap = Map.singleton "key" parsedData
@@ -137,7 +133,7 @@ readPoint = yamlToData
137133
fullCircle :: String -> Either String String
138134
fullCircle yamlString = (readPoint yamlString) >>= pure <<< printYAML
139135

140-
main :: Eff (RunnerEffects ()) Unit
136+
main :: Effect Unit
141137
main = run [consoleReporter] do
142138
describe "purescript-yaml" do
143139
describe "decode" do
@@ -149,9 +145,6 @@ main = run [consoleReporter] do
149145
let encoded = printYAML parsedData
150146
encoded `shouldEqual` yamlOutput
151147

152-
let encodedStrMap = printYAML testStrMap
153-
encodedStrMap `shouldEqual` yamlMapOutput
154-
155148
let encodedMap = printYAML testMap
156149
encodedMap `shouldEqual` yamlMapOutput
157150

0 commit comments

Comments
 (0)