Skip to content

Instantly share code, notes, and snippets.

View leque's full-sized avatar

OOHASHI Daichi leque

View GitHub Profile
@leque
leque / tg.ml
Last active April 3, 2023 09:18
Flexiblly Extend Nested Structures with OCaml
(*
inspired by
- Flexiblly Extend Nested Structures - "Trees that Grow" in TypeScript
https://dev.to/igrep/flexiblly-extend-nested-structures-trees-that-grow-in-typescript-4347
- 入れ子構造を自由に拡張する – TypeScript版「Trees that Grow」 (Japanese translation of above article)
https://eng-blog.iij.ad.jp/archives/18900
*)
type 'a literal = [`Literal of int * 'lit]
constraint 'a = <literal: 'lit; ..>
@leque
leque / .md
Last active February 1, 2023 15:30
flowchart TB;

saty[.saty file]
md[.md file]

saty == parse ==> utast[untyped AST]
md == decode markdown ==> utast

subgraph frontend
@leque
leque / r.ml
Last active January 18, 2023 14:55
string -> Uchar.t Seq.t
module type Reader = sig
type t
type stream
type elem
val make : stream -> t
val read : t -> (elem * t) option
end
module Option_syntax = struct
let (let*) = Option.bind
@leque
leque / .md
Last active December 29, 2022 00:36
SATySFiの文字列構文まわり試案

SATySFiの文字列構文まわり試案

概要

SATySFiの文字列構文を整理し、拡張性が高く理解しやすい構文にする。文字列先頭/末尾の空白を自動で除去しないように変更する。現状の #`〜` 文字列や `〜`# 文字列を廃止する。 新たにタグ付き文字列(tagged-string)の構文を導入する。

動機

  • 現状の課題
    • 特殊文字を書くための構文が不十分(改行文字、Unicodeエスケープ、……)
@leque
leque / satysfi-clustered.pdf
Last active October 5, 2022 10:45
SATySFi module dependencies
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
(**
An OCaml implementation of a call-by-value abstract machine for lambda-calculus +
control, shift, control0, shift0, and prompt.
based on "A dynamic continuation-passing style for dynamic delimited continuations"
https://dl.acm.org/doi/10.1145/2794078
*)
type variable = string
type term =
| Var of variable
@leque
leque / ssort.rb
Last active October 8, 2021 14:15
# visualize "Is this the simplest (and most surprising) sorting algorithm ever?" https://arxiv.org/abs/2110.01111
require 'curses'
def show_array(i, j, arr)
Curses.clear
Curses.setpos(i, 0)
Curses.addstr('i')
Curses.setpos(j, 1)
Curses.addstr('j')
arr.each_with_index do |x, idx|
@leque
leque / vis.scm
Last active September 15, 2021 15:39
;;; AST
(define-class <expr> ()
())
(define-class <int-expr> (<expr>)
((value :init-keyword :value)))
(define-class <binop-expr> (<expr>)
())
@leque
leque / list.json
Created May 3, 2021 01:37
smlsharp: read a json-represented list
{
"type": "cons",
"head": 1,
"tail": {
"type": "cons",
"head": 42,
"tail": {
"type": "nil"
}
}
@leque
leque / memo.adoc
Last active August 13, 2022 23:54
vi(m)クローンの正規表現比較

vi(m)クローンの正規表現(雑)比較