https://github.com/danielxmoore/kusanagi
CoffeeScript style syntax for Motoko language
https://github.com/danielxmoore/kusanagi
Last synced: over 1 year ago
JSON representation
CoffeeScript style syntax for Motoko language
- Host: GitHub
- URL: https://github.com/danielxmoore/kusanagi
- Owner: DanielXMoore
- Created: 2022-06-12T16:07:18.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-13T17:02:23.000Z (over 3 years ago)
- Last Synced: 2025-03-27T21:52:13.936Z (over 1 year ago)
- Language: CoffeeScript
- Size: 230 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Kusanagi
========
[](https://github.com/DanielXMoore/kusanagi/actions/workflows/build.yml)
The initial work on this project was funded by the [Origyn Foundation](https://origyn.ch).
CoffeeScript style syntax for the Motoko language. [Try Kusanagi](https://danielx.net/kusanagi/)
```motoko
import State "State"
module
public class Grid(state : State.State)
let grid = state
let n = grid.size()
public func size() : Nat
n
func nextCell(i : Nat, j : Nat) : State.Cell
let l : Nat = living i, j
if get i, j
l == 2 or l == 3
else
l == 3
func next(dst : Grid)
for i in grid.keys()
let cool = true
for j in grid[i].keys()
let yo = "wat"
dst.set i, j, nextCell i, j
```
Get Started
---
```bash
npm install -g kusanagi
kusanagi < src.ku > out.mo
```
Features
---
- Indentation based blocks
- Let shorthand `x = 5` -> `let x = 5`
- Alternative with syntax
```
let x = {
...a
...b
}
```
becomes
```
let x = {
a and
b
}
```
- Chained comparisons
```motoke
x < y <= z
```
Becomes
```motoko
x < y and y <= z
```
- `match`
```
match x, #nat(val), 0
---
switch(x) {
case(#nat(val)) { val };
case(_){ 0 }
};
```
- `take`
```
take x, 0
---
switch(x) {
case(null) { 0 };
case(?val) { val }
};
```
- Null soaks
```
student.classes?.get(classID)
---
do?{student.classes!.get(classID)};
```