generated from tpl/purs
Clean up package.json and README.md
This commit is contained in:
parent
f66d6c42b4
commit
d477e83bfc
47
README.md
47
README.md
@ -2,23 +2,10 @@
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
First install [js-yaml](https://github.com/connec/yaml-js). Note, purescript-yaml is not compatible with YAML 1.1.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install js-yaml@^3.4.6
|
spago install yaml-next
|
||||||
```
|
```
|
||||||
|
|
||||||
Then add purescript-yaml-next as a project dependency.
|
|
||||||
|
|
||||||
```
|
|
||||||
bower install --save purescript-yaml-next
|
|
||||||
```
|
|
||||||
|
|
||||||
Alternatively, you can add the repo itself as a project dependency, e.g.
|
|
||||||
|
|
||||||
```
|
|
||||||
bower install --save git://github.com/archaeron/purescript-yaml#tagOrBranch
|
|
||||||
```
|
|
||||||
|
|
||||||
## YAML to Data Type Usage
|
## YAML to Data Type Usage
|
||||||
|
|
||||||
@ -35,10 +22,14 @@ Y: 1
|
|||||||
```
|
```
|
||||||
|
|
||||||
We can read a `Point` from the YAML by converting the YAML into JSON
|
We can read a `Point` from the YAML by converting the YAML into JSON
|
||||||
and then using [purescript-argonaut](https://github.com/purescript-contrib/purescript-argonaut)'s encoding functionality to get the
|
and then using [purescript-argonaut]'s encoding functionality to get the
|
||||||
type we need (specifically, [purescript-argonaut-codecs](https://github.com/purescript-contrib/purescript-argonaut-codecs)
|
type we need (specifically, [purescript-argonaut-codecs]
|
||||||
functionality).
|
functionality).
|
||||||
|
|
||||||
|
[purescript-argonaut]: https://github.com/purescript-contrib/purescript-argonaut
|
||||||
|
[purescript-argonaut-codecs]:
|
||||||
|
https://github.com/purescript-contrib/purescript-argonaut-codecs
|
||||||
|
|
||||||
```purescript
|
```purescript
|
||||||
getPoint :: Either String Point
|
getPoint :: Either String Point
|
||||||
getPoint = case runExcept $ parseYAMLToJson yamlPoint of
|
getPoint = case runExcept $ parseYAMLToJson yamlPoint of
|
||||||
@ -69,7 +60,7 @@ data YValue
|
|||||||
| YNull
|
| YNull
|
||||||
```
|
```
|
||||||
|
|
||||||
To convert data into a aYValue, create instances of the ToYAML class for your
|
To convert data into a `YValue`, create instances of the `ToYAML` class for your
|
||||||
data types.
|
data types.
|
||||||
|
|
||||||
```purescript
|
```purescript
|
||||||
@ -91,32 +82,32 @@ instance pointToYAML :: ToYAML Point where
|
|||||||
```
|
```
|
||||||
|
|
||||||
You can find helper functions for converting basic types into `YValue`
|
You can find helper functions for converting basic types into `YValue`
|
||||||
in the Data.YAML.Foreign.Encode module.
|
in the `Data.YAML.Foreign.Encode` module.
|
||||||
|
|
||||||
Finally, if you want to convert `YValue` into a String, you can use the
|
Finally, if you want to convert `YValue` into a String, you can use the
|
||||||
`printYAML` function from Data.YAML.Foreign.Encode.
|
`printYAML` function from `Data.YAML.Foreign.Encode`.
|
||||||
|
|
||||||
|
|
||||||
```purescript
|
```purescript
|
||||||
printYAML :: forall a. (ToYAML a) => a -> String
|
printYAML :: forall a. (ToYAML a) => a -> String
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
Using the previous code and the type classes we defined earlier, we can go
|
Using the previous code and the type classes we defined earlier,
|
||||||
full circle from a YAML string to a PureScript Data Type and back to a YAML string.
|
we can go full circle from a YAML string to a PureScript Data Type
|
||||||
|
and back to a YAML string.
|
||||||
|
|
||||||
```purescript
|
```purescript
|
||||||
fullCircle :: String -> Either String String
|
fullCircle :: String -> Either String String
|
||||||
fullCircle yamlString = (readPoint yamlString) >>= pure <<< printYAML
|
fullCircle yamlString = (readPoint yamlString) >>= pure <<< printYAML
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Check out the repo and make changes. You can run/add tests by running pulp test.
|
1. Check out the repo
|
||||||
|
1. Run `npm install`
|
||||||
```
|
1. Make changes
|
||||||
bower install
|
1. Test them by running `npm test`
|
||||||
npm install
|
|
||||||
pulp test
|
|
||||||
```
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "purescript-yaml-next",
|
"name": "purescript-yaml-next",
|
||||||
"license": "SEE LICENSE FILE",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/archaeron/purescript-yaml",
|
"repository": "https://github.com/archaeron/purescript-yaml-next",
|
||||||
"private": true,
|
"private": true,
|
||||||
"contributors": [],
|
|
||||||
"main": "main.js",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "spago -x test.dhall test",
|
"test": "spago -x test.dhall test",
|
||||||
"postinstall": "spago build"
|
"postinstall": "spago build"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"js-yaml": "^4.0.0"
|
"js-yaml": "^4.0.0"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user