Upgrade dependencies for PureScript 0.12

This commit is contained in:
Adrian Sieber 2018-09-08 20:46:12 +00:00
parent 52e69a74ef
commit de0d8c15b5
7 changed files with 79 additions and 55 deletions

View File

@ -14,15 +14,16 @@
], ],
"dependencies": { "dependencies": {
"js-yaml": "^3.4.6", "js-yaml": "^3.4.6",
"purescript-functions": "^3.0.0", "purescript-argonaut-core": "^4.0.1",
"purescript-foreign": "^4.0.0", "purescript-foreign": "^5.0.0",
"purescript-foreign-generic": "^4.1.0", "purescript-foreign-generic": "^7.0.0",
"purescript-unsafe-coerce": "^3.0.0", "purescript-functions": "^4.0.0",
"purescript-argonaut-core": "^3.1.0" "purescript-ordered-collections": "^1.1.0",
"purescript-unsafe-coerce": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"purescript-console": "^3.0.0", "purescript-argonaut-codecs": "^4.0.2",
"purescript-spec": "^1.0.0", "purescript-console": "^4.1.0",
"purescript-argonaut-codecs": "^3.0.1" "purescript-spec": "^3.0.0"
} }
} }

34
package-lock.json generated Normal file
View File

@ -0,0 +1,34 @@
{
"name": "purescript-yaml-next",
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"requires": {
"sprintf-js": "1.0.3"
}
},
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
},
"js-yaml": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
"requires": {
"argparse": "1.0.10",
"esprima": "4.0.1"
}
},
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
}
}
}

View File

@ -3,15 +3,14 @@
"license": "SEE LICENSE FILE", "license": "SEE LICENSE FILE",
"repository": "", "repository": "",
"private": true, "private": true,
"contributors": [ ], "contributors": [],
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"postinstall": "bower install", "postinstall": "bower install",
"build": "pulp build" "build": "pulp build"
}, },
"devDependencies": { "devDependencies": {},
},
"dependencies": { "dependencies": {
"js-yaml": "^3.4.6" "js-yaml": "^3.12.0"
} }
} }

View File

@ -3,10 +3,10 @@ module Data.YAML.Foreign.Decode (
parseYAMLToJson parseYAMLToJson
) where ) where
import Data.Foreign (F, Foreign, ForeignError(..), fail) import Foreign (F, Foreign, ForeignError(..), fail)
import Data.Foreign.Generic (genericDecode) import Foreign.Generic (genericDecode)
import Data.Foreign.Generic.Class (class GenericDecode) import Foreign.Generic.Class (class GenericDecode)
import Data.Foreign.Generic.Types (Options) import Foreign.Generic.Types (Options)
import Data.Function.Uncurried (Fn3, runFn3) import Data.Function.Uncurried (Fn3, runFn3)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Prelude ((>=>), (<<<), pure, (>>=)) import Prelude ((>=>), (<<<), pure, (>>=))
@ -17,7 +17,7 @@ foreign import parseYAMLImpl :: forall r. Fn3 (String -> r) (Foreign -> r) Strin
-- | Attempt to parse a YAML string, returning the result as foreign data. -- | Attempt to parse a YAML string, returning the result as foreign data.
parseYAML :: String -> F Foreign parseYAML :: String -> F Foreign
parseYAML yaml = runFn3 parseYAMLImpl (fail <<< JSONError) pure yaml parseYAML yaml = runFn3 parseYAMLImpl (fail <<< ForeignError) pure yaml
-- | Attempt to parse a YAML string, returning the result as Json -- | Attempt to parse a YAML string, returning the result as Json
parseYAMLToJson :: String -> F Json parseYAMLToJson :: String -> F Json

View File

@ -9,8 +9,6 @@ module Data.YAML.Foreign.Encode (
import Data.Map as M import Data.Map as M
import Data.Map (Map) import Data.Map (Map)
import Data.StrMap as StrMap
import Data.StrMap (StrMap)
import Data.Array (toUnfoldable) import Data.Array (toUnfoldable)
import Data.Function.Uncurried (Fn4, runFn4) import Data.Function.Uncurried (Fn4, runFn4)
import Data.List (List) import Data.List (List)
@ -54,11 +52,8 @@ instance eqYValue :: Eq YValue where
class ToYAML a where class ToYAML a where
toYAML :: a -> YValue toYAML :: a -> YValue
instance strMapToYAML :: (ToYAML a) => ToYAML (StrMap a) where
toYAML strMap = YObject $ StrMap.fold (\acc key value -> M.insert key (toYAML value) acc) M.empty strMap
instance mapToYAML :: (ToYAML a) => ToYAML (Map String a) where instance mapToYAML :: (ToYAML a) => ToYAML (Map String a) where
toYAML m = YObject $ M.mapWithKey (\key value -> toYAML value) m toYAML m = YObject $ map (\value -> toYAML value) m
instance booleanToYAML :: ToYAML Boolean where instance booleanToYAML :: ToYAML Boolean where
toYAML = YBoolean toYAML = YBoolean

View File

@ -5,7 +5,9 @@ import Data.Argonaut.Core (toObject, toString)
import Data.Argonaut.Decode (getField) import Data.Argonaut.Decode (getField)
import Data.Argonaut.Decode.Class (class DecodeJson) import Data.Argonaut.Decode.Class (class DecodeJson)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Generic (class Generic, gShow, gEq) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (maybe) import Data.Maybe (maybe)
import Prelude (class Eq, class Show, bind, pure, ($)) import Prelude (class Eq, class Show, bind, pure, ($))
@ -23,17 +25,17 @@ data GeoObject = GeoObject
, coverage :: Number , coverage :: Number
} }
derive instance genericGeoObject :: Generic GeoObject derive instance genericGeoObject :: Generic GeoObject _
instance showGeoObject :: Show GeoObject where show = gShow instance showGeoObject :: Show GeoObject where show = genericShow
instance eqGeoObject :: Eq GeoObject where eq = gEq instance eqGeoObject :: Eq GeoObject where eq = genericEq
derive instance genericPoint :: Generic Point derive instance genericPoint :: Generic Point _
instance showPoint :: Show Point where show = gShow instance showPoint :: Show Point where show = genericShow
instance eqPoint :: Eq Point where eq = gEq instance eqPoint :: Eq Point where eq = genericEq
derive instance genericMobility :: Generic Mobility derive instance genericMobility :: Generic Mobility _
instance showMobility :: Show Mobility where show = gShow instance showMobility :: Show Mobility where show = genericShow
instance eqMobility :: Eq Mobility where eq = gEq instance eqMobility :: Eq Mobility where eq = genericEq
instance geoJson :: DecodeJson GeoObject where instance geoJson :: DecodeJson GeoObject where
decodeJson s = do decodeJson s = do

View File

@ -1,21 +1,19 @@
module Test.Main where module Test.Main where
import Data.Map as Map import Data.Map as Map
import Data.StrMap as StrMap
import Control.Monad.Eff (Eff)
import Control.Monad.Except (runExcept) import Control.Monad.Except (runExcept)
import Data.Argonaut.Decode (class DecodeJson, decodeJson) import Data.Argonaut.Decode (class DecodeJson, decodeJson)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Map (Map) import Data.Map (Map)
import Data.StrMap (StrMap)
import Data.YAML.Foreign.Decode (parseYAMLToJson) import Data.YAML.Foreign.Decode (parseYAMLToJson)
import Data.YAML.Foreign.Encode (printYAML) import Data.YAML.Foreign.Encode (printYAML)
import Effect
import Prelude (Unit, discard, pure, ($), (<<<), (>>=)) import Prelude (Unit, discard, pure, ($), (<<<), (>>=))
import Test.Instances (GeoObject(..), Mobility(..), Point(..)) import Test.Instances (GeoObject(..), Mobility(..), Point(..))
import Test.Spec (describe, it) import Test.Spec (describe, it)
import Test.Spec.Assertions (shouldEqual) import Test.Spec.Assertions (shouldEqual)
import Test.Spec.Reporter.Console (consoleReporter) import Test.Spec.Reporter.Console (consoleReporter)
import Test.Spec.Runner (RunnerEffects, run) import Test.Spec.Runner (run)
yamlInput :: String yamlInput :: String
yamlInput = """ yamlInput = """
@ -45,7 +43,9 @@ yamlInput = """
""" """
yamlOutput :: String yamlOutput :: String
yamlOutput = """- Mobility: Fix yamlOutput = """- Coverage: 10
Mobility: Fix
Name: House
Points: Points:
- X: 10 - X: 10
Y: 10 Y: 10
@ -53,10 +53,10 @@ yamlOutput = """- Mobility: Fix
Y: 10 Y: 10
- X: 5 - X: 5
Y: 5 Y: 5
Coverage: 10
Name: House
Scale: 9.5 Scale: 9.5
- Mobility: Fix - Coverage: 10
Mobility: Fix
Name: Tree
Points: Points:
- X: 1 - X: 1
Y: 1 Y: 1
@ -64,15 +64,15 @@ yamlOutput = """- Mobility: Fix
Y: 2 Y: 2
- X: 0 - X: 0
Y: 0 Y: 0
Coverage: 10
Name: Tree
Scale: 1 Scale: 1
""" """
yamlMapOutput :: String yamlMapOutput :: String
yamlMapOutput = """key: yamlMapOutput = """key:
- Mobility: Fix - Coverage: 10
Mobility: Fix
Name: House
Points: Points:
- X: 10 - X: 10
Y: 10 Y: 10
@ -80,10 +80,10 @@ yamlMapOutput = """key:
Y: 10 Y: 10
- X: 5 - X: 5
Y: 5 Y: 5
Coverage: 10
Name: House
Scale: 9.5 Scale: 9.5
- Mobility: Fix - Coverage: 10
Mobility: Fix
Name: Tree
Points: Points:
- X: 1 - X: 1
Y: 1 Y: 1
@ -91,8 +91,6 @@ yamlMapOutput = """key:
Y: 2 Y: 2
- X: 0 - X: 0
Y: 0 Y: 0
Coverage: 10
Name: Tree
Scale: 1 Scale: 1
""" """
@ -106,8 +104,6 @@ yamlToData s = case runExcept $ parseYAMLToJson s of
Left err -> Left "Could not parse yaml" Left err -> Left "Could not parse yaml"
Right json -> decodeJson json Right json -> decodeJson json
testStrMap :: StrMap (Array GeoObject)
testStrMap = StrMap.singleton "key" parsedData
testMap :: Map String (Array GeoObject) testMap :: Map String (Array GeoObject)
testMap = Map.singleton "key" parsedData testMap = Map.singleton "key" parsedData
@ -137,7 +133,7 @@ readPoint = yamlToData
fullCircle :: String -> Either String String fullCircle :: String -> Either String String
fullCircle yamlString = (readPoint yamlString) >>= pure <<< printYAML fullCircle yamlString = (readPoint yamlString) >>= pure <<< printYAML
main :: Eff (RunnerEffects ()) Unit main :: Effect Unit
main = run [consoleReporter] do main = run [consoleReporter] do
describe "purescript-yaml" do describe "purescript-yaml" do
describe "decode" do describe "decode" do
@ -149,9 +145,6 @@ main = run [consoleReporter] do
let encoded = printYAML parsedData let encoded = printYAML parsedData
encoded `shouldEqual` yamlOutput encoded `shouldEqual` yamlOutput
let encodedStrMap = printYAML testStrMap
encodedStrMap `shouldEqual` yamlMapOutput
let encodedMap = printYAML testMap let encodedMap = printYAML testMap
encodedMap `shouldEqual` yamlMapOutput encodedMap `shouldEqual` yamlMapOutput