spell-music / csound-expression

Haskell Framework for Electronic Music
320 stars 31 forks source link

error building on ghc 9.2.8 / cabal 3.6.2 #83

Closed shakfu closed 6 months ago

shakfu commented 1 year ago
% cabal install csound-expression --lib
Resolving dependencies...
Build profile: -w ghc-9.2.8 -O1
In order, the following will be built (use -v for more details):
 - Boolean-0.2.4 (lib:Boolean) (requires build)
 - NumInstances-1.4 (lib) (requires build)
 - colour-2.3.6 (lib) (requires build)
 - dlist-1.0 (lib) (requires build)
 - data-default-class-0.1.2.0 (lib:data-default-class) (requires build)
 - data-array-byte-0.1.0.1 (lib) (requires download & build)
 - old-locale-1.0.0.7 (lib) (requires build)
 - th-abstraction-0.5.0.0 (lib) (requires download & build)
 - transformers-compat-0.7.2 (lib) (requires download & build)
 - wl-pprint-1.2.1 (lib:wl-pprint) (requires build)
 - temporal-media-0.6.3 (lib:temporal-media) (requires build)
 - data-default-instances-dlist-0.0.1 (lib:data-default-instances-dlist) (requires build)
 - data-default-instances-containers-0.0.1 (lib:data-default-instances-containers) (requires build)
 - hashable-1.4.2.0 (lib) (requires download & build)
 - data-default-instances-old-locale-0.0.1 (lib:data-default-instances-old-locale) (requires build)
 - deriving-compat-0.6.3 (lib) (requires download & build)
 - data-fix-0.3.2 (lib) (requires build)
 - data-default-0.7.1.1 (lib:data-default) (requires build)
 - data-fix-cse-0.0.3 (lib) (requires build)
 - csound-expression-dynamic-0.3.9 (lib) (requires build)
 - csound-expression-typed-0.2.7 (lib) (requires build)
 - csound-expression-opcodes-0.0.5.1 (lib) (requires build)
 - csound-expression-5.4.3 (lib) (requires build)
Downloading  transformers-compat-0.7.2
Starting     Boolean-0.2.4 (all, legacy fallback)
Starting     NumInstances-1.4 (lib)
Starting     old-locale-1.0.0.7 (lib)
Starting     colour-2.3.6 (lib)
Starting     dlist-1.0 (lib)
Starting     data-default-class-0.1.2.0 (all, legacy fallback)
Downloaded   transformers-compat-0.7.2
Downloading  data-array-byte-0.1.0.1
Downloaded   data-array-byte-0.1.0.1
Downloading  th-abstraction-0.5.0.0
Starting     data-array-byte-0.1.0.1 (lib)
Downloaded   th-abstraction-0.5.0.0
Downloading  deriving-compat-0.6.3
Starting     th-abstraction-0.5.0.0 (lib)
Downloaded   deriving-compat-0.6.3
Downloading  hashable-1.4.2.0
Downloaded   hashable-1.4.2.0
Building     dlist-1.0 (lib)
Building     NumInstances-1.4 (lib)
Building     colour-2.3.6 (lib)
Building     data-array-byte-0.1.0.1 (lib)
Building     old-locale-1.0.0.7 (lib)
Building     data-default-class-0.1.2.0 (all, legacy fallback)
Building     th-abstraction-0.5.0.0 (lib)
Building     Boolean-0.2.4 (all, legacy fallback)
Haddock      old-locale-1.0.0.7 (lib)
Haddock      data-default-class-0.1.2.0 (all, legacy fallback)
Haddock      data-array-byte-0.1.0.1 (lib)
Installing   old-locale-1.0.0.7 (lib)
Haddock      Boolean-0.2.4 (all, legacy fallback)
Installing   data-default-class-0.1.2.0 (all, legacy fallback)
Completed    old-locale-1.0.0.7 (lib)
Starting     transformers-compat-0.7.2 (lib)
Completed    data-default-class-0.1.2.0 (all, legacy fallback)
Starting     wl-pprint-1.2.1 (all, legacy fallback)
Installing   data-array-byte-0.1.0.1 (lib)
Installing   Boolean-0.2.4 (all, legacy fallback)
Haddock      dlist-1.0 (lib)
Completed    data-array-byte-0.1.0.1 (lib)
Starting     data-default-instances-old-locale-0.0.1 (all, legacy fallback)
Completed    Boolean-0.2.4 (all, legacy fallback)
Starting     data-default-instances-containers-0.0.1 (all, legacy fallback)
Building     transformers-compat-0.7.2 (lib)
Building     wl-pprint-1.2.1 (all, legacy fallback)
Installing   dlist-1.0 (lib)
Building     data-default-instances-old-locale-0.0.1 (all, legacy fallback)
Building     data-default-instances-containers-0.0.1 (all, legacy fallback)
Completed    dlist-1.0 (lib)
Starting     hashable-1.4.2.0 (lib)
Haddock      data-default-instances-old-locale-0.0.1 (all, legacy fallback)
Haddock      NumInstances-1.4 (lib)
Building     hashable-1.4.2.0 (lib)
Haddock      data-default-instances-containers-0.0.1 (all, legacy fallback)
Installing   data-default-instances-old-locale-0.0.1 (all, legacy fallback)
Haddock      wl-pprint-1.2.1 (all, legacy fallback)
Completed    data-default-instances-old-locale-0.0.1 (all, legacy fallback)
Installing   NumInstances-1.4 (lib)
Starting     temporal-media-0.6.3 (all, legacy fallback)
Installing   data-default-instances-containers-0.0.1 (all, legacy fallback)
Completed    data-default-instances-containers-0.0.1 (all, legacy fallback)
Starting     data-default-instances-dlist-0.0.1 (all, legacy fallback)
Completed    NumInstances-1.4 (lib)
Installing   wl-pprint-1.2.1 (all, legacy fallback)
Completed    wl-pprint-1.2.1 (all, legacy fallback)
Building     temporal-media-0.6.3 (all, legacy fallback)
Building     data-default-instances-dlist-0.0.1 (all, legacy fallback)
Haddock      data-default-instances-dlist-0.0.1 (all, legacy fallback)
Haddock      th-abstraction-0.5.0.0 (lib)
Installing   data-default-instances-dlist-0.0.1 (all, legacy fallback)
Haddock      colour-2.3.6 (lib)
Completed    data-default-instances-dlist-0.0.1 (all, legacy fallback)
Starting     data-default-0.7.1.1 (all, legacy fallback)
Installing   th-abstraction-0.5.0.0 (lib)
Installing   colour-2.3.6 (lib)
Completed    th-abstraction-0.5.0.0 (lib)
Building     data-default-0.7.1.1 (all, legacy fallback)
Haddock      transformers-compat-0.7.2 (lib)
Completed    colour-2.3.6 (lib)
Haddock      temporal-media-0.6.3 (all, legacy fallback)
Haddock      data-default-0.7.1.1 (all, legacy fallback)
Installing   transformers-compat-0.7.2 (lib)
Installing   temporal-media-0.6.3 (all, legacy fallback)
Completed    transformers-compat-0.7.2 (lib)
Starting     deriving-compat-0.6.3 (lib)
Completed    temporal-media-0.6.3 (all, legacy fallback)
Installing   data-default-0.7.1.1 (all, legacy fallback)
Completed    data-default-0.7.1.1 (all, legacy fallback)
Building     deriving-compat-0.6.3 (lib)
Haddock      hashable-1.4.2.0 (lib)
Installing   hashable-1.4.2.0 (lib)
Completed    hashable-1.4.2.0 (lib)
Starting     data-fix-0.3.2 (lib)
Building     data-fix-0.3.2 (lib)
Haddock      data-fix-0.3.2 (lib)
Installing   data-fix-0.3.2 (lib)
Completed    data-fix-0.3.2 (lib)
Starting     data-fix-cse-0.0.3 (lib)
Building     data-fix-cse-0.0.3 (lib)
Haddock      data-fix-cse-0.0.3 (lib)
Installing   data-fix-cse-0.0.3 (lib)
Completed    data-fix-cse-0.0.3 (lib)
Haddock      deriving-compat-0.6.3 (lib)
Installing   deriving-compat-0.6.3 (lib)
Completed    deriving-compat-0.6.3 (lib)
Starting     csound-expression-dynamic-0.3.9 (lib)
Building     csound-expression-dynamic-0.3.9 (lib)

Failed to build csound-expression-dynamic-0.3.9.
Build log (
$HOME/.cabal/logs/ghc-9.2.8/csnd-xprssn-dynmc-0.3.9-7a997124.log ):
Warning: csound-expression-dynamic.cabal:4:23: Packages with 'cabal-version:
1.12' or later should specify a specific version of the Cabal spec of the form
'cabal-version: x.y'. Use 'cabal-version: 1.22'.
Configuring library for csound-expression-dynamic-0.3.9..
Preprocessing library for csound-expression-dynamic-0.3.9..
Building library for csound-expression-dynamic-0.3.9..
[ 1 of 15] Compiling Csound.Dynamic.Tfm.DeduceTypes ( src/Csound/Dynamic/Tfm/DeduceTypes.hs, dist/build/Csound/Dynamic/Tfm/DeduceTypes.o, dist/build/Csound/Dynamic/Tfm/DeduceTypes.dyn_o )
[ 2 of 15] Compiling Csound.Dynamic.Tfm.UnfoldMultiOuts ( src/Csound/Dynamic/Tfm/UnfoldMultiOuts.hs, dist/build/Csound/Dynamic/Tfm/UnfoldMultiOuts.o, dist/build/Csound/Dynamic/Tfm/UnfoldMultiOuts.dyn_o )
[ 3 of 15] Compiling Csound.Dynamic.Types.Exp ( src/Csound/Dynamic/Types/Exp.hs, dist/build/Csound/Dynamic/Types/Exp.o, dist/build/Csound/Dynamic/Types/Exp.dyn_o )

src/Csound/Dynamic/Types/Exp.hs:397:10: error:
    • Could not deduce (Data.Functor.Classes.Eq1 (PreInline a))
        arising from the superclasses of an instance declaration
      from the context: Hashable a
        bound by the instance declaration
        at src/Csound/Dynamic/Types/Exp.hs:397:10-46
    • In the instance declaration for ‘Hashable1 (PreInline a)’
    |
397 | instance Hashable a => Hashable1 (PreInline a)
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Csound/Dynamic/Types/Exp.hs:398:10: error:
    • Could not deduce (Data.Functor.Classes.Eq1 (Inline a))
        arising from the superclasses of an instance declaration
      from the context: Hashable a
        bound by the instance declaration
        at src/Csound/Dynamic/Types/Exp.hs:398:10-43
    • In the instance declaration for ‘Hashable1 (Inline a)’
    |
398 | instance Hashable a => Hashable1 (Inline a)
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Csound/Dynamic/Types/Exp.hs:399:10: error:
    • No instance for (Data.Functor.Classes.Eq1 RatedExp)
        arising from the superclasses of an instance declaration
    • In the instance declaration for ‘Hashable1 RatedExp’
    |
399 | instance Hashable1 RatedExp
    |          ^^^^^^^^^^^^^^^^^^

src/Csound/Dynamic/Types/Exp.hs:400:10: error:
    • No instance for (Data.Functor.Classes.Eq1 MainExp)
        arising from the superclasses of an instance declaration
    • In the instance declaration for ‘Hashable1 MainExp’
    |
400 | instance Hashable1 MainExp
    |          ^^^^^^^^^^^^^^^^^

src/Csound/Dynamic/Types/Exp.hs:401:10: error:
    • No instance for (Data.Functor.Classes.Eq1 PrimOr)
        arising from the superclasses of an instance declaration
    • In the instance declaration for ‘Hashable1 PrimOr’
    |
401 | instance Hashable1 PrimOr
    |          ^^^^^^^^^^^^^^^^
cabal: Failed to build csound-expression-dynamic-0.3.9 (which is required by
csound-expression-5.4.3). See the build log above for details.

% 
jwaldmann commented 1 year ago

worksforme when building from source (this repo, master). confirm that the error appears when building from hackage source. looks like the issue was fixed with 67d5d0e0a41a484bdb2a85adff1ab166e7c32fde (at least the commit log mentions Eq1)

shakfu commented 1 year ago

@jwaldmann Thanks for your response. I installed via cabal install csound-expression not from the repo, so it was from hackage. But in any case thanks for the fix, I'll try again and test it further.

colllin commented 11 months ago

For anyone else as brand-new to Haskell and cabal as I am, you can circumvent this issue by directing cabal to build the csound-expression-dynamic package from a recent commit on GitHub.

Add these lines to your cabal.project file:

source-repository-package
  type: git
  location: https://github.com/spell-music/csound-expression
  tag: 345df2c91c9831dd895f58951990165598504814
  subdir: csound-expression-dynamic

Then re-build using cabal. This appears to encourage cabal to build the csound-expression-dynamic package from the specified github commit, and appears to work even when your_project.cabal depends on it indirectly, e.g. build-depends: csound-expression, ...

Then, naturally, since I built a more-recent version of a sub-dependency, I also needed to build the matching versions for the other csound-* packages. Add to cabal.project:

source-repository-package
  type: git
  location: https://github.com/spell-music/csound-expression
  tag: 345df2c91c9831dd895f58951990165598504814
  subdir: csound-expression-typed

source-repository-package
  type: git
  location: https://github.com/spell-music/csound-expression
  tag: 345df2c91c9831dd895f58951990165598504814
  subdir: csound-expression-opcodes

source-repository-package
  type: git
  location: https://github.com/spell-music/csound-expression
  tag: 345df2c91c9831dd895f58951990165598504814
  subdir: csound-expression

source-repository-package
  type: git
  location: https://github.com/spell-music/csound-expression
  tag: 345df2c91c9831dd895f58951990165598504814
  subdir: csound-sampler
jwaldmann commented 11 months ago

yes that's possible. the easy way to build all the world at once is this:

$ git clone https://github.com/spell-music/csound-expression/
$ cd csound-expression
$ cabal install --lib all base --package-env=cse

then use with

$ ghci -package-env=cse
ghci> import Csound.Base

just tested with ghc-9.6.2, cabal-install-3.10.1.0.

Note: package environment files contain a collection of exposed libraries (exposed = you can import them in ghci), all denotes all packages mentioned in cabal.project, and base should also be exposed. It's good to have different env files for different projects, avoids per-user cabal hell.

references:

https://cabal.readthedocs.io/en/stable/cabal-commands.html#adding-libraries-to-ghc-package-environments

https://downloads.haskell.org/ghc/latest/docs/users_guide/packages.html#package-environments

long discussion about exposing base: https://github.com/haskell/cabal/issues/8894

shakfu commented 11 months ago

@jwaldmann / @colllin

Thanks for the additional guidance on this issue.

jabowery commented 11 months ago

I'm new to cabal/Haskell but the above advice doesn't get me past trying to build:

https://github.com/ariesoeteman/figurative_apperception_engine

which fails on the Compilation instructions step:

at which point the OP error occurs.

anton-k commented 11 months ago

I recommend to use stack, or install the package from hackage. I build it with stack from sources.

anton-k commented 11 months ago

With stack we can create custom environments where to load the lib. Here is the link on how I install the lib: https://github.com/spell-music/csound-expression/blob/master/tutorial/chapters/Intro.md#installing-with-stack-recommended

I create shortcat alias to the command which opens up ghci with all libraries loaded to the interpreter.

anton-k commented 11 months ago

I've tried out from scratch with this instruction for stack and it works. This workflow is geared toward using ghci. Usually I try small snippets and if I like it I copy them to file and reload it to interpreter.

But if you want to use it from haskell project in write-compile-listen loop. You can create new stack project with stack new my-project-name and in the stack.yaml write link to the library on your local drive or in the github repo. Make sure that your resolver in the stack.yaml matches the one from csound-expression's stack.yaml.

So the algorithm for project is:

extra-deps:
 - git: https://github.com/spell-music/csound-expression
   commit: <use-latest-commit-from-master-branch-here>

after that you can use libraries from the repo as deps.

anton-k commented 11 months ago

Ok, it's a bit more involved. Here is the complete stack.yaml for a new project that depends on CE:

resolver:
  lts-20.5

packages:
- .

extra-deps:
  - git: https://github.com/spell-music/csound-expression
    commit: 345df2c91c9831dd895f58951990165598504814
    subdirs:
       - csound-expression-dynamic
       - csound-expression-typed
       - csound-expression-opcodes
       - csound-expression

  - git: https://github.com/spell-music/temporal-media
     commit: b0508a6444714ac64d970d505e27f66daefc8ff1

  - git: https://github.com/spell-music/data-fix-cse
    commit: abff72605479401fc43fa62f053153a11d7a1c61
anton-k commented 11 months ago

example-for-ce.zip

zip archive with example project that works.

anton-k commented 6 months ago

Please use newer versions of ghc. It works with 9.6.4 and 9.8

shakfu commented 6 months ago

@anton-k Ok, thanks for update!