Merge pull request #6 from feramhq/master

Upgrade dependencies for PureScript 0.12
This commit is contained in:
Dominick Gendill 2018-09-10 18:47:14 -06:00 committed by GitHub
commit 58035ea964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 56 deletions

View File

@ -1,6 +1,5 @@
{
"name": "purescript-yaml-next",
"version": "0.1.0",
"moduleType": [
"node"
],
@ -14,15 +13,16 @@
],
"dependencies": {
"js-yaml": "^3.4.6",
"purescript-functions": "^3.0.0",
"purescript-foreign": "^4.0.0",
"purescript-foreign-generic": "^4.1.0",
"purescript-unsafe-coerce": "^3.0.0",
"purescript-argonaut-core": "^3.1.0"
"purescript-argonaut-core": "^4.0.1",
"purescript-foreign": "^5.0.0",
"purescript-foreign-generic": "^7.0.0",
"purescript-functions": "^4.0.0",
"purescript-ordered-collections": "^1.1.0",
"purescript-unsafe-coerce": "^4.0.0"
},
"devDependencies": {
"purescript-console": "^3.0.0",
"purescript-spec": "^1.0.0",
"purescript-argonaut-codecs": "^3.0.1"
"purescript-argonaut-codecs": "^4.0.2",
"purescript-console": "^4.1.0",
"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",
"repository": "",
"private": true,
"contributors": [ ],
"contributors": [],
"main": "main.js",
"scripts": {
"postinstall": "bower install",
"build": "pulp build"
},
"devDependencies": {
},
"devDependencies": {},
"dependencies": {
"js-yaml": "^3.4.6"
"js-yaml": "^3.12.0"
}
}

View File

@ -3,10 +3,10 @@ module Data.YAML.Foreign.Decode (
parseYAMLToJson
) where
import Data.Foreign (F, Foreign, ForeignError(..), fail)
import Data.Foreign.Generic (genericDecode)
import Data.Foreign.Generic.Class (class GenericDecode)
import Data.Foreign.Generic.Types (Options)
import Foreign (F, Foreign, ForeignError(..), fail)
import Foreign.Generic (genericDecode)
import Foreign.Generic.Class (class GenericDecode)
import Foreign.Generic.Types (Options)
import Data.Function.Uncurried (Fn3, runFn3)
import Data.Generic.Rep (class Generic)
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.
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
parseYAMLToJson :: String -> F Json

View File

@ -9,8 +9,6 @@ module Data.YAML.Foreign.Encode (
import Data.Map as M
import Data.Map (Map)
import Data.StrMap as StrMap
import Data.StrMap (StrMap)
import Data.Array (toUnfoldable)
import Data.Function.Uncurried (Fn4, runFn4)
import Data.List (List)
@ -54,11 +52,8 @@ instance eqYValue :: Eq YValue where
class ToYAML a where
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
toYAML m = YObject $ M.mapWithKey (\key value -> toYAML value) m
toYAML m = YObject $ map (\value -> toYAML value) m
instance booleanToYAML :: ToYAML Boolean where
toYAML = YBoolean

View File

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

View File

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