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

add decoder for NonEmptyString #91

Closed
srghma opened this issue Dec 20, 2020 · 2 comments
Closed

add decoder for NonEmptyString #91

srghma opened this issue Dec 20, 2020 · 2 comments
Labels
type: enhancement A new feature or addition.

Comments

@srghma
Copy link
Member

srghma commented Dec 20, 2020

can add after 0.14, because cannot run tests now

instance decodeJsonCodePoint :: DecodeJson NonEmptyString where
  decodeJson = decodeNonEmptyString

decodeNonEmptyString :: Json -> Either JsonDecodeError NonEmptyString
decodeNonEmptyString json =
  note (Named "NonEmptyString" $ UnexpectedValue json)
    =<< map (NonEmptyString.fromString) (decodeString json)
@srghma
Copy link
Member Author

srghma commented Dec 20, 2020

we could also add

decodeNonempty :: Json -> Either JsonDecodeError String
decodeNonempty = map NonEmptyString.toString <<< decodeNonEmptyString

like haskell lib envparse does

they have str :: String and nonempty :: String

@thomashoneyman
Copy link
Contributor

I think this is sensible to add, and I'd accept a PR for it. If you don't want to build using a 0.14 release candidate you could always check out the last commit before the 0.14 changes, make your update, and then rebase onto master (I think, at least).

@thomashoneyman thomashoneyman added the type: enhancement A new feature or addition. label Dec 23, 2020
srghma added a commit to srghma/purescript-argonaut-codecs that referenced this issue Dec 23, 2020
srghma added a commit to srghma/purescript-argonaut-codecs that referenced this issue Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A new feature or addition.
Development

No branches or pull requests

2 participants