Programmatically cabal package example?

I’m looking for an example haskell package which defines (another) instance of a cabal package programmatically (i.e, in haskell), possibly using a temporary directory which would then be able to consume program text for Main.hs file and run it. The idea would be to use haskell for scripting, and have that package be the environment in which the script is run.

If this sounds like a stupid idea, or if there are better ways to go about it, then that would be great to know as well! :stuck_out_tongue:

2 Likes

cabal has some ability to run scripts already! https://github.com/vmchale/img-fut/blob/2377b78c0de7222c28e7528480f396dd6c034e37/Shakefile.hs#L1

I’m not sure if it still works though.

1 Like

It definitely still works. It is in the getting started part of the user guide:

https://cabal.readthedocs.io/en/stable/getting-started.html#run-a-single-file-haskell-script

2 Likes

Thanks! Had ran across this command but always thought it’s for using from within an existing package, but alas, it looks like the place to look at! :slight_smile: