haskell / haskell/cabal

Run a statement directly with `cabal v2-repl --run "func"`

Open
#9,183 3 comments 0 reactions 0 assignees View on GitHub
type: enhancement
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

## Problem

Currently it's possible to run a statement with shell piping but this gives a noisy output:

```bash
$ cabal v2-repl <<< ':type zip'
[ 1 of 40] Compiling..
..
Ok, 40 modules loaded.
ghci> zip :: [a] -> [b] -> [(a, b)]
ghci> Leaving GHCi.

$ cabal v2-repl <<< ':type zip' | wc -l
48
```

(From https://stackoverflow.com/questions/58600068/how-can-i-run-a-ghci-statement-in-cabal-v2-repl-directly-from-command-line)

## Proposal

It would be great to have a `--run ` that produces a one line output.

This would be useful to test IO in certain cases. For example, to produce a SQL query and then run it:

```bash
$ cabal v2-repl --run "Module.produceQuery" | psql
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.