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

updated code to purescript 0.12 and Generic.Rep #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CarstenKoenig
Copy link

ok this includes a lot of (sadly breaking) changes:

  • updated packages to the newest ones for PureScript 0.12
  • uses purescript-argonaut-generic (right now my own fork - I hope they include this or something similar soon)
  • uses Aff
  • I think it's better to have a version of affjax (called it ajax here) that is close to your original version but there is one change: it will use argonaut-generic instances to decode the JSON right there - so we don't need getResult any more - I think it's the obvious use case here
  • it also drops most of the copied code and uses affjax directly - only FFI left is encodeUriComponent and unsafeToString - mostly because I could not find the first any more and I'm not sure what the second is exactly used for at the moment

sadly there are no tests and I'm not 100% certain that this code is working

so this is more or less WIP but I need this to continue on servant-purescript and I wanted to have your input/feedback on that

best regards,
Carsten

gDefaultEncodeHeader v =
case toSpine v of
SString s -> s -- Special case string - just use it as is (http-api-data compatibility).
_ -> show <<< Aeson.encodeJson $ v
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this special case no longer needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I did not mess up this should be taken care of by this instance here:

https://github.com/eskimor/purescript-servant-support/pull/15/files#diff-7b8d38eeda45bc94e96d07a922b4631bR37

as far as I understood your code this one was used pass on strings as they are

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha - yeah I completely missed that one. Looks good then. 'else instance' - that's a nice construct :-P

@eskimor
Copy link
Owner

eskimor commented Jul 7, 2018

I believe the second is used for error reporting, if I remember correctly.

If we get the JSON directly, how do we report errors if something goes wrong?

@CarstenKoenig
Copy link
Author

CarstenKoenig commented Jul 7, 2018

I should probably write some test cases but I hoped to use this kind of error

https://github.com/eskimor/purescript-servant-support/pull/15/files#diff-4dd6048806498efe169a5f3a62c9672bR59

for those kinds of errors

(argonaut-generic: https://github.com/CarstenKoenig/purescript-argonaut-generic/blob/RowToList/src/Data/Argonaut/Decode/Generic/Rep.purs should produce hopefully readable errors for why some JSON could not be decoded)

@eskimor
Copy link
Owner

eskimor commented Jul 8, 2018

Sounds reasonable.

@shmish111
Copy link

ok, this one is needed, what is the situation with this, I will test with the servant-purescript PR now

@vlatkoB
Copy link

vlatkoB commented Oct 28, 2019

Any updates on the update? :-)

@legrostdg
Copy link

any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants