haskell-repa / repa

High performance, regular, shape polymorphic parallel arrays.
repa.ouroborus.net
135 stars 36 forks source link

Cannot build with GHC 9.4 #26

Open ocharles opened 1 year ago

ocharles commented 1 year ago
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/ghxd25ms5lfpgcjxvj39vhb0r4ayws9f-repa-3.4.1.5.tar.gz
source root is repa-3.4.1.5
setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file repa-3.4.1.5/Setup.hs
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
Configure flags:
--prefix=/nix/store/alynchw9kljiahqzzda3r43aw08p4aaf-repa-lib-repa-3.4.1.5 lib:repa --package-db=clear --package-db=/nix/store/hdc321489p4iy14n94cwkl2ziaqxrgns-repa-lib-repa-3.4.1.5-config/lib/ghc-9.4.3/lib/package.conf.d --flags=-no-template-haskell --exact-configuration --dependency=vector=vector-0.13.0.0-EVobHunI92X1unxEGlt0nQ --dependency=QuickCheck=QuickCheck-2.14.2-8FHYQRR7kRJC6XvpdMgvgw --dependency=array=array-0.5.4.0 --dependency=base=base-4.17.0.0 --dependency=binary=binary-0.8.9.1 --dependency=bytestring=bytestring-0.11.3.1 --dependency=containers=containers-0.6.6 --dependency=deepseq=deepseq-1.4.8.0 --dependency=directory=directory-1.3.7.1 --dependency=exceptions=exceptions-0.10.5 --dependency=filepath=filepath-1.4.2.2 --dependency=ghc=ghc-9.4.3 --dependency=ghc-bignum=ghc-bignum-1.3 --dependency=ghc-boot=ghc-boot-9.4.3 --dependency=ghc-boot-th=ghc-boot-th-9.4.3 --dependency=ghc-compact=ghc-compact-0.1.0.0 --dependency=ghc-heap=ghc-heap-9.4.3 --dependency=ghc-prim=ghc-prim-0.9.0 --dependency=hpc=hpc-0.6.1.0 --dependency=integer-gmp=integer-gmp-1.1 --dependency=mtl=mtl-2.2.2 --dependency=parsec=parsec-3.1.15.0 --dependency=pretty=pretty-1.1.3.6 --dependency=process=process-1.6.16.0 --dependency=rts=rts-1.0.2 --dependency=stm=stm-2.5.1.0 --dependency=template-haskell=template-haskell-2.19.0.0 --dependency=terminfo=terminfo-0.4.1.5 --dependency=text=text-2.0.1 --dependency=time=time-1.12.2 --dependency=transformers=transformers-0.5.6.2 --dependency=unix=unix-2.7.3 --dependency=xhtml=xhtml-3000.2.2.1 --with-ghc=ghc --with-ghc-pkg=ghc-pkg --with-hsc2hs=hsc2hs --with-gcc=cc --with-ld=ld.gold --ghc-option=-optl-fuse-ld=gold --ld-option=-fuse-ld=gold --with-ar=ar --with-strip=strip --enable-executable-stripping --enable-library-stripping --enable-library-profiling --disable-profiling --enable-static --enable-shared --disable-coverage --enable-library-for-ghci --datadir=/nix/store/27hh8xlq8xqk31p72yz55biycvd1i164-repa-lib-repa-3.4.1.5-data/share/ghc-9.4.3 --profiling-detail=default --enable-split-sections 
Configuring library for repa-3.4.1.5..
@nix { "action": "setPhase", "phase": "buildPhase" }
building
Preprocessing library for repa-3.4.1.5..
Building library for repa-3.4.1.5..
[ 1 of 39] Compiling Data.Array.Repa.Eval.Elt ( Data/Array/Repa/Eval/Elt.hs, dist/build/Data/Array/Repa/Eval/Elt.o, dist/build/Data/Array/Repa/Eval/Elt.dyn_o )

Data/Array/Repa/Eval/Elt.hs:129:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a11 :: *
        Float# :: TYPE 'FloatRep
    • In the first argument of ‘touch#’, namely ‘f’
      In the expression: touch# f state
      In the expression:
        case touch# f state of state' -> (# state', () #)
    |
129 |   = IO (\state -> case touch# f state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:142:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a10 :: *
        Double# :: TYPE 'DoubleRep
    • In the first argument of ‘touch#’, namely ‘d’
      In the expression: touch# d state
      In the expression:
        case touch# d state of state' -> (# state', () #)
    |
142 |   = IO (\state -> case touch# d state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:156:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a9 :: *
        Int# :: TYPE 'IntRep
    • In the first argument of ‘touch#’, namely ‘i’
      In the expression: touch# i state
      In the expression:
        case touch# i state of state' -> (# state', () #)
    |
156 |   = IO (\state -> case touch# i state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:168:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a8 :: *
        Int8# :: TYPE 'Int8Rep
    • In the first argument of ‘touch#’, namely ‘w’
      In the expression: touch# w state
      In the expression:
        case touch# w state of state' -> (# state', () #)
    |
168 |   = IO (\state -> case touch# w state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:181:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a7 :: *
        Int16# :: TYPE 'Int16Rep
    • In the first argument of ‘touch#’, namely ‘w’
      In the expression: touch# w state
      In the expression:
        case touch# w state of state' -> (# state', () #)
    |
181 |   = IO (\state -> case touch# w state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:194:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a6 :: *
        Int32# :: TYPE 'Int32Rep
    • In the first argument of ‘touch#’, namely ‘w’
      In the expression: touch# w state
      In the expression:
        case touch# w state of state' -> (# state', () #)
    |
194 |   = IO (\state -> case touch# w state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:207:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a5 :: *
        Int64# :: TYPE 'Int64Rep
    • In the first argument of ‘touch#’, namely ‘w’
      In the expression: touch# w state
      In the expression:
        case touch# w state of state' -> (# state', () #)
    |
207 |   = IO (\state -> case touch# w state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:221:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a4 :: *
        Word# :: TYPE 'WordRep
    • In the first argument of ‘touch#’, namely ‘i’
      In the expression: touch# i state
      In the expression:
        case touch# i state of state' -> (# state', () #)
    |
221 |   = IO (\state -> case touch# i state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:234:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a3 :: *
        Word8# :: TYPE 'Word8Rep
    • In the first argument of ‘touch#’, namely ‘w’
      In the expression: touch# w state
      In the expression:
        case touch# w state of state' -> (# state', () #)
    |
234 |   = IO (\state -> case touch# w state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:247:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a2 :: *
        Word16# :: TYPE 'Word16Rep
    • In the first argument of ‘touch#’, namely ‘w’
      In the expression: touch# w state
      In the expression:
        case touch# w state of state' -> (# state', () #)
    |
247 |   = IO (\state -> case touch# w state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:260:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a1 :: *
        Word32# :: TYPE 'Word32Rep
    • In the first argument of ‘touch#’, namely ‘w’
      In the expression: touch# w state
      In the expression:
        case touch# w state of state' -> (# state', () #)
    |
260 |   = IO (\state -> case touch# w state of
    |                               ^

Data/Array/Repa/Eval/Elt.hs:273:31: error:
    • Couldn't match a lifted type with an unlifted type
      When matching types
        a0 :: *
        Word64# :: TYPE 'Word64Rep
    • In the first argument of ‘touch#’, namely ‘w’
      In the expression: touch# w state
      In the expression:
        case touch# w state of state' -> (# state', () #)
    |
273 |   = IO (\state -> case touch# w state of
    |                               ^
[ 2 of 39] Compiling Data.Array.Repa.Eval.Gang ( Data/Array/Repa/Eval/Gang.hs, dist/build/Data/Array/Repa/Eval/Gang.o, dist/build/Data/Array/Repa/Eval/Gang.dyn_o )
[ 3 of 39] Compiling Data.Array.Repa.Eval.Interleaved ( Data/Array/Repa/Eval/Interleaved.hs, dist/build/Data/Array/Repa/Eval/Interleaved.o, dist/build/Data/Array/Repa/Eval/Interleaved.dyn_o )
[ 4 of 39] Compiling Data.Array.Repa.Eval.Reduction ( Data/Array/Repa/Eval/Reduction.hs, dist/build/Data/Array/Repa/Eval/Reduction.o, dist/build/Data/Array/Repa/Eval/Reduction.dyn_o )
[ 5 of 39] Compiling Data.Array.Repa.Shape ( Data/Array/Repa/Shape.hs, dist/build/Data/Array/Repa/Shape.o, dist/build/Data/Array/Repa/Shape.dyn_o )
[ 6 of 39] Compiling Data.Array.Repa.Index ( Data/Array/Repa/Index.hs, dist/build/Data/Array/Repa/Index.o, dist/build/Data/Array/Repa/Index.dyn_o )
[ 7 of 39] Compiling Data.Array.Repa.Eval.Chunked ( Data/Array/Repa/Eval/Chunked.hs, dist/build/Data/Array/Repa/Eval/Chunked.o, dist/build/Data/Array/Repa/Eval/Chunked.dyn_o )
[ 8 of 39] Compiling Data.Array.Repa.Eval.Selection ( Data/Array/Repa/Eval/Selection.hs, dist/build/Data/Array/Repa/Eval/Selection.o, dist/build/Data/Array/Repa/Eval/Selection.dyn_o )
[10 of 39] Compiling Data.Array.Repa.Base ( Data/Array/Repa/Base.hs, dist/build/Data/Array/Repa/Base.o, dist/build/Data/Array/Repa/Base.dyn_o )
[11 of 39] Compiling Data.Array.Repa.Eval.Target ( Data/Array/Repa/Eval/Target.hs, dist/build/Data/Array/Repa/Eval/Target.o, dist/build/Data/Array/Repa/Eval/Target.dyn_o )
[12 of 39] Compiling Data.Array.Repa.Eval.Load ( Data/Array/Repa/Eval/Load.hs, dist/build/Data/Array/Repa/Eval/Load.o, dist/build/Data/Array/Repa/Eval/Load.dyn_o )
[13 of 39] Compiling Data.Array.Repa.Repr.HintSmall ( Data/Array/Repa/Repr/HintSmall.hs, dist/build/Data/Array/Repa/Repr/HintSmall.o, dist/build/Data/Array/Repa/Repr/HintSmall.dyn_o )
[30 of 39] Compiling Data.Array.Repa.Slice ( Data/Array/Repa/Slice.hs, dist/build/Data/Array/Repa/Slice.o, dist/build/Data/Array/Repa/Slice.dyn_o )
[34 of 39] Compiling Data.Array.Repa.Stencil.Base ( Data/Array/Repa/Stencil/Base.hs, dist/build/Data/Array/Repa/Stencil/Base.o, dist/build/Data/Array/Repa/Stencil/Base.dyn_o )
[36 of 39] Compiling Data.Array.Repa.Stencil.Partition ( Data/Array/Repa/Stencil/Partition.hs, dist/build/Data/Array/Repa/Stencil/Partition.o, dist/build/Data/Array/Repa/Stencil/Partition.dyn_o )
[37 of 39] Compiling Data.Array.Repa.Stencil.Template ( Data/Array/Repa/Stencil/Template.hs, dist/build/Data/Array/Repa/Stencil/Template.o, dist/build/Data/Array/Repa/Stencil/Template.dyn_o )

Data/Array/Repa/Stencil/Template.hs:50:9: warning: [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a pattern binding: Patterns of type ‘[String]’ not matched: []
   |
50 |         line1 : _       = lines str
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
isomorpheme commented 1 year ago

Looks like this change is what causes the errors:

mkWeak#, mkWeakNoFinalizer#, touch# and keepAlive# are now levity-polymorphic instead of representation-polymorphic. For instance:

mkWeakNoFinalizer#
  :: forall {l :: Levity} {k :: Levity}
            (a :: TYPE (BoxedRep l))
            (b :: TYPE (BoxedRep k)).
     a -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)

That is, the type signature now quantifies over the GHC.Exts.Levity of a instead of its GHC.Exts.RuntimeRep. In addition, this variable is now inferred, instead of specified, meaning that it is no longer eligible for visible type application. Note that b is now also levity-polymorphic, due to the change outlined in the previous point.

https://downloads.haskell.org/~ghc/9.4.5/docs/users_guide/9.4.1-notes.html

Specifically, I think this was introduced in MR !5877.

The fix seems to be to simply pass the boxed values to touch# instead of deconstructing first, e.g.

-  touch (F# f)
+  touch f
   = IO (\state -> case touch# f state of
                         state' -> (# state', () #))

I don't know if that could block optimizations or cause safety issues though.