Skip to content

Prepare for 2.0 release#46

Merged
garyb merged 8 commits into
masterfrom
bump
Oct 13, 2016
Merged

Prepare for 2.0 release#46
garyb merged 8 commits into
masterfrom
bump

Conversation

@garyb

@garyb garyb commented Oct 10, 2016

Copy link
Copy Markdown
Member

Resolves #37, resolves #41

@garyb

garyb commented Oct 10, 2016

Copy link
Copy Markdown
Member Author

Figured I may as well add the general ForeignError from #37 - it seems harmless enough.

@paf31

paf31 commented Oct 10, 2016

Copy link
Copy Markdown
Contributor

Looks good, but let's discuss the use of NonEmpty. I think it would be nice to move NonEmpty to the top level, make it a Semigroup and give an Alt instance to F which combined errors using that Semigroup. What do you think?

@garyb

garyb commented Oct 10, 2016

Copy link
Copy Markdown
Member Author

I did start looking at that, but it wasn't really obvious to me how you'd actually get more than one failure out of the "parsing" anyway?

@paf31

paf31 commented Oct 10, 2016

Copy link
Copy Markdown
Contributor

Using <|>?

@paf31

paf31 commented Oct 10, 2016

Copy link
Copy Markdown
Contributor

i.e. using the Except (NonEmpty ForeignError) monad in place of Either.

@garyb

garyb commented Oct 10, 2016

Copy link
Copy Markdown
Member Author

Ok, sounds good to me. I take it we don't need the list in TypeError then? (although it will give slightly less good error messages)

@paf31

paf31 commented Oct 10, 2016

Copy link
Copy Markdown
Contributor

I think we could get rid of that, since that's more of an error message rendering problem, right?

@garyb

garyb commented Oct 10, 2016

Copy link
Copy Markdown
Member Author

Yeah, exactly

Comment thread src/Data/Foreign/Keys.purs Outdated
keys value
| isNull value = Left $ TypeMismatch (NE.singleton "object") "null"
| isUndefined value = Left $ TypeMismatch (NE.singleton "object") "undefined"
| isNull value = Left $ NE.singleton $ TypeMismatch "object" "null"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be worth extracting Left <<< NE.singleton <<< TypeMismatch into a function here.

Comment thread src/Data/Foreign.purs Outdated
-- | An error monad, used in this library to encode possible failures when
-- | dealing with foreign data.
type F = Either ForeignError
type F = Either (NE.NonEmpty List ForeignError)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this use Except so that we get the right Alt instance?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah right, I was trying to avoid adding the -transformers dependency, but yep, good point.

@paf31

paf31 commented Oct 11, 2016

Copy link
Copy Markdown
Contributor

👍 Thanks for this.

@garyb

garyb commented Oct 11, 2016

Copy link
Copy Markdown
Member Author

Maybe the MultipleErrors I just added here would be something worth adding in transformers?

@paf31

paf31 commented Oct 11, 2016

Copy link
Copy Markdown
Contributor

Could we add it in nonempty? We have non-empty containers, but we could also have non-empty base types with Monoid a => Semigroup (NonEmpty a).

@garyb

garyb commented Oct 11, 2016

Copy link
Copy Markdown
Member Author

Something like newtype NonEmptySemigroup s a = Semigroup s => NonEmptySemigroup (NonEmpty f a)? (but not with the constraint there obviously), or like newtype NonEmptyList = NonEmptyList (NonEmpty List)? We can't do the latter due to the dependency order, but something like the former would work.

@paf31

paf31 commented Oct 11, 2016

Copy link
Copy Markdown
Contributor

Never mind, I'm not sure what I was thinking. I think having a newtype around NonEmpty List somewhere would be good, although I'm fine with leaving this here too.

@garyb

garyb commented Oct 11, 2016

Copy link
Copy Markdown
Member Author

Yeah, it's fine here, just it seems like something that I'll want to use commonly with Except / MonadError in cases that have nothing to do with Foreign.

@garyb

garyb commented Oct 11, 2016

Copy link
Copy Markdown
Member Author

I could just make a new library for it I guess.

@paf31

paf31 commented Oct 12, 2016

Copy link
Copy Markdown
Contributor

Could it go into lists?

@garyb

garyb commented Oct 12, 2016

Copy link
Copy Markdown
Member Author

Yeah, I'll do that.

@paf31

paf31 commented Oct 12, 2016

Copy link
Copy Markdown
Contributor

What about leaving the type here for now, hiding its constructor and adding non-empty lists into lists later?

@garyb

garyb commented Oct 13, 2016

Copy link
Copy Markdown
Member Author

Done at last I think!

@paf31

paf31 commented Oct 13, 2016

Copy link
Copy Markdown
Contributor

👍 Thanks, looks great!

@garyb garyb merged commit b73e22f into master Oct 13, 2016
@garyb garyb deleted the bump branch October 13, 2016 19:49
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.

API question about ForeignError

3 participants