spell-music / csound-expression

Haskell Framework for Electronic Music
320 stars 31 forks source link

build errors with ghc-9.8 (-Wall -Werror, head is partial) #86

Closed jwaldmann closed 6 months ago

jwaldmann commented 7 months ago
[ 4 of 17] Compiling Csound.Dynamic.Tfm.InferTypes ( src/Csound/Dynamic/Tfm/InferTypes.hs, dist/build/Csound/Dynamic/Tfm/InferTypes.o, dist/build/Csound/Dynamic/Tfm/InferTypes.dyn_o )

src/Csound/Dynamic/Tfm/InferTypes.hs:280:23: error: [GHC-63394] [-Wx-partial, -Werror=x-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
    |
280 |           then pure $ head $ Map.toList rateTab
    |                       ^^^^

src/Csound/Dynamic/Tfm/InferTypes.hs:288:42: error: [GHC-63394] [-Wx-partial, -Werror=x-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
    |
288 |     findSignature args allOpcRates = go (head allOpcRates) Nothing allOpcRates
    |                                          ^^^^
anton-k commented 6 months ago

Thanks for report. Fixed this and uploaded new version to the hackage

jwaldmann commented 6 months ago

Hi Anton. Thanks for working on this. I can build from source with ghc-9.8 (clone the repo, then cabal install all) but I cannot build from hackage:

$ cabal update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org has been updated.
The index-state is set to 2024-02-18T12:44:28Z.
...

$ cabal install --lib csound-expression --package-env=cse
...
Building library for csound-expression-typed-0.2.7..
[ 1 of 63] Compiling Csound.Typed.Constants ( src/Csound/Typed/Constants.hs, dist/build/Csound/Typed/Constants.o, dist/build/Csound/Typed/Constants.dyn_o )
[ 2 of 63] Compiling Csound.Typed.GlobalState.Cache ( src/Csound/Typed/GlobalState/Cache.hs, dist/build/Csound/Typed/GlobalState/Cache.o, dist/build/Csound/Typed/GlobalState/Cache.dyn_o )
[ 3 of 63] Compiling Csound.Typed.GlobalState.Opcodes ( src/Csound/Typed/GlobalState/Opcodes.hs, dist/build/Csound/Typed/GlobalState/Opcodes.o, dist/build/Csound/Typed/GlobalState/Opcodes.dyn_o )

src/Csound/Typed/GlobalState/Opcodes.hs:91:11: error: [GHC-83865]
    • Couldn't match expected type ‘IfRate’ with actual type ‘Rate’
...
src/Csound/Typed/GlobalState/Opcodes.hs:92:9: error: [GHC-83865]
    • Couldn't match type ‘()’ with ‘CodeBlock E’
      Expected: DepT m (CodeBlock E)
        Actual: DepT m ()
...
src/Csound/Typed/GlobalState/Opcodes.hs:129:21: error: [GHC-83865]
    • Couldn't match type ‘[Char]’
                     with ‘text-2.1:Data.Text.Internal.Text’
      Expected: Name
        Actual: String
    • In the first argument of ‘opcs’, namely ‘"sprintf"’
      In the expression: opcs "sprintf" [(Sr, Sr : repeat Ir)] (a : as)
anton-k commented 6 months ago

By some strange reason cabal does not apply extension OverloadedStrings on install. Although it is set in the cabal file.

anton-k commented 6 months ago
cabal update

Will fix that. by some stranger reason revision over hackage site erased some extensions.