spebbe / dartz

Functional programming in Dart
MIT License
755 stars 59 forks source link

Dart 2.0.0-dev.69.0 has more VM runtime problems similar to #7 #8

Closed rich-j closed 6 years ago

rich-j commented 6 years ago

Upgrading to Dart VM version: 2.0.0-dev.69.0 (Tue Jul 17 14:57:16 2018 +0200) on "macos_x64" now causes failures when running unit tests under the VM. This seems similar to https://github.com/spebbe/dartz/issues/7. Using your ddc_compat branch and still run fine under DDC. Here are the load errors that now cause all unit tests to fail when run in the VM:

Unable to spawn isolate: file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/either.dart:70:26: Error: Declared type variables of 'EitherMonad::map4' doesn't match those on overridden method 'Applicative::map4'.
  @override Either<L, E> map4<A, A2 extends A, B, B2 extends B, C, C2 extends C, D, D2 extends D, E>(Either<L, A2> fa, Either<L, B2> fb, Either<L, C2> fc, Either<L, D2> fd, E fun(A a, B b, C c, D d)) =>
                         ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/either.dart:67:26: Error: Declared type variables of 'EitherMonad::map3' doesn't match those on overridden method 'Applicative::map3'.
  @override Either<L, D> map3<A, A2 extends A, B, B2 extends B, C, C2 extends C, D>(Either<L, A2> fa, Either<L, B2> fb, Either<L, C2> fc, D fun(A a, B b, C c)) =>
                         ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/either.dart:64:26: Error: Declared type variables of 'EitherMonad::map2' doesn't match those on overridden method 'Applicative::map2'.
  @override Either<L, C> map2<A, A2 extends A, B, B2 extends B, C>(Either<L, A2> fa, Either<L, B2> fb, C fun(A a, B b)) =>
                         ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/either.dart:76:26: Error: Declared type variables of 'EitherMonad::map6' doesn't match those on overridden method 'Applicative::map6'.
  @override Either<L, G> map6<A, A2 extends A, B, B2 extends B, C, C2 extends C, D, D2 extends D, E, E2 extends E, F, F2 extends F, G>(Either<L, A2> fa, Either<L, B2> fb, Either<L, C2> fc, Either<L, D2> fd, Either<L, E2> fe, Either<L, F2> ff, G fun(A a, B b, C c, D d, E e, F f)) =>
                         ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/either.dart:73:26: Error: Declared type variables of 'EitherMonad::map5' doesn't match those on overridden method 'Applicative::map5'.
  @override Either<L, F> map5<A, A2 extends A, B, B2 extends B, C, C2 extends C, D, D2 extends D, E, E2 extends E, F>(Either<L, A2> fa, Either<L, B2> fb, Either<L, C2> fc, Either<L, D2> fd, Either<L, E2> fe, F fun(A a, B b, C c, D d, E e)) =>
                         ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/free.dart:70:24: Error: Declared type variables of 'FreeMonad::map4' doesn't match those on overridden method 'Applicative::map4'.
  @override Free<F, E> map4<A, A2 extends A, B, B2 extends B, C, C2 extends C, D, D2 extends D, E>(Free<F, A2> fa, Free<F, B2> fb, Free<F, C2> fc, Free<F, D2> fd, E fun(A a, B b, C c, D d)) =>
                       ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/free.dart:67:24: Error: Declared type variables of 'FreeMonad::map3' doesn't match those on overridden method 'Applicative::map3'.
  @override Free<F, D> map3<A, A2 extends A, B, B2 extends B, C, C2 extends C, D>(Free<F, A2> fa, Free<F, B2> fb, Free<F, C2> fc, D fun(A a, B b, C c)) =>
                       ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/free.dart:64:24: Error: Declared type variables of 'FreeMonad::map2' doesn't match those on overridden method 'Applicative::map2'.
  @override Free<F, C> map2<A, A2 extends A, B, B2 extends B, C>(Free<F, A2> fa, Free<F, B2> fb, C fun(A a, B b)) =>
                       ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/free.dart:76:24: Error: Declared type variables of 'FreeMonad::map6' doesn't match those on overridden method 'Applicative::map6'.
  @override Free<F, G> map6<A, A2 extends A, B, B2 extends B, C, C2 extends C, D, D2 extends D, E, E2 extends E, FF, F2 extends FF, G>(Free<F, A2> fa, Free<F, B2> fb, Free<F, C2> fc, Free<F, D2> fd, Free<F, E2> fe, Free<F, F2> ff, G fun(A a, B b, C c, D d, E e, FF f)) =>
                       ^
file:///Users/richj/.pub-cache/git/dartz-c789fc294ebde28cfd5318b9954faa3927630e2f/lib/src/free.dart:73:25: Error: Declared type variables of 'FreeMonad::map5' doesn't match those on overridden method 'Applicative::map5'.
  @override Free<F, FF> map5<A, A2 extends A, B, B2 extends B, C, C2 extends C, D, D2 extends D, E, E2 extends E, FF>(Free<F, A2> fa, Free<F, B2> fb, Free<F, C2> fc, Free<F, D2> fd, Free<F, E2> fe, FF fun(A a, B b, C c, D d, E e)) =>
                        ^
spebbe commented 6 years ago

Hi and thanks for reporting!

They are really tightening the noose on me now :-)

I've pushed a change on ddc_compat where all the previously overridden mapX/liftX operations are moved from the Applicative instance for a type to static methods on the type itself. For example, OptionMP.map2(some(1), some(2), (int a, int b) => a+b) is now Option.map2(some(1), some(2), (int a, int b) => a+b).

I've also started to add some type specialized traverse/sequence operations, such as IList#traverseOption here and there, which will eventually completely replace the generic traverse/sequence mechanism. These should work in a fully type safe way on both Dart 1 and 2.

Hope that keeps you going until the next Dart 2 dev release :-)

rich-j commented 6 years ago

Thanks - our unit tests are running again in the VM. Also I was able to change some ugly code over to using traverseX operations. Too bad they need to be specialized - I guess it's progress...

Google is in clean up mode since Dart 2 stable is "happening very soon". You may have already seen this: Getting ready for Dart 2, and making your packages look great on the Pub site!.