isovector / do-notation

deprecated in favor of -XQualifiedDo
BSD 3-Clause "New" or "Revised" License
41 stars 5 forks source link

do-notation tests don't compile with GHC-9.0.2 #5

Closed bluescreen303 closed 2 years ago

bluescreen303 commented 2 years ago

Although the package itself compiles, compiling the tests fails:

Preprocessing library for do-notation-0.1.0.2..
Building library for do-notation-0.1.0.2..
[1 of 3] Compiling Control.Monad.Trans.Ix ( src/Control/Monad/Trans/Ix.hs, dist/build/Control/Monad/Trans/Ix.o, dist/build/Control/Monad/Trans/Ix.dyn_o )
[2 of 3] Compiling Language.Haskell.DoNotation ( src/Language/Haskell/DoNotation.hs, dist/build/Language/Haskell/DoNotation.o, dist/build/Language/Haskell/DoN>
[3 of 3] Compiling Paths_do_notation ( dist/build/autogen/Paths_do_notation.hs, dist/build/Paths_do_notation.o, dist/build/Paths_do_notation.dyn_o )
[1 of 3] Compiling Control.Monad.Trans.Ix ( src/Control/Monad/Trans/Ix.hs, dist/build/Control/Monad/Trans/Ix.p_o )
[2 of 3] Compiling Language.Haskell.DoNotation ( src/Language/Haskell/DoNotation.hs, dist/build/Language/Haskell/DoNotation.p_o )
[3 of 3] Compiling Paths_do_notation ( dist/build/autogen/Paths_do_notation.hs, dist/build/Paths_do_notation.p_o )
Preprocessing test suite 'do-notation-test' for do-notation-0.1.0.2..
Building test suite 'do-notation-test' for do-notation-0.1.0.2..
[1 of 2] Compiling Main             ( test/Spec.hs, dist/build/do-notation-test/do-notation-test-tmp/Main.o )

test/Spec.hs:66:13: error:
    • Couldn't match type ‘a0’
                     with ‘forall s.
                           Linear s ('LinearState 0 '[]) ('LinearState n '[]) a’
      Expected: (forall s.
                 Linear s ('LinearState 0 '[]) ('LinearState n '[]) a)
                -> IO a
        Actual: a0 -> IO a
      Cannot instantiate unification variable ‘a0’
      with a type involving polytypes:
        forall s. Linear s ('LinearState 0 '[]) ('LinearState n '[]) a
    • In the expression: coerce
      In an equation for ‘runLinear’: runLinear = coerce
    • Relevant bindings include
        runLinear :: (forall s.
                      Linear s ('LinearState 0 '[]) ('LinearState n '[]) a)
                     -> IO a
          (bound at test/Spec.hs:66:1)
   |
66 | runLinear = coerce
   |             ^^^^^^

Ignoring this (skipping tests) leads to very similar errors on the usage site.

isovector commented 2 years ago

The issue here is that quicklook in 9.2 changed how rank-n types typecheck. Eta expanding things should fix it, but I don't understand what you mean by

Ignoring this (skipping tests) leads to very similar errors on the usage site.

Which usage site do you mean?

I'm happy to push a fix for the eta expansion, but I think this package is obsoleted by qualified do

bluescreen303 commented 2 years ago

What I meant was that when I skip testing do-notation, my own code (the usage site) throws very similar errors as these tests do.

I will have a look at qualified do first.

I haven't been following new haskell developments for a while now, so I wasn't aware of that. The reason I'm still using do-notation is because my CI system started to complain about all the example / tryout code I have based on your book "thinking with types" when nixpkgs default ghc got updated to 9.0.2 :)

If I can change to qualified do easily I will close this issue. I'll let you know in a few days.

bluescreen303 commented 2 years ago

I can confirm that the eta expansion does the trick. But after that, I managed to indeed just get rid of do-notation in full by using the QualifiedDo extension. Thanks for pointing this out!

isovector commented 2 years ago

No problem, glad you figured it out! I'll archive this repo towards that end.