This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(provide (except-out (all-defined-out) with-free Pure Free)) | |
(require racket/control) | |
(struct Pure (r) #:transparent) | |
(struct Free (a k) #:transparent) | |
; (: compose [All (a b c) (-> (-> a b) (-> b c) (-> c d))]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
from_date=${1:-"2024-10-01"} | |
to_date=${2:-"2025-03-31"} | |
total=0 | |
f() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local eff = require('eff') | |
local inst, perform, handler = eff.inst, eff.perform, eff.handler | |
local Twice = inst() | |
local Exit = inst() | |
--[[ | |
co = { | |
print(1) | |
coroutine.yield() -- *1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[@@@alert "-unstable"] | |
[@@@warning "-32"] | |
(* Reimplementation of Go's worker pools using Eio and Domainslib.Chan | |
https://gobyexample.com/worker-pools | |
*) | |
module Stdenv = struct | |
type _ Effect.t += Get : (Eio.Stdenv.t * Eio.Switch.t) Effect.t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type (_, _) operation = .. | |
type 'a computation = | |
| Return : 'a -> 'a computation | |
| Call : ('arg, 'res) operation * 'arg * ('res -> 'a computation) -> 'a computation | |
type ('a, 'b) handler = { | |
return : 'a -> 'b computation; | |
operations : 'arg 'res. ('arg, 'res) operation -> | |
'arg -> ('res -> 'b computation) -> 'b computation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Get { | |
readonly _tag: 'Get'; | |
readonly _ans: number; | |
} | |
interface Put { | |
readonly _tag: 'Put'; | |
readonly _ans: void; | |
value: number; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type (_, _) cont = | |
Cont : (('a -> 'r) -> 'r) -> ('r, 'a) cont | |
let runCont : ('r, 'a) cont -> ('a -> 'r) -> 'r | |
= fun (Cont f) k -> f k | |
let runCont' k cf = runCont cf k | |
let return x = Cont((|>) x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Read = (key) => ({type : 'Read', arguments : [ key ]}); | |
const Write = (key, value) => ({type : 'Write', arguments : [ key, value ]}); | |
const performWith = (handler, eff) => | |
new Promise(() => { throw eff; }).catch(handler); | |
async function go(handler) { | |
const x = await performWith(handler, Read("x")); | |
await performWith(handler, Write("z", x + 4)); | |
const z = await performWith(handler, Read("z")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module typed-delimcc | |
public effect subcont0<a> { | |
fun shift0(f : (b -> a) -> a) : b | |
} | |
public fun reset0(th : () -> subcont0<a> a) : a { | |
handle(th) { | |
shift0(f) -> f(resume) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type NATURAL = sig | |
type t | |
val build : ((t -> t) -> t -> t) -> t | |
end | |
module type BUILD_NATURAL = functor | |
(M : sig | |
type t |
NewerOlder