Skip to content

development tutorial transcript mode #5792

@aryairani

Description

@aryairani

Walkthroughs of Unison app development are super valuable for teaching and promotion.

Unfortunately, for writing up such a walkthrough, it turns out that neither the scratch file nor the transcript is very convenient.

The scratch file is too mutable: If you want to show multiple iterations of development, you must throw away (or manually archive) early versions of the application as you work, or keep them in separate sub-namespaces and never use the update command. Neither option is very good.

The transcript isn't nice for this purpose either. Your code isn't syntax-highlighted either in the editor or in the output (I assume this could be improved, through the Unison vscode plugin). You have to manually add after each unison buffer, which creates unnecessary clutter for the author and for the reader. Unless you're trying to demonstrate details of the type checker, you always want to add/update every code stanza. On the plus side, you can run them and verify the result before publishing the tutorial, but each run is manual instead of interactive like the scratch file.

Unison Docs are almost a good option here — it's great that they can hyperlink to Unison code easily—but again, they are a clumsy tool for illustrating multiple iterations of an application, and there's no way to test them for correctness.

Describe the solution you'd like

Option 1: interactive extended transcript mode + syntax highlighting

(Syntax highlighting is already released now via unisonweb/vscode-unison#21 thanks to @dfreeman.)

Syntax:

Hi I'm writing a new application!

```ucm :hide branch=project/main autoupdate=true
> lib.install @unison/base
> lib.install @unison/http
> lib.install @unison/cloud
```

Each command is assumed to be in a branch specified by the most recent `branch` attribute. 
The default is `scratch/main`.  The output transcript can include the active branch in the prompt.

Here we've skipped `project.create` and just manually `> lib.install @unison/base`. 
This seems okay for the moment.

```unison
foo = "new code" 
```

Because of the active `autoupdate=true`, code blocks are automatically added/updated into the branch.
`:hide` is implied when `autoupdate=true`; we're not trying to teach how to use `ucm` here.

```unison
foo = "newer code" 
```

Blah blah blah, now `foo` is much better.

Behavior:

The file watcher watches this file (possibly activated with some kind of load or watch command. The file parsed and executed stanza by stanza in a temporary branch until the end is reached or until an error is encountered. Errors are reported with the corresponding line number in the markdown file in the output and in LSP. (Not the line number relative to the start of the stanza.)

The syntax highlighter highlights the markdown and the Unison.

Note: because we don't have a syntax for Shown :: Hidden, there's no conflict currently between that and autoupdate=true implying HideOutput.

Option 2: An extended scratch file mode + syntax highlighting

It's a mode where if there are duplicate-named definitions in the file, they're all type checked, but later ones replace earlier ones. This lets you draft multiple versions of the application in the scratch file, utilizing the file watcher, interactive type checker, language server.

Maybe easier to implement (could it be something with just incrementing the symbol numbers?); but to splice the results together into a blog post once finished is extra manual work.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions