Skip to content
This repository was archived by the owner on Oct 1, 2026. It is now read-only.
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
43 changes: 43 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: check

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install ATS2
run: |
curl -sL "https://raw.githubusercontent.com/ats-lang/ats-lang.github.io/master/FROZEN000/ATS-Postiats/ATS2-Postiats-int-0.4.2.tgz" -o /tmp/ats2.tgz
mkdir -p ~/.ats2
tar -xzf /tmp/ats2.tgz -C ~/.ats2
cd ~/.ats2/ATS2-Postiats-int-0.4.2
make -j$(nproc) -C src/CBOOT patsopt
mkdir -p bin
cp src/CBOOT/patsopt bin/patsopt

- name: Cache bats toolchain
id: cache-bats
uses: actions/cache@v4
with:
path: ~/bats-toolchain
key: bats-${{ runner.os }}-${{ hashFiles('.github/workflows/check.yml') }}

- name: Build bats
if: steps.cache-bats.outputs.cache-hit != 'true'
run: |
git clone https://github.com/bats-lang/bats.git ~/bats-toolchain
cd ~/bats-toolchain
cargo build --release

- name: bats check
run: |
git clone https://github.com/bats-lang/repository-prototype.git ~/repository
~/bats-toolchain/target/release/bats lock --repository ~/repository
~/bats-toolchain/target/release/bats check --repository ~/repository
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
build/
dist/
*.sats
*.dats
*_dats.c
*.o
debug/
release/
_bats_*
bats_modules/
bats.lock
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ $T.exit() : void

`set` returns a promise that resolves when the host fires the timer.
The resolved value is an integer status (typically 0).

## Dependencies

- **promise**
25 changes: 23 additions & 2 deletions src/lib.bats
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
#pub fun hello(): void
(* timer -- promise-based timers and process control *)

implement hello () = println! ("hello from library")
#include "share/atspre_staload.hats"

#use promise as P
#use wasm.bats-packages.dev/bridge as B

#pub fun set
(delay_ms: int): $P.promise(int, $P.Pending)

#pub fun exit(): void

implement set(delay_ms) = let
val @(p, r) = $P.create<int>()
val id = $P.stash(r)
val () = $B.timer_set(delay_ms, id)
in p end

implement exit() = $B.exit()

fn _test_set(): void = let
val p = set(100)
val () = $P.discard<int>(p)
in () end
Loading