Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/default-handlers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ providing a handler in a `run-with` block.
For example, we can write:

```flix
use Sys.Env
use Time.Clock

def main(): Unit \ {Clock, Env, Logger} =
Expand All @@ -21,6 +22,7 @@ def main(): Unit \ {Clock, Env, Logger} =
which the Flix compiler translates to:

```flix
use Sys.Env
use Time.Clock

def main(): Unit \ IO =
Expand All @@ -41,6 +43,8 @@ respective effects.
For example, `Clock.runWithIO` is declared as:

```flix
use Time.Clock

@DefaultHandler
pub def runWithIO(f: Unit -> a \ ef): a \ (ef - Clock) + IO = ...
```
Expand Down
7 changes: 7 additions & 0 deletions src/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ compiler. See [Default Handlers](./default-handlers.md) for details.
For example, main can use the `Env` and `Exit` effects:

```flix
use Sys.Env
use Sys.Exit

def main(): Unit \ {Env, Exit} =
let args = Env.getArgs();
match List.head(args) {
Expand All @@ -39,6 +42,8 @@ The command line arguments passed to the program can be accessed by calling
`Env.getArgs()` through the `Env` effect:

```flix
use Sys.Env

def main(): Unit \ {Env, IO} =
let args = Env.getArgs();
println("Arguments: ${args}")
Expand All @@ -49,6 +54,8 @@ def main(): Unit \ {Env, IO} =
The program can be terminated with a specific exit code using `Exit.exit`:

```flix
use Sys.Exit

def main(): Unit \ Exit =
Exit.exit(0)
```
Expand Down