Skip to content

Commit

Permalink
adding some docs on using scripts from ghci.
Browse files Browse the repository at this point in the history
  • Loading branch information
Montmorency committed Sep 19, 2022
1 parent a840e8d commit edab873
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Guide/scripts.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ This is made possible because of the [she-bang line](https://en.wikipedia.org/wi

In case you get a permission error, try to add the executable flag via `chmod +x Application/Script/HelloWorldToAllUsers.hs`.

## Running a script from ghci

You can also open a ghci prompt to test features in scripts interactively.

```bash
make ghci
```

Then you can load your script into the interpreter:
```
:l Application/Scripts/MyScript
```

and run the script from the IHP ghci command line:

```haskell
IHP> runScript ihpDefaultConfig runTestName
```

The `ihpDefaultConfig` is made available from the `Application.Script.Prelude` import but can be substituted
with your own `Config` data structure. This is particularly useful for adjusting logging levels or
testing new APIs that require certain configuration variables.

## Building a script

In production, you might want to build a script to a binary for performance reasons. Use make like this:
Expand Down

0 comments on commit edab873

Please sign in to comment.