Newcomer looking for help with changes to kind system

Shant Hairapetian shanth2600 at gmail.com
Tue Apr 6 17:34:01 UTC 2021


Hi Ben,
Thanks for the reply

> Incidentally, the collapse of LiftedRep and UnliftedRep will happen in
> GHC 9.2 (turning into `BoxedRep :: Levity -> RuntimeRep`).

Yes I believe this change was accidentally merged a few months ago then
reverted? I will keep that in mind.

> Can you provide a program that your patch rejects, as well as
> the full error that is produced?

My error is in stage 1 in the building of the ghc-bignum library. I have
attached the full error as well as the patch itself.

Thanks,
Shant



On Mon, Apr 5, 2021 at 7:41 PM Ben Gamari <ben at smart-cactus.org> wrote:

> Shant Hairapetian <shanth2600 at gmail.com> writes:
>
> > Hello,
> >
> > I’m a master’s student working on implementing the changes outlined in
> > “Kinds are Calling Conventions“ (
> > https://www.microsoft.com/en-us/research/uploads/prod/2020/03/kacc.pdf).
> I
> > have been working directly with Paul Downen but have hit some roadblocks.
> >
> > To sum up the changes to the kind system, I am attempting to modify the
> > “TYPE” type constructor to accept, rather than just a RuntimeRep, a
> record
> > type (called RuntimeInfo) comprised of a RuntimeRep and a CallingConv
> > (calling convention). The calling convention has an “Eval” constructor
> > which accepts a levity (effectively moving the levity information from
> the
> > representation to the calling convention. LiftedRep and UnliftedRep would
> > also be collapsed into a single PtrRep constructor) and a “Call”
> > constructor (denoting the arity of primitive, extensional functions,
> > see: Making
> > a Faster Curry with Extensional Types
> > <
> https://www.microsoft.com/en-us/research/uploads/prod/2019/07/arity-haskell-symposium-2019.pdf
> >)
> > which accepts a list of RuntimeRep’s. I have created and wired-in the new
> > RuntimeInfo and CallingConv types in GHC.Builtin.Types, as well as the
> > corresponding primitive types in GHC.Builtin.Types.Prim and have modified
> > the “TYPE” constructor to accept a RuntimeInfo rather than a RuntimeRep.
> >
> Hi Shant,
>
> It would be helpful to have a bit more information on the nature of your
> failure. Can you provide a program that your patch rejects, as well as
> the full error that is produced?
>
> Incidentally, the collapse of LiftedRep and UnliftedRep will happen in
> GHC 9.2 (turning into `BoxedRep :: Levity -> RuntimeRep`).
>
> Cheers,
>
> - Ben
>
>

-- 
Shant Hairapetian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20210406/e5196261/attachment-0001.html>
-------------- next part --------------

    libraries/ghc-bignum/src/GHC/Num/WordArray.hs:78:22: error:
        • Couldn't match type: 'TupleRep ('[] @RuntimeRep)
                         with: 'RInfo ('TupleRep ('[] @RuntimeRep)) 'GHC.Types.ConvEval
          Expected: (# State# s, MutableWordArray# s #)
            Actual: (# State# s, MutableByteArray# s #)
        • In the expression: newByteArray# (wordsToBytes# sz) s
          In an equation for ‘newWordArray#’:
              newWordArray# sz s = newByteArray# (wordsToBytes# sz) s
       |
    78 | newWordArray# sz s = newByteArray# (wordsToBytes# sz) s
       |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    libraries/ghc-bignum/src/GHC/Num/WordArray.hs:112:71: error:
        • Couldn't match a lifted type with an unlifted type
          When matching types
            b0 :: TYPE ('RInfo 'LiftedRep 'GHC.Types.ConvEval)
            WordArray# :: TYPE ('RInfo 'UnliftedRep 'GHC.Types.ConvEval)
          Expected: (# () | WordArray# #)
            Actual: (# () | b0 #)
        • In the expression: a
          In a case alternative: (# _, a #) -> a
          In the expression: case runRW# io of { (# _, a #) -> a }
        • Relevant bindings include
            a :: (# () | b0 #)
              (bound at libraries/ghc-bignum/src/GHC/Num/WordArray.hs:112:63)
        |
    112 | withNewWordArrayTrimedMaybe# sz act = case runRW# io of (# _, a #) -> a
        |                                                                       ^

    libraries/ghc-bignum/src/GHC/Num/WordArray.hs:117:40: error:
        • Couldn't match kind ‘RuntimeInfo’ with ‘RuntimeRep’
          When matching the kind of ‘'RInfo 'LiftedRep 'GHC.Types.ConvEval’
        • In the expression: ()
          In the expression: (# () | #)
          In the expression: (# s, (# () | #) #)
        |
    117 |                (# s, 0# #) -> (# s, (# () | #) #)
        |                                        ^^

    libraries/ghc-bignum/src/GHC/Num/WordArray.hs:120:48: error:
        • Couldn't match kind ‘RuntimeInfo’ with ‘RuntimeRep’
          When matching kinds
            'RInfo 'LiftedRep 'GHC.Types.ConvEval :: RuntimeInfo
            'RInfo 'UnliftedRep 'GHC.Types.ConvEval :: RuntimeInfo
        • In the expression: ba
          In the expression: (# | ba #)
          In the expression: (# s, (# | ba #) #)
        |
    120 |                      (# s, ba #) -> (# s, (# | ba #) #)
        |                                                ^^

    libraries/ghc-bignum/src/GHC/Num/WordArray.hs:431:31: error:
        • Couldn't match type: 'TupleRep ('[] @RuntimeRep)
                         with: 'RInfo ('TupleRep ('[] @RuntimeRep)) 'GHC.Types.ConvEval
          Expected: (# State# s, Word# #)
            Actual: (# State# s, Word# #)
        • In the expression: readWordArray# mwa i s2
          In a case alternative:
              (# s2, sz #)
                | isTrue# (i >=# sz) -> (# s2, 0## #)
                | isTrue# (i <# 0#) -> (# s2, 0## #)
                | True -> readWordArray# mwa i s2
          In the expression:
            case mwaSize# mwa s of {
              (# s2, sz #)
                | isTrue# (i >=# sz) -> (# s2, 0## #)
                | isTrue# (i <# 0#) -> (# s2, 0## #)
                | True -> readWordArray# mwa i s2 }
        |
    431 |       | True               -> readWordArray# mwa i s2
        |                               ^^^^^^^^^^^^^^^^^^^^^^^

    libraries/ghc-bignum/src/GHC/Num/WordArray.hs:434:12: error:
        • Couldn't match type: 'TupleRep ('[] @RuntimeRep)
                         with: 'RInfo ('TupleRep ('[] @RuntimeRep)) 'GHC.Types.ConvEval
          Expected: MutableWordArray# s
                    -> Int# -> State# s -> (# State# s, Word# #)
            Actual: MutableByteArray# s
                    -> Int# -> State# s -> (# State# s, Word# #)
        • In the expression: readWordArray#
          In an equation for ‘mwaRead#’: mwaRead# = readWordArray#
        |
    434 | mwaRead# = readWordArray#
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KACC.patch
Type: application/octet-stream
Size: 45138 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20210406/e5196261/attachment-0001.obj>


More information about the ghc-devs mailing list