Skip to content

Instantly share code, notes, and snippets.

trait Serializer {
serialize(Self) -> Bytes
}
impl Serializer for Int with serialize(self) {
Bytes::from_array([
self.land(0xFF),
self.lsr(8).land(0xFF),
self.lsr(16).land(0xFF),
self.lsr(24).land(0xFF)
// gc impl
import { flush, js_string, setMemory, spectest } from "./js_string.ts";
const { instance: { exports } } = await WebAssembly.instantiateStreaming(
fetch(new URL("../target/wasm-gc/release/build/main/main.wasm", import.meta.url)),
{
js_string,
spectest,
js: {
setTimeout, clearTimeout,

This is reply for moonbit author.

https://twitter.com/bobzhang1988/status/1784065637092089951


I have a slightly different opinion.

TypeScript was an ecosystem that combined a universal escape hatch called any with incremental typing. The community-based DefinitelyTyped provided an experience that, from a personal perspective, expanded the world of typing just by sleeping on it. This is an experience that Flow and ReScript did not provide. Unfortunately.

setTimeout binding

deno runner

import { flush, js_string, setMemory, spectest } from "../.mooncakes/mizchi/js_io/mod.ts";

type Instance = {
  fire: (fid: number) => void;
};
pub trait ToJson {
write_json_string(Self, Buffer) -> Unit
}
fn ToJson::write_json_string(self : Int, buf : Buffer) -> Unit {
buf.write_string(self.to_string())
}
fn ToJson::write_json_string(self : Bool, buf : Buffer) -> Unit {
buf.write_string(self.to_string())

String JS <=> Moonbit

struct MyCtx {
  result: String
  mut cur: Int
  input: @vec.Vec[Int]
}

pub fn app() -> MyCtx {
@mizchi
mizchi / one-button-playing.md
Last active March 20, 2024 11:37
ヴァンサバに至るローグライクとハクスラの歴史

これはポ鯖アドベントカレンダーの1日目の記事。

ヴァンサバはいとこ同士の子だという話をするために、ハクスラとローグライトの話をしたい。

本記事は身内の友人向けの記事なので、主観が強く、記事の正確性は重要視していない。それについてはご勘弁願いたい。


では、話をしよう。

@mizchi
mizchi / agent.test.ts
Created March 19, 2024 07:57
軽量 Langchain 的な何か
import { defineAgent, ok, err, runAgent, stepAgent, chain, initAgent } from "./agent.ts";
import { Agent, AgentError, AgentErrorCode } from "./types.ts";
import { expect } from "https://deno.land/std@0.214.0/expect/mod.ts";
Deno.test("stepAgent: simple", async () => {
const simple = defineAgent((_init) => {
return {
async invoke(input, _options) {
return `Hello, ${input}`;
},