diagrams / diagrams-lib

Diagrams standard library
https://diagrams.github.io/
Other
138 stars 62 forks source link

Does not build with ghc 8.2 #297

Closed edsko closed 7 years ago

edsko commented 7 years ago

Trying to build with ghc 8.2 this yields

src/Diagrams/Names.hs:50:10: warning: [-Wsimplifiable-class-constraints]
    • The constraint ‘OrderedField n’ matches an instance declaration
      instance (Floating s, Ord s) => OrderedField s
        -- Defined in ‘Diagrams.Core.Envelope’
      This makes type inference for inner bindings fragile;
        either use MonoLocalBinds, or simplify it using the instance
    • In the type signature:
        named :: (IsName nm, Metric v, OrderedField n, Semigroup m) =>
                 nm -> QDiagram b v n m -> QDiagram b v n m
   |
50 | named :: (IsName nm, Metric v, OrderedField n, Semigroup m)
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

src/Diagrams/Names.hs:57:14: warning: [-Wsimplifiable-class-constraints]
    • The constraint ‘OrderedField n’ matches an instance declaration
      instance (Floating s, Ord s) => OrderedField s
        -- Defined in ‘Diagrams.Core.Envelope’
      This makes type inference for inner bindings fragile;
        either use MonoLocalBinds, or simplify it using the instance
    • In the type signature:
        namePoint :: (IsName nm, Metric v, OrderedField n, Semigroup m) =>
                     (QDiagram b v n m -> Point v n)
                     -> nm -> QDiagram b v n m -> QDiagram b v n m
   |
57 | namePoint :: (IsName nm , Metric v, OrderedField n, Semigroup m)
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
[ 5 of 73] Compiling Diagrams.Parametric ( src/Diagrams/Parametric.hs, dist/build/Diagrams/Parametric.o )

src/Diagrams/Parametric.hs:58:11: error:
    • The default type signature for domainUpper:
        forall n. Num n => p -> n
      does not match its corresponding non-default type signature
    • When checking the class method:
        domainUpper :: forall p. DomainBounds p => p -> N p
      In the class declaration for ‘DomainBounds’
   |
58 |   default domainUpper :: Num n => p -> n
   |           ^^^^^^^^^^^
cchalmers commented 7 years ago

The error was fixed with 7045ba725f64ef3db80e778a7bc4fdd8f6555f7e. We just need a new release for 8.2 compatibility?

I don't really understand thesimplifiable-class-constraints warnings.

cchalmers commented 7 years ago

I've fixed the warnings by adding MonoLocalBinds to the offending modules (5ae5de8ad2f093b15ebecaa9b8d9dd1a37cd7d46).

bergey commented 7 years ago

It sounds as though 8.2 doesn't like the way we use type classes as constraint synonyms. GHC has had explicit support for constraint synonyms for a while. Maybe we should convert to them? I think they would make our intentions more clear.

AFAICT there's nothing wrong with using MonoLocalBinds either; it seems to be turned on by other extensions in most modules.

byorgey commented 7 years ago

Released diagrams-lib-1.4.1 with this fix in (as well as a few minor accumulated API additions).

@bergey , I had actually started replacing some such type-classes-as-constraint-synonyms (https://github.com/diagrams/diagrams-core/commit/2e51c505719a3e589fb010b752fdf203ffbe494d) but it broke things on GHC 7.8 which we still support at the moment. I agree we ought to do this eventually though.