mirror of
https://github.com/rowtype-yoga/purescript-fetch-yoga-json.git
synced 2024-11-25 05:57:13 +03:00
Initial commit
This commit is contained in:
parent
3bba5a1059
commit
9501af2cde
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/bower_components/
|
||||
/node_modules/
|
||||
/.pulp-cache/
|
||||
/output/
|
||||
/generated-docs/
|
||||
/.psc-package/
|
||||
/.psc*
|
||||
/.purs*
|
||||
/.psa*
|
||||
/.spago
|
12
package.json
Normal file
12
package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "purescript-iso-fetch-yoga-json",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
6
packages.dhall
Normal file
6
packages.dhall
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
let upstream =
|
||||
https://github.com/purescript/package-sets/releases/download/psc-0.15.4-20220808/packages.dhall
|
||||
sha256:60eee64b04ca0013fae3e02a69fc3b176105c6baa2f31865c67cd5f881a412fd
|
||||
|
||||
in upstream
|
14
spago.dhall
Normal file
14
spago.dhall
Normal file
@ -0,0 +1,14 @@
|
||||
{ name = "iso-fetch-yoga-json"
|
||||
, dependencies =
|
||||
[ "aff"
|
||||
, "either"
|
||||
, "exceptions"
|
||||
, "foreign"
|
||||
, "lists"
|
||||
, "prelude"
|
||||
, "transformers"
|
||||
, "yoga-json"
|
||||
]
|
||||
, packages = ./packages.dhall
|
||||
, sources = [ "src/**/*.purs" ]
|
||||
}
|
17
src/Fetch/Yoga/Json.purs
Normal file
17
src/Fetch/Yoga/Json.purs
Normal file
@ -0,0 +1,17 @@
|
||||
module Fetch.Yoga.Json where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Control.Monad.Error.Class (throwError)
|
||||
import Data.Either (either)
|
||||
import Data.List.NonEmpty (NonEmptyList, fold1)
|
||||
import Effect.Aff (Aff)
|
||||
import Effect.Exception (Error, error)
|
||||
import Foreign (Foreign, ForeignError, renderForeignError)
|
||||
import Yoga.JSON as Yoga
|
||||
|
||||
fromJson :: forall json. Yoga.ReadForeign json ⇒ Aff Foreign -> Aff json
|
||||
fromJson json = json >>= Yoga.read >>> either (toError >>> throwError) pure
|
||||
where
|
||||
toError :: NonEmptyList ForeignError -> Error
|
||||
toError = map renderForeignError >>> fold1 >>> error
|
11
test.dhall
Normal file
11
test.dhall
Normal file
@ -0,0 +1,11 @@
|
||||
let conf = ./spago.dhall
|
||||
|
||||
in conf
|
||||
// { sources = conf.sources # [ "test/**/*.purs" ]
|
||||
, dependencies =
|
||||
conf.dependencies
|
||||
# [ "aff"
|
||||
, "console"
|
||||
, "effect"
|
||||
]
|
||||
}
|
11
test/Main.purs
Normal file
11
test/Main.purs
Normal file
@ -0,0 +1,11 @@
|
||||
module Test.Main where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Effect (Effect)
|
||||
import Effect.Aff (launchAff_)
|
||||
import Effect.Class.Console (log)
|
||||
|
||||
main :: Effect Unit
|
||||
main = launchAff_ do
|
||||
log "You should add some tests."
|
Loading…
Reference in New Issue
Block a user