Skip to content
Open
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Widip
Mytilus
-----

> _Types? Where we're going, we don't need types!_

Widip is an [interactive environment] for computing in modern systems. Many long-standing systems have thrived thanks to a uniform metaphor, which in our case is wiring diagrams.
Mytilus is an [interactive environment] for computing in modern systems. Many long-standing systems have thrived thanks to a uniform metaphor, which in our case is wiring diagrams.

System |Metaphor
---------|--------------
Widip |Wiring Diagram
Mytilus |Wiring Diagram
UNIX |File
Lisp |List
Smalltalk|Object
Expand All @@ -17,11 +17,11 @@ Smalltalk|Object

# Installation

`widip` can be installed via [pip](https://pypi.org/project/widip/) and run from the command line as follows:
`mytilus` can be installed via [pip](https://pypi.org/project/mytilus/) and run from the command line as follows:

```bash
pip install widip
python -m widip
pip install mytilus
python -m mytilus
```

This will automatically install dependencies: [discopy](https://pypi.org/project/discopy/) (computing, drawing), [pyyaml](https://pypi.org/project/pyyaml/) (parser library), and [watchdog](https://pypi.org/project/watchdog/) (filesystem watcher).
Expand All @@ -30,16 +30,16 @@ This will automatically install dependencies: [discopy](https://pypi.org/project

If you're working with a local copy of this repository, run `pip install -e .`.

# Using `widip`
The `widip` program starts a [chatbot] or [command-line interface]. It integrates with the [filesystem] for rendering diagram files. We give more information for a few use cases below.
# Using `mytilus`
The `mytilus` program starts a [chatbot] or [command-line interface]. It integrates with the [filesystem] for rendering diagram files. We give more information for a few use cases below.

## For documentation
Widis are meant for humans before computers and we find it valuable to give immediate visual feedback. Changes in a `.yaml` file trigger rendering a `.jpg` file next to it. This guides the user exploration while they can bring their own tools. As an example, VS Code will automatically reload markdown previews when `.jpg` files change.

Widis are great for communication and this is a very convenient workflow for git- and text-based documentation.

## For UNIX programming
The lightweight `widish` [UNIX shell] works everywhere from developer workstations to cloud environments to production servers. Processes that read and write YAML document streams are first-class citizens. With this practical approach users can write programs in the same language of widis.
The lightweight `mytilus` [UNIX shell] works everywhere from developer workstations to cloud environments to production servers. Processes that read and write YAML document streams are first-class citizens. With this practical approach users can write programs in the same language of widis.

## For graphical programming
Programming is hard, but it shouldn't be _that_ hard.
Expand Down
17 changes: 17 additions & 0 deletions bin/mytilus
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
set -eu

SELF_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
ROOT_DIR=$(CDPATH= cd -- "$SELF_DIR/.." && pwd)

if [ -x "$ROOT_DIR/.venv/bin/python" ]; then
PYTHON_BIN="$ROOT_DIR/.venv/bin/python"
elif command -v python3 >/dev/null 2>&1; then
PYTHON_BIN=$(command -v python3)
else
PYTHON_BIN=$(command -v python)
fi

export PYTHONPATH="$ROOT_DIR${PYTHONPATH:+:$PYTHONPATH}"

exec "$PYTHON_BIN" -m mytilus "$@"
2 changes: 0 additions & 2 deletions bin/widish

This file was deleted.

2 changes: 1 addition & 1 deletion bin/yaml/python.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!bin/widish
#!bin/mytilus
!python
Binary file added bin/yaml/shell.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from pathlib import Path

from discorun.comput.computer import Box, ComputableFunction, ProgramTy, Ty
from discorun.metaprog.core import (
MetaprogramComputation,
MetaprogramFunctor,
ProgramComputation,
ProgramFunctor,
)
from discorun.pcc.core import ProgramClosedCategory
from discorun.state.core import Process, fixed_state, simulate


def large_diagram():
X, A, B, C, D = Ty("X"), Ty("A"), Ty("B"), Ty("C"), Ty("D")
H_ty, L_ty = ProgramTy("H"), ProgramTy("L")

high_level = ProgramClosedCategory(H_ty)
low_level = ProgramClosedCategory(L_ty)

# Stateful execution in the same language composed for several rounds.
stateful_chain = (
high_level.execution(A, B)
>> high_level.execution(B, C)
>> high_level.execution(C, D)
)

# One execution step followed by an interpreted high-level computation.
interpreter_chain = (
high_level.execution(A, B)
>> ProgramFunctor()(ProgramComputation("H", L_ty, H_ty, B, C))
)

# One execution step followed by a metaprogram rewrite / partial evaluation.
compiler_chain = (
high_level.execution(A, B)
>> MetaprogramFunctor()(MetaprogramComputation("H", L_ty, L_ty, H_ty, B, C))
)

# A plain computation lifted to a process, then simulated in the high-level
# program state space, and executed once more.
process_chain = (
fixed_state(ComputableFunction("worker", X, A, B))
>> simulate(Process("machine", X, B, C), Box("embed", X, H_ty))
>> high_level.execution(C, D)
)

# A separate low-level execution pipeline for contrast with the H-language.
low_level_chain = low_level.execution(A, B) >> low_level.execution(B, C)

# Tensor the pipelines together so the rendered figure shows several linked
# Chapter 6/7 stories in one large diagram.
return (
stateful_chain
@ interpreter_chain
@ compiler_chain
@ process_chain
@ low_level_chain
)


if __name__ == "__main__":
output_path = Path("debug.svg")
large_diagram().draw(path=str(output_path))
print(output_path)
Loading