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

Additionnal facilities for partial matching #8

Closed
jbgi opened this Issue Oct 20, 2015 · 7 comments

Comments

Projects
None yet
3 participants
@jbgi
Member

jbgi commented Oct 20, 2015

today there is only

Function<ADT, R> otherwise(Supplier<R> expression)

I think it should be renamed into

Function<ADT, R> otherwiseEval(Supplier<R> expression)

And then we can add:

Function<ADT, R> otherwise(R value)
Function<ADT, Option<R>> otherwiseNone()
Function<ADT, Either<L, R>> <L> otherwiseLeft(L leftValue)
Function<ADT, Validation<E, R>> <E> otherwiseFail(E error)

What others think about that feature? (are naming good?)

@jbgi jbgi added this to the 0.5 milestone Oct 20, 2015

@talios

This comment has been minimized.

Show comment
Hide comment
@talios

talios Oct 31, 2015

Contributor

Would otherwiseLeft and otherwiseFail only be generated for the flavours that support them, or will derive4j have a companion artefact containing an Either and Validation implementation ( hopefully not unique versions of these per @Data type..

Contributor

talios commented Oct 31, 2015

Would otherwiseLeft and otherwiseFail only be generated for the flavours that support them, or will derive4j have a companion artefact containing an Either and Validation implementation ( hopefully not unique versions of these per @Data type..

@jbgi

This comment has been minimized.

Show comment
Hide comment
@jbgi

jbgi Oct 31, 2015

Member

they would be generated only for flavours that already have those data-types.

Member

jbgi commented Oct 31, 2015

they would be generated only for flavours that already have those data-types.

@talios

This comment has been minimized.

Show comment
Hide comment
@talios

talios Nov 2, 2015

Contributor

+2 - sounds good.

Contributor

talios commented Nov 2, 2015

+2 - sounds good.

@elucash

This comment has been minimized.

Show comment
Hide comment
@elucash

elucash Nov 3, 2015

2cents: why not have overload?

Function<ADT, R> otherwise(R value);
Function<ADT, R> otherwise(Supplier<R> value);

Things are only going bad if you have same erasure or ambiguous lambda parameter (Supplier<Supplier<>> ? unlikely to be used). And the symmetry is not harmed either as naming here is to accommodate return type, not input

elucash commented Nov 3, 2015

2cents: why not have overload?

Function<ADT, R> otherwise(R value);
Function<ADT, R> otherwise(Supplier<R> value);

Things are only going bad if you have same erasure or ambiguous lambda parameter (Supplier<Supplier<>> ? unlikely to be used). And the symmetry is not harmed either as naming here is to accommodate return type, not input

@jbgi

This comment has been minimized.

Show comment
Hide comment
@jbgi

jbgi Nov 3, 2015

Member

Yeah, let's try overloading. If not complaints from users' compilers we will keep it. thanks @elucash

Member

jbgi commented Nov 3, 2015

Yeah, let's try overloading. If not complaints from users' compilers we will keep it. thanks @elucash

@jbgi jbgi modified the milestones: 0.6, 0.5 Nov 10, 2015

@jbgi

This comment has been minimized.

Show comment
Hide comment
@jbgi

jbgi Dec 15, 2015

Member

overloading may not be a good idea, performance-wise. Current inference algo is slow in the presence of overloading: https://bugs.openjdk.java.net/browse/JDK-8051946 / http://stackoverflow.com/questions/34223249/slow-compilation-with-jooq-3-6-plain-sql-and-the-javac-compiler
I also worry that IDE code completion will be less useful.

Member

jbgi commented Dec 15, 2015

overloading may not be a good idea, performance-wise. Current inference algo is slow in the presence of overloading: https://bugs.openjdk.java.net/browse/JDK-8051946 / http://stackoverflow.com/questions/34223249/slow-compilation-with-jooq-3-6-plain-sql-and-the-javac-compiler
I also worry that IDE code completion will be less useful.

@jbgi jbgi closed this in 1782eff Dec 29, 2015

@jbgi

This comment has been minimized.

Show comment
Hide comment
@jbgi

jbgi Dec 29, 2015

Member

I left out otherwiseFail (Validation ), to reduce the amount of generated code (conversion from Either is easy).
I also gone the overload route. If problems arise overloads may be renamed in a later version.

Member

jbgi commented Dec 29, 2015

I left out otherwiseFail (Validation ), to reduce the amount of generated code (conversion from Either is easy).
I also gone the overload route. If problems arise overloads may be renamed in a later version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment