Translate your Haskell types to PureScript types. It should in theory work for almost all Haskell types, including type constructors! You just have to instantiate it with dummy parameters from e.g. "Language.PureScript.Bridge.TypeParameters".
Data type translation is fully and easily customizable by providing your own BridgePart
instances!
The latest version of this project requires PureScript 0.15.
Use aeson
's generic encoding/decoding with default options
There are three PureScript libraries which can interface with Aeson through PureScript bridge. The second, purescript-argonaut-aeson-generic
, has issues.
Enable this on the Haskell side with Language.PureScript.Bridge.SumType.jsonHelpers
.
- see
./test/RoundTripJsonHelpers
for example - sample Dhall config (for spago-legacy):
, json-helpers =
{ dependencies =
[ "aff"
, "argonaut-codecs"
, "argonaut-core"
, "arrays"
, "bifunctors"
, "contravariant"
, "control"
, "effect"
, "either"
, "enums"
, "foldable-traversable"
, "foreign-object"
, "maybe"
, "newtype"
, "ordered-collections"
, "prelude"
, "profunctor"
, "psci-support"
, "quickcheck"
, "record"
, "spec"
, "spec-quickcheck"
, "transformers"
, "tuples"
, "typelevel-prelude"
]
, repo =
"https://github.com/input-output-hk/purescript-bridge-json-helpers.git"
, version = "486db9ee62882baa42cca24f556848c5f6bec565"
}
Enable this on the Haskell side with Language.PureScript.Bridge.SumType.argonautAesonGeneric
.
This library is demonstrated by the example
; see ./example/readme.md
.
TODO: resolve incompatibility between Argonaut and Aeson
Additional requirement: peterbecich/purescript-argonaut-codecs
- commit
04abb3eb24a4deafe125be0eb23e2786c642e66b
- see
./test/RoundTripArgonautAesonGeneric
for example- note that some types have been disabled from the
RoundTripArgonautAesonGeneric
testRoundTripJsonHelpers
tests more types
- the types tested can be expanded when the incompatibility issue is resolved
- note that some types have been disabled from the
- sample Dhall config:
, argonaut-codecs =
{ dependencies = [ "console" ]
, repo = "https://github.com/peterbecich/purescript-argonaut-codecs.git"
, version = "04abb3eb24a4deafe125be0eb23e2786c642e66b"
}
- forked from
purescript-contrib/purescript-argonaut-codecs
See ForeignObject
in Language.PureScript.Bridge.SumType
.
This may need to be fixed.
The test coverage is less than the other two libraries.
Usage of this library is documented in Language.Purescript.Bridge
, with writePSTypes
you should have everything to get started. Documentation can be found here.
There is an example; see ./example/readme.md
.
It works for my use case and is used in production. PRs for more PSType
s definitions and bridges are very welcome!
This repo uses stylish-haskell
. .stylish-haskell.yaml
is provided.
find . -name '*.hs' | xargs stylish-haskell -i