spebbe / dartz

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

Compile Error on Dart 2.3.3 #16

Closed CatherineThompson closed 5 years ago

CatherineThompson commented 5 years ago

I'm getting the following compiler message when trying to use dartz Options in a flutter project. It' on Dart 2.3.3.

    Compiler message:
    file:///Users/catherinethompson/.pub-cache/hosted/pub.dartlang.org/dartz-0.8.4/lib/src/endo.dart:5:7: Error: Found unsupported uses of 'A' in supertype 'Monoid'.
    class EndoMonoid<A> extends Monoid<Endo<A>> {
          ^
    file:///Users/catherinethompson/.pub-cache/hosted/pub.dartlang.org/dartz-0.8.4/lib/src/endo.dart:11:33: Error: A value of type 'EndoMonoid<dynamic>' can't be assigned to a variable of type 'Monoid<dynamic Function(dynamic)>'.
     - 'EndoMonoid' is from 'package:dartz/dartz.dart' ('file:///Users/catherinethompson/.pub-cache/hosted/pub.dartlang.org/dartz-0.8.4/lib/dartz.dart').
     - 'Monoid' is from 'package:dartz/dartz.dart' ('file:///Users/catherinethompson/.pub-cache/hosted/pub.dartlang.org/dartz-0.8.4/lib/dartz.dart').
    Try changing the type of the left hand side, or casting the right hand side to 'Monoid<dynamic Function(dynamic)>'.
    final Monoid<Endo> EndoMi = new EndoMonoid();
                                    ^
    file:///Users/catherinethompson/.pub-cache/hosted/pub.dartlang.org/dartz-0.8.4/lib/src/endo.dart:12:36: Error: A value of type 'EndoMonoid<dynamic>' can't be assigned to a variable of type 'Monoid<A Function(A)>'.
     - 'EndoMonoid' is from 'package:dartz/dartz.dart' ('file:///Users/catherinethompson/.pub-cache/hosted/pub.dartlang.org/dartz-0.8.4/lib/dartz.dart').
     - 'Monoid' is from 'package:dartz/dartz.dart' ('file:///Users/catherinethompson/.pub-cache/hosted/pub.dartlang.org/dartz-0.8.4/lib/dartz.dart').
    Try changing the type of the left hand side, or casting the right hand side to 'Monoid<A Function(A)>'.
    Monoid<Endo<A>> endoMi<A>() => new EndoMonoid();
                                       ^
spebbe commented 5 years ago

Hi and thanks for reporting!

This looks identical to https://github.com/spebbe/dartz/issues/12, which was closed a bit prematurely. A solution exists, but hasn't been released yet. I'll make a fix release soon and will keep this issue open until then.

spebbe commented 5 years ago

Released in 0.8.5 from master and rebased onto 0_9_0_wip_2