Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge IOHK fork #89

Open
wants to merge 118 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
81ad9e8
add optional Foreign encoding and decoding
shmish111 May 8, 2019
80774b2
remove TODO
shmish111 May 8, 2019
ecd2bd8
use https://github.com/paf31/purescript-foreign-generic/pull/52
shmish111 May 10, 2019
70f1654
Whitespace changes.
krisajenkins May 17, 2019
02de37e
Refactoring the code to use a structured printing library.
krisajenkins May 20, 2019
d9bf17a
Bugfix for Encode/Decode constraints.
krisajenkins May 21, 2019
8eace90
Bugfix for decode/encode instances on recursive types.
krisajenkins May 22, 2019
4ef961c
You can now generate `Eq` instances for something like `Proxy :: Prox…
krisajenkins May 23, 2019
05b5b62
Whitespace changes.
krisajenkins May 23, 2019
72fbe2d
You can now generate a `Show` instance based on `genericShow`.
krisajenkins May 23, 2019
a7069a5
Aeson-compatible encodings for Enums*.
krisajenkins May 24, 2019
02bd099
Bugfix for Encode/Decode constraints.
krisajenkins May 21, 2019
de2574e
You can now generate a `Show` instance based on `genericShow`.
krisajenkins May 23, 2019
b310e6a
Applying hlint suggestions.
krisajenkins Sep 20, 2019
1fc332d
You can now generate `Ord` instances for something like `Proxy :: Pro…
krisajenkins Sep 20, 2019
e68e46d
Bugfix for genericShow.
krisajenkins Jul 11, 2019
1e7ca3d
genericShow now supports parameterised types.
krisajenkins Aug 2, 2019
5e25608
Adding Functor support.
krisajenkins Aug 9, 2019
0c3dd26
fix haddock
shmish111 Sep 13, 2019
0042602
Version 0.13.1.0.
krisajenkins Sep 20, 2019
fb8a038
Updating for PureScript 0.13.
krisajenkins Sep 30, 2019
a76b119
Adding support for Eq1 instances.
krisajenkins Nov 20, 2019
28c3777
Factoring out some duplicated code in the typeclass instance-generation.
krisajenkins Nov 26, 2019
6a92d78
use a newer stackage
shmish111 Feb 5, 2021
755841f
Merge pull request #1 from input-output-hk/eq1
jhbertra Oct 5, 2021
808d12c
run lorri init
jhbertra Oct 5, 2021
62ead0a
Add flake.nix
jhbertra Oct 5, 2021
2276c49
Update import module for genericShow
jhbertra Oct 5, 2021
13381aa
0.14.0.0
jhbertra Oct 5, 2021
c867392
Remove shell params
jhbertra Oct 5, 2021
0cd3f0c
Merge pull request #3 from input-output-hk/jhbertra/ps-014
jhbertra Oct 5, 2021
0240a54
Replace foreign-generic with Argonaut
jhbertra Oct 8, 2021
542274f
Add roundtrip test project
jhbertra Oct 8, 2021
38b502a
Add compile test
jhbertra Oct 8, 2021
6c5c39d
Add Aesone round trip test
jhbertra Oct 12, 2021
44fe87f
Spawn only one process and check warnings
jhbertra Oct 13, 2021
1e0cebf
Remove Proxy from API
jhbertra Oct 13, 2021
1d311a8
Add lenses to test
jhbertra Oct 13, 2021
f9c9fe9
Fix bugs with nested decoders
jhbertra Oct 13, 2021
69f69a5
Simplify test type
jhbertra Oct 13, 2021
12aa42c
Integrate json helpers
jhbertra Oct 20, 2021
2231292
Refactor printing
jhbertra Oct 20, 2021
7bc806f
Merge pull request #4 from input-output-hk/jhbertra/ps-014
jhbertra Oct 20, 2021
e6d4f98
Export everything again
jhbertra Oct 20, 2021
c898b46
Fix problems with inline records in sum types
jhbertra Oct 25, 2021
55c951d
Make sum type encoding better
jhbertra Oct 25, 2021
2953fb1
Update sum type encode/decode
jhbertra Oct 25, 2021
2f91764
Add recursive types to test
jhbertra Oct 25, 2021
35d863b
Merge pull request #5 from input-output-hk/jhbertra/bug-fixes
jhbertra Oct 25, 2021
132a6d1
Fix handling of multi record constructors
jhbertra Oct 27, 2021
27501fe
Fix encoding of nullary constructors
jhbertra Oct 28, 2021
366fc70
Add support for set and map json
jhbertra Oct 28, 2021
569fc66
Update json-helpers dependency
jhbertra Nov 4, 2021
7d3b750
Add ormolu to nix shell
jhbertra Jan 20, 2022
b4c4069
Add support for custom instances
jhbertra Jan 20, 2022
9550caf
Format everything with ormolu
jhbertra Jan 21, 2022
759012a
Add newlines at the end of module files
jhbertra Jan 21, 2022
a62b87c
Fix type extraction for custom instances
jhbertra Jan 21, 2022
47a1f11
Add import lines for custom instances
jhbertra Jan 21, 2022
2b58aa6
Add package namespacing support
paluh Jun 22, 2022
51e8404
Make package namespacing introduction backward compatible.
paluh Jul 7, 2022
7e554e5
Merge pull request #10 from paluh/master
jhbertra Jul 7, 2022
53f4e98
copy Stylish Haskell, Nix Flake config
peterbecich Sep 18, 2023
94c66ef
fix compilation
peterbecich Sep 24, 2023
faf275c
`nix flake update`
peterbecich Sep 4, 2023
b5fbac0
format with Fourmolu and then Stylish Haskell
peterbecich Sep 24, 2023
cf3de1d
WIP merge IOHK fork
peterbecich Sep 25, 2023
35ecb0e
`genericShow` instance provided by IOHK fork
peterbecich Sep 30, 2023
027e5e7
Encode/Decode instances by IOHK using `purescript-bridge-json-helpers`
peterbecich Sep 30, 2023
a57e39e
bump to version 0.16.0.0; delete boilerplate
peterbecich Sep 30, 2023
fba4c7a
generate `DecodeJsonField`
peterbecich Sep 30, 2023
974d7db
delete unused `CodeGenSwitches`
peterbecich Sep 30, 2023
0d5edfe
fix LSP server for RoundTrip test
peterbecich Oct 1, 2023
88f1e31
fix rendered `EncodeJson` and `DecodeJson` instances
peterbecich Oct 1, 2023
d1a613b
extend example to show failing case
peterbecich Oct 1, 2023
5933ef7
fix printing of import list
peterbecich Oct 1, 2023
a2acbbb
fix printing of imports with/without aliases
peterbecich Oct 1, 2023
c9fa2f0
RoundTrip test succeeds with json-helper library
peterbecich Oct 15, 2023
5480bff
RoundTrip tests for both json-helpers and argonaut-aeson-generic
peterbecich Oct 15, 2023
1bc3046
fix dependency notice for `json-helpers`
peterbecich Oct 16, 2023
eadfb27
clean up example
peterbecich Oct 16, 2023
93e6ab7
fix example using argonaut-aeson-generic
peterbecich Oct 16, 2023
47becfb
improve example to show random errors
peterbecich Oct 16, 2023
c7ebbac
fix Stack project
peterbecich Oct 22, 2023
0b5e11f
temporarily disable tests in Nix
peterbecich Oct 22, 2023
bce383f
improve example
peterbecich Oct 22, 2023
c60400c
make Aeson produce `tag` for `Either`
peterbecich Nov 25, 2023
55e265b
working example of encoding/decoding `Either`
peterbecich Nov 26, 2023
920c236
clean-up
peterbecich Nov 26, 2023
ada7742
readme
peterbecich Jan 3, 2024
fc87b4b
update purescript-bridge-json-helpers
peterbecich Jan 3, 2024
1e9c7d9
update github action
peterbecich Jan 3, 2024
2d6a6e2
get tests passing
peterbecich Jan 3, 2024
3be53bf
improve readme
peterbecich Jan 4, 2024
deed0f3
improve readme, clean-up
peterbecich Jan 4, 2024
95e6034
clean-up
peterbecich Jan 13, 2024
17830c1
`nix flake update`
peterbecich Jan 13, 2024
7069895
changelog
peterbecich Jan 13, 2024
7d7c1d8
stylish-haskell and lint
peterbecich Jan 13, 2024
de32d3f
demonstrate `json-helpers` in the `example`
peterbecich Jan 28, 2024
6f5008a
example, generate PureScript before server starts
peterbecich Jan 28, 2024
83a204d
move example to new Spago
flip111 Feb 25, 2024
d56a437
complete upgrade to new Spago@next
peterbecich Feb 25, 2024
5c86b32
Merge pull request #2 from peterbecich/spago-upgrade
peterbecich Feb 25, 2024
8536ddf
update example package set
peterbecich Feb 25, 2024
e1eee18
remove `Show` constraint; there are issues to be fixed
peterbecich Jan 28, 2024
8c389d1
Fix show instances for unused type variables
flip111 Feb 15, 2024
bfb9ebe
Revert eta reduction of show = genericShow
flip111 Feb 25, 2024
becf65e
Merge pull request #1 from flip111/fix-show2
peterbecich Feb 25, 2024
28053d1
extra-source-files
peterbecich Feb 25, 2024
4439ef6
github action tweak
peterbecich Feb 26, 2024
dd3fabf
`nix flake update`
peterbecich Mar 30, 2024
f2e973c
calendar datatype test
peterbecich Mar 31, 2024
72d87b7
use quasiquoter to clean up tests
peterbecich Mar 31, 2024
392e7b4
`Enum` and `Bounded` require `Eq` and `Ord`
peterbecich Apr 1, 2024
8a04045
`nix flake update`, update Spago
peterbecich Jul 5, 2024
1f1b74e
use Spago Workspaces
peterbecich Jul 6, 2024
d18a14d
provide esbuild
peterbecich Jul 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
generate DecodeJsonField
  • Loading branch information
peterbecich committed Sep 30, 2023
commit fba4c7a0be37066afcc68d7b13a0f84980f9966a
18 changes: 2 additions & 16 deletions src/Language/PureScript/Bridge/Printer.hs
Original file line number Diff line number Diff line change
@@ -432,7 +432,8 @@ showConstraints :: PSType -> [PSType]
showConstraints = constrainWith "Show"

decodeJsonConstraints :: PSType -> [PSType]
decodeJsonConstraints = constrainWith "DecodeJson"
decodeJsonConstraints psType =
(constrainWith "DecodeJson" psType) <> (constrainWith "DecodeJsonField" psType)

encodeJsonConstraints :: PSType -> [PSType]
encodeJsonConstraints = constrainWith "EncodeJson"
@@ -499,21 +500,6 @@ sumTypeToEncode (SumType _ cs _)
isTypeParam :: PSType -> PSType -> Bool
isTypeParam t typ = _typeName typ `elem` map _typeName (_typeParameters t)

-- encodeInstance :: PSType -> Text
-- encodeInstance params = "Encode " <> typeInfoToText False params

-- encodeJsonInstance :: PSType -> Text
-- encodeJsonInstance params = "EncodeJson " <> typeInfoToText False params

-- decodeInstance :: PSType -> Text
-- decodeInstance params = "Decode " <> typeInfoToText False params

-- decodeJsonInstance :: PSType -> Text
-- decodeJsonInstance params = "DecodeJson " <> typeInfoToText False params

-- decodeJsonFieldInstance :: PSType -> Text
-- decodeJsonFieldInstance params = "DecodeJsonField " <> typeInfoToText False params

-- genericInstance :: Switches.Settings -> PSType -> Text
-- genericInstance settings params =
-- if not (Switches.genericsGenRep settings)
28 changes: 17 additions & 11 deletions test/RoundTrip/Spec.hs
Original file line number Diff line number Diff line change
@@ -43,19 +43,25 @@ import Test.QuickCheck.Property (Testable (property))
myBridge :: BridgePart
myBridge = defaultBridge

instancesToGenerate = equal
. order
. genericShow
. order
. argonautJson

myTypes :: [SumType 'Haskell]
myTypes =
[ equal . genericShow . order . argonautJson $ mkSumType @TestData
, equal . genericShow . order . argonautJson $ mkSumType @TestSum
, equal . genericShow . order . argonautJson $ mkSumType @TestRecursiveA
, equal . genericShow . order . argonautJson $ mkSumType @TestRecursiveB
, functor . equal . genericShow . order . argonautJson $ mkSumType @(TestRecord A)
, equal . genericShow . order . argonautJson $ mkSumType @TestNewtype
, equal . genericShow . order . argonautJson $ mkSumType @TestNewtypeRecord
, equal . genericShow . order . argonautJson $ mkSumType @TestMultiInlineRecords
, equal . genericShow . order . argonautJson $ mkSumType @TestTwoFields
, equal . genericShow . order . argonautJson $ mkSumType @TestEnum
, equal . genericShow . order . argonautJson $ mkSumType @MyUnit
[ instancesToGenerate $ mkSumType @TestData
, instancesToGenerate $ mkSumType @TestSum
, instancesToGenerate $ mkSumType @TestRecursiveA
, instancesToGenerate $ mkSumType @TestRecursiveB
, functor . instancesToGenerate $ mkSumType @(TestRecord A)
, instancesToGenerate $ mkSumType @TestNewtype
, instancesToGenerate $ mkSumType @TestNewtypeRecord
, instancesToGenerate $ mkSumType @TestMultiInlineRecords
, instancesToGenerate $ mkSumType @TestTwoFields
, instancesToGenerate $ mkSumType @TestEnum
, instancesToGenerate $ mkSumType @MyUnit
]

roundtripSpec :: Spec
46 changes: 23 additions & 23 deletions test/RoundTrip/app/src/RoundTrip/Types.purs
Original file line number Diff line number Diff line change
@@ -31,11 +31,11 @@ data TestData

derive instance Eq TestData

derive instance Ord TestData

instance Show TestData where
show a = genericShow a

derive instance Ord TestData

instance EncodeJson TestData where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -76,11 +76,11 @@ data TestSum

derive instance Eq TestSum

derive instance Ord TestSum

instance Show TestSum where
show a = genericShow a

derive instance Ord TestSum

instance EncodeJson TestSum where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -97,11 +97,11 @@ data TestRecursiveA

derive instance Eq TestRecursiveA

derive instance Ord TestRecursiveA

instance Show TestRecursiveA where
show a = genericShow a

derive instance Ord TestRecursiveA

instance EncodeJson TestRecursiveA where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -116,11 +116,11 @@ newtype TestRecursiveB = RecurseB TestRecursiveB

derive instance Eq TestRecursiveB

derive instance Ord TestRecursiveB

instance Show TestRecursiveB where
show a = genericShow a

derive instance Ord TestRecursiveB

instance EncodeJson TestRecursiveB where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -142,15 +142,15 @@ derive instance Functor TestRecord

derive instance (Eq a) => Eq (TestRecord a)

derive instance (Ord a) => Ord (TestRecord a)

instance (Show a) => Show (TestRecord a) where
show a = genericShow a

derive instance (Ord a) => Ord (TestRecord a)

instance (EncodeJson a) => EncodeJson (TestRecord a) where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

instance (DecodeJson a) => DecodeJson (TestRecord a) where
instance (DecodeJson a, DecodeJsonField a) => DecodeJson (TestRecord a) where
decodeJson = genericDecodeAeson Argonaut.defaultOptions

derive instance Generic (TestRecord a) _
@@ -163,11 +163,11 @@ newtype TestNewtype = TestNewtype (TestRecord Boolean)

derive instance Eq TestNewtype

derive instance Ord TestNewtype

instance Show TestNewtype where
show a = genericShow a

derive instance Ord TestNewtype

instance EncodeJson TestNewtype where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -184,11 +184,11 @@ newtype TestNewtypeRecord = TestNewtypeRecord { unTestNewtypeRecord :: TestNewty

derive instance Eq TestNewtypeRecord

derive instance Ord TestNewtypeRecord

instance Show TestNewtypeRecord where
show a = genericShow a

derive instance Ord TestNewtypeRecord

instance EncodeJson TestNewtypeRecord where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -213,11 +213,11 @@ data TestMultiInlineRecords

derive instance Eq TestMultiInlineRecords

derive instance Ord TestMultiInlineRecords

instance Show TestMultiInlineRecords where
show a = genericShow a

derive instance Ord TestMultiInlineRecords

instance EncodeJson TestMultiInlineRecords where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -232,11 +232,11 @@ data TestTwoFields = TestTwoFields Boolean Int

derive instance Eq TestTwoFields

derive instance Ord TestTwoFields

instance Show TestTwoFields where
show a = genericShow a

derive instance Ord TestTwoFields

instance EncodeJson TestTwoFields where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -258,11 +258,11 @@ data TestEnum

derive instance Eq TestEnum

derive instance Ord TestEnum

instance Show TestEnum where
show a = genericShow a

derive instance Ord TestEnum

instance EncodeJson TestEnum where
encodeJson = genericEncodeAeson Argonaut.defaultOptions

@@ -285,11 +285,11 @@ data MyUnit = U

derive instance Eq MyUnit

derive instance Ord MyUnit

instance Show MyUnit where
show a = genericShow a

derive instance Ord MyUnit

instance EncodeJson MyUnit where
encodeJson = genericEncodeAeson Argonaut.defaultOptions