0

I have been investigating the use of the excellent functional library vavr

  // https://mvnrepository.com/artifact/io.vavr/vavr
compile group: 'io.vavr', name: 'vavr', version: '0.9.2'
// https://mvnrepository.com/artifact/io.vavr/vavr-match
compile group: 'io.vavr', name: 'vavr-match', version: '0.9.2'

Using this type of example:-

int input = 2;
        String output = Match(input).of(Case($(1), "one"), Case($(2), "two"), Case($(3), "three"), Case($(), "?"));

        assertEquals("two", output);

using these static imports

import static io.vavr.API.$;
import static io.vavr.API.Case;
import static io.vavr.API.Match;

However when I upgrade to

// https://mvnrepository.com/artifact/io.vavr/vavr
compile group: 'io.vavr', name: 'vavr', version: '1.0.0-alpha-2'

I can no longer resolve the io.vavr.API imports.

Where have these been refactored to in the most recent version of vavr?

Have they been removed altogether?

4

2 回答 2

2

io.vavr.API will still be part of Vavr 1.0, however, the contents most probably will be changed.

The alpha-* versions are increments. I will provide new features step-by-step in order to make them available for testing purposes.

I see that this is a bit confusing because my users expect more complete contents of an alpha version. Currently I'm working on that issue.

(Disclaimer: I'm the author of Vavr)

于 2019-02-15T18:59:20.303 回答
1

TL;DR Yes, it has been removed from 1.x.x.

Please have a look at this post, especially this part:

We can't change the Java language by ourselves. All features that try to do so, e.g. pattern matching and for comprehensions, will be moved to a separate module vavr-api. Because different Java 9 modules can't export the same package, the package name needs to be changed.

Please note that Java will come up with native pattern matching. Therefore the use of vavr-api is discouraged but it will still be maintained.

All main modules mentioned above (excluding vavr-api and the co-module vavr-match) will be available as one big bundle, called vavr-all-in-one.

I'm not up-to-date with the status of current work, however it will be no longer available in the core module.

于 2019-02-15T11:57:42.827 回答