Initial commit

This commit is contained in:
sigma-andex 2022-08-19 16:39:45 +01:00
parent 3bba5a1059
commit 9501af2cde
No known key found for this signature in database
GPG Key ID: C5F79968835855AB
7 changed files with 81 additions and 0 deletions

10
.gitignore vendored Normal file
View 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
View 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
View 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
View 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
View 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
View 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
View 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."