Help getting PolyKinds over the line

In the meantime, I think I’ve removed all the kind imports are deprecated and # type deprecated compiler warnings…

Also, for the below error, the only thing I can find that has that particular type signature in the library seems to be liftOpt (https://github.com/JordanMartinez/purescript/blob/feaaf3af8b6ecaa4a70aa1f64d9188b56c23dec0/tests/support/.spago/optparse/v3.0.1/src/Options/Applicative/Common.purs#L56-L58):

Error 6 of 9:

  in module Options.Applicative.Types
  at .spago/optparse/v3.0.1/src/Options/Applicative/Types.purs:103:1 - 113:4 (line 103, column 1 - line 113, column 4)
  at :0:0 - 0:0 (line 0, column 0 - line 0, column 0)

    Cannot unambiguously generalize kinds appearing in the elaborated type:

      forall (a :: Type). Option @t60 a -> Parser a

    where t60 is an unknown kind.
    Try adding additional kind signatures or polymorphic kind variables.

  in data binding group ParserInfo, Parser, Option, OptReader, CReader, ReadM, ParseError, SomeParser, MultPE

  See https://github.com/purescript/documentation/blob/master/errors/QuantificationCheckFailureInType.md for more information,
  or to contribute content related to this error.

@natefaubion Edit: I can now compile the entire package set using the PolyKinds PR.

Here’s the errors that stack test reports, most of which are likely because Spago is being used rather than Bower.

  repl
    completionTests
      :b Eff:                                                                                                                                                                                                            FAIL
        expected: [":b Effect",":b Effect.Class",":b Effect.Class.Console",":b Effect.Console",":b Effect.Ref",":b Effect.Uncurried",":b Effect.Unsafe"]
         but got: [":b Effect",":b Effect.AVar",":b Effect.Aff",":b Effect.Aff.AVar",":b Effect.Aff.Bus",":b Effect.Aff.Class",":b Effect.Aff.Compat",":b Effect.Aff.Retry",":b Effect.Class",":b Effect.Class.Console",":b Effect.Console",":b Effect.Exception",":b Effect.Exception.Unsafe",":b Effect.Now",":b Effect.Promise",":b Effect.Promise.Console",":b Effect.Promise.Nonstandard",":b Effect.Promise.Unsafe",":b Effect.Random",":b Effect.Ref",":b Effect.Timer",":b Effect.Uncurried",":b Effect.Unsafe"]
      :b Effect.:                                                                                                                                                                                                        FAIL
        expected: [":b Effect.Class",":b Effect.Class.Console",":b Effect.Console",":b Effect.Ref",":b Effect.Uncurried",":b Effect.Unsafe"]
         but got: [":b Effect.AVar",":b Effect.Aff",":b Effect.Aff.AVar",":b Effect.Aff.Bus",":b Effect.Aff.Class",":b Effect.Aff.Compat",":b Effect.Aff.Retry",":b Effect.Class",":b Effect.Class.Console",":b Effect.Console",":b Effect.Exception",":b Effect.Exception.Unsafe",":b Effect.Now",":b Effect.Promise",":b Effect.Promise.Console",":b Effect.Promise.Nonstandard",":b Effect.Promise.Unsafe",":b Effect.Random",":b Effect.Ref",":b Effect.Timer",":b Effect.Uncurried",":b Effect.Unsafe"]
      import Eff:                                                                                                                                                                                                        FAIL
        expected: ["import Effect","import Effect.Class","import Effect.Class.Console","import Effect.Console","import Effect.Ref","import Effect.Uncurried","import Effect.Unsafe"]
         but got: ["import Effect","import Effect.AVar","import Effect.Aff","import Effect.Aff.AVar","import Effect.Aff.Bus","import Effect.Aff.Class","import Effect.Aff.Compat","import Effect.Aff.Retry","import Effect.Class","import Effect.Class.Console","import Effect.Console","import Effect.Exception","import Effect.Exception.Unsafe","import Effect.Now","import Effect.Promise","import Effect.Promise.Console","import Effect.Promise.Nonstandard","import Effect.Promise.Unsafe","import Effect.Random","import Effect.Ref","import Effect.Timer","import Effect.Uncurried","import Effect.Unsafe"]
      import Effect.:                                                                                                                                                                                                    FAIL
        expected: ["import Effect.Class","import Effect.Class.Console","import Effect.Console","import Effect.Ref","import Effect.Uncurried","import Effect.Unsafe"]
         but got: ["import Effect.AVar","import Effect.Aff","import Effect.Aff.AVar","import Effect.Aff.Bus","import Effect.Aff.Class","import Effect.Aff.Compat","import Effect.Aff.Retry","import Effect.Class","import Effect.Class.Console","import Effect.Console","import Effect.Exception","import Effect.Exception.Unsafe","import Effect.Now","import Effect.Promise","import Effect.Promise.Console","import Effect.Promise.Nonstandard","import Effect.Promise.Unsafe","import Effect.Random","import Effect.Ref","import Effect.Timer","import Effect.Uncurried","import Effect.Unsafe"]

    commandTests
      :print:                                                                                                                                                                                                            Error found:
in module $PSCI
at <internal>:0:0 - 0:0 (line 0, column 0 - line 0, column 0)

  Could not match type
          
    String
          
  with type
             
    Effect t0
             

while checking that type String
  is at least as general as type Effect t0
while checking that expression show it
  has type Effect t0
in value declaration $main

where t0 is an unknown type

See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
or to contribute content related to this error.

  publish
    preparePackage with json roundtrips
      purescript-prelude:                                                                                                                                                                                                FAIL
        uncaught exception: IOException of type NoSuchThing
        tests/support/bower_components/purescript-prelude: changeWorkingDirectory: does not exist (No such file or directory)
      basic example:                                                                                                                                                                                                     FAIL (0.08s)
        Failed to produce JSON from tests/purs/publish/basic-example:
        There is a problem with your package, which meant that it could not be                                                                                    
        published.                                                                                                                                                
        Details:                                                                                                                                                  
          Compile error:                                                                                                                                          
            Error 1 of 4:                                                                                                                                         
              in module Main                                                                                                                             
              at /home/jordan/Programming/Git Projects/purescript/tests/purs/publish/basic-example/src/Main.purs:3:1 - 3:15 (line 3, column 1 - line 3, column 15)
                                                                                                                                                                  
                Module Prelude was not found.                                                                                                            
                Make sure the source file exists, and that it has been provided as an input to the compiler.                                                      
                                                                                                                                                                  
                                                                                                                                                                  
              See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,                                          
              or to contribute content related to this error.                                                                                                     
            Error 2 of 4:                                                                                                                                         
              in module Main                                                                                                                             
              at /home/jordan/Programming/Git Projects/purescript/tests/purs/publish/basic-example/src/Main.purs:4:1 - 4:23 (line 4, column 1 - line 4, column 23)
                                                                                                                                                                  
                Module Effect was not found.                                                                                                             
                Make sure the source file exists, and that it has been provided as an input to the compiler.                                                      
                                                                                                                                                                  
                                                                                                                                                                  
              See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,                                          
              or to contribute content related to this error.                                                                                                     
            Error 3 of 4:                                                                                                                                         
              in module Main                                                                                                                             
              at /home/jordan/Programming/Git Projects/purescript/tests/purs/publish/basic-example/src/Main.purs:5:1 - 5:28 (line 5, column 1 - line 5, column 28)
                                                                                                                                                                  
                Module Effect.Console was not found.                                                                                                     
                Make sure the source file exists, and that it has been provided as an input to the compiler.                                                      
                                                                                                                                                                  
                                                                                                                                                                  
              See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,                                          
              or to contribute content related to this error.                                                                                                     
            Error 4 of 4:                                                                                                                                         
              in module Main                                                                                                                             
              at /home/jordan/Programming/Git Projects/purescript/tests/purs/publish/basic-example/src/Main.purs:6:1 - 6:40 (line 6, column 1 - line 6, column 40)
                                                                                                                                                                  
                Module Data.Newtype was not found.                                                                                                       
                Make sure the source file exists, and that it has been provided as an input to the compiler.                                                      
                                                                                                                                                                  
                                                                                                                                                                  
              See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,                                          
              or to contribute content related to this error.                                                                                                     
      basic example with legacy resolutions file:                                                                                                                                                                        FAIL (0.07s)
        Failed to produce JSON from tests/purs/publish/basic-example:
        There is a problem with your package, which meant that it could not be                                                                                    
        published.                                                                                                                                                
        Details:                                                                                                                                                  
          Compile error:                                                                                                                                          
            Error 1 of 4:                                                                                                                                         
              in module Main                                                                                                                             
              at /home/jordan/Programming/Git Projects/purescript/tests/purs/publish/basic-example/src/Main.purs:3:1 - 3:15 (line 3, column 1 - line 3, column 15)
                                                                                                                                                                  
                Module Prelude was not found.                                                                                                            
                Make sure the source file exists, and that it has been provided as an input to the compiler.                                                      
                                                                                                                                                                  
                                                                                                                                                                  
              See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,                                          
              or to contribute content related to this error.                                                                                                     
            Error 2 of 4:                                                                                                                                         
              in module Main                                                                                                                             
              at /home/jordan/Programming/Git Projects/purescript/tests/purs/publish/basic-example/src/Main.purs:4:1 - 4:23 (line 4, column 1 - line 4, column 23)
                                                                                                                                                                  
                Module Effect was not found.                                                                                                             
                Make sure the source file exists, and that it has been provided as an input to the compiler.                                                      
                                                                                                                                                                  
                                                                                                                                                                  
              See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,                                          
              or to contribute content related to this error.                                                                                                     
            Error 3 of 4:                                                                                                                                         
              in module Main                                                                                                                             
              at /home/jordan/Programming/Git Projects/purescript/tests/purs/publish/basic-example/src/Main.purs:5:1 - 5:28 (line 5, column 1 - line 5, column 28)
                                                                                                                                                                  
                Module Effect.Console was not found.                                                                                                     
                Make sure the source file exists, and that it has been provided as an input to the compiler.                                                      
                                                                                                                                                                  
                                                                                                                                                                  
              See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,                                          
              or to contribute content related to this error.                                                                                                     
            Error 4 of 4:                                                                                                                                         
              in module Main                                                                                                                             
              at /home/jordan/Programming/Git Projects/purescript/tests/purs/publish/basic-example/src/Main.purs:6:1 - 6:40 (line 6, column 1 - line 6, column 40)
                                                                                                                                                                  
                Module Data.Newtype was not found.                                                                                                       
                Make sure the source file exists, and that it has been provided as an input to the compiler.                                                      
                                                                                                                                                                  
                                                                                                                                                                  
              See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,                                          
              or to contribute content related to this error.

@natefaubion Latest error message now that I’ve added your “coercible merge” commits. The error is caused by a row having the label role in it:

Line where error occurs: https://github.com/JordanMartinez/purescript/blob/useSpagoForSupport/tests/support/.spago/react-basic/v13.0.0/src/React/Basic/DOM/Generated.purs#L134

Error found:
at .spago/react-basic/v13.0.0/src/React/Basic/DOM/Generated.purs:134:5 - 134:9 (line 134, column 5 - line 134, column 9)

  Unable to parse module:
  Unexpected token 'role'


See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
or to contribute content related to this error.

You’ll see this error in master. It’s because the parser changes for contextual keywords in role declarations didn’t account for labels, so role, phantom, representational, and nominal can’t currently be used as unquoted labels. I’ll fix this in my PR, or someone else can do it in a separate PR.

I rebased useSpagoForSupport again on top of the changes you made that fixed the role parsing error. The good news is that I don’t get any compiler errors. However, isn’t that a bit surprising? I don’t think we updated Map, which I thought would trigger such an error.

However, isn’t that a bit surprising? I don’t think we updated Map , which I thought would trigger such an error.

What do you mean?

I thought the Coercible changes were going to force us to update Map to something like

type Map role nominal representational

or something like that. (I’m still not familiar with the Coercible PR’s syntax updates).

So, I was expecting to get a compiler error on my end where I’d have to update that library before the entire package set would compile.

It doesn’t force you to do anything. It can’t really. The point of roles is that there is a way to tell the compiler if there is an invariant that is not described in the type system. Map maintains an invariant that it’s representation depends on the Ord instance of k, however there is nothing in the type Map k a that states this to the compiler. It’s maintained as part of the interface. By default, for normal data types, the compiler will assume that it’s OK to coerce types under the type constructor for things that are representationally equivalent. An annotation needs to be added for data types where this is not a safe assumption. Map compiles, but you might get garbage without the annotation if you try to coerce between things that have different Ord instances but are otherwise representationally equal. It needs a role annotation that the k parameter is nominal.

Ah, gotcha.

Ok, so is the PolyKinds PR done now?

I think the implementation is as done as it can be. It needs an actual review.

2 Likes

I am going to do my best to review Soon™

The PR has been merged! :tada:

20 Likes