The easiest way to work outside of a package is https://cabal.readthedocs.io/en/latest/getting-started.html#running-a-single-file-haskell-script. Works pretty well, both in cabal run and cabal repl mode, and you can forget about any cabal *-install commands.

Best regards,
Andrew

On 30 Mar 2024, at 22:33, Henning Thielemann <lemming@henning-thielemann.de> wrote:


On Sat, 30 Mar 2024, Volker Wysk wrote:

Am Freitag, dem 29.03.2024 um 13:48 -0400 schrieb Brandon Allbery:
Cabal and stack are designed around the notion of projects, defined by a
cabal file (or `package.yaml` if you use Hpack), `stack.yaml` for stack,
optional `cabal.project` for cabal. Projects are sandboxed such that the
package(s) in the project use consistent versions of all dependencies.
Neither tool handles use outside of a project well, although stack has a
global configuration (whose use for this is deprecated iirc) and cabal
uses ghc's environment files when requested. So something that isn't
really intended for use as part of a project isn't well handled by either
one.

Sounds complicated. I guess the best way to avoid trouble, is to do
everything in projects and avoid code outside of projects.

You can easily turn code outside of a project into code inside a project, by adding something to the 'packages' field in cabal.project or add a separate 'source-repository-package' entry in the cabal.project.

Or you stick to 'cabal v1-install'.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.