Skip to content

Added applyEither for validation-style combination#45

Closed
reactormonk wants to merge 1 commit intopurescript:masterfrom
reactormonk:master
Closed

Added applyEither for validation-style combination#45
reactormonk wants to merge 1 commit intopurescript:masterfrom
reactormonk:master

Conversation

@reactormonk
Copy link

@hdgarrood
Copy link
Contributor

Thanks, but I am tempted to leave this as-is and let purescript-validation continue to handle this use-case.

@reactormonk
Copy link
Author

The use-case here is a different combination logic once. For the same code, you'd need to convert to validation and back. This would be possible, but require either either or validation to depend on each other or even a third package just for Either -> Validation and back.

@hdgarrood
Copy link
Contributor

validation already depends on either though; the definition of V is

newtype V err result = V (Either err result)

and although the constructor isn't exported, you can freely convert back and forth with either invalid pure and toEither.

@reactormonk
Copy link
Author

So to use this specific applicative combinator, you suggest to a) include purescript-validation b) write
toEither $ apply (either invalid pure e1) (either invalid pure e2)? That does sound like a whole lot of work.

@hdgarrood
Copy link
Contributor

It is, which is why I'd like to see purescript/purescript-validation#11 happen, so that we can just do under V apply. See https://pursuit.purescript.org/packages/purescript-newtype/3.0.0/docs/Data.Newtype#v:under

@hdgarrood
Copy link
Contributor

Sorry, under V apply doesn't typecheck. But with V and un V (which we will have if we export the constructor) I think it is easy enough to convert between them. But also, if you want this function, you probably should just be using V to begin with.

@hdgarrood
Copy link
Contributor

Another thing we could do to make this more comfortable would be purescript/purescript-parallel#26

@reactormonk
Copy link
Author

tl;dr: not possible: purescript/purescript-parallel#27

@hdgarrood
Copy link
Contributor

I don't want to merge this, sorry. I'm concerned that people might expect it to behave in the same way as apply for Either, and I also think that it doesn't really make sense to provide this function other than in an actual Apply instance (as validation already does). If you do want this specific function, as opposed to the version which works with V, I think that's too much of a niche use case to deserve a spot in Data.Either, and it's easy enough to define inline, as you've done.

@hdgarrood hdgarrood closed this Oct 16, 2020
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.

2 participants