You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Make case studies runnable on the website (#1009)
Currently, the case studies are not runnable on the website or resort to
the trick of having an empty REPL where you have to input `main()`. In
this PR, I try to properly handle `effekt:repl` in literate Effekt files
such that it has the same (observable) behaviour as on the website.
Since expressions can not be top-level, I wrap them in a function `def
replN() = <REPL-CONTENT>` and later append a main function where all
repl cells are called:
```
def repl1() = 1 + 2
def repl2() = println("hello")
def main() = {
inspect(repl1())
inspect(repl2())
()
}
```
If there's already a user-defined `main` function, then an error occurs.
Though, I argue that the user should not define a `main` function in a
literate Effekt file, as this kind of defeats its purpose.
Furthermore, I also tackle the issue of importing non-stdlib modules by
just merging all files in the dependency chain into the same file and
adding appropriate redirects for the old links.
Changes:
- You may now either have one or more `effekt:repl` code fences or one manually defined `main` function
- A repl cell is translated such that it is wrapped in a function:
```
def replN = {
stmt
}
```
corresponds to
````
```effekt:repl
stmt
```
````
where `def replN = {` is inserted for the opening fence and `}` for the closing fence to preserve positional information.
- You may now have other languages in a literate effekt file other than Effekt, e.g. ```` ```scala ```` gives you syntax highlighting but is ignored by the effekt compiler
- Similarly, `effekt:ignore` code fences are also ignored by the compiler
- Previously, `[[()]] = #f` in chez. Now, `[[()]] = #<void>`, reasone being that `inspect(inspect(())) = inspect(())` should hold but with `[[()]] = #f` it is not since `inspect` returns `#<void>`.
- `anf`, `lexer`, `pretty` and `parser` are concatenated into a single file to solve import issues.
---------
Co-authored-by: Jiří Beneš <[email protected]>
0 commit comments