Skip to content

Instantly share code, notes, and snippets.

View KeenS's full-sized avatar

κeen KeenS

View GitHub Profile
@leque
leque / freer-monad.scm
Last active May 11, 2016 01:35
Freer monad in Scheme
;;;; Freer monad in Scheme
;;;; See also
;;;; * "Freer monads, more extensible effects"
;;;; http://dl.acm.org/citation.cfm?doid=2804302.2804319
;;;; * Free monad in Scheme https://gist.github.com/wasabiz/951b2f0b22643a59aeb2
(use gauche.record)
(use util.match)
;;; data Freer f a where
;;; Pure :: a -> Freer f a
@leque
leque / ck-zundoko.scm
Last active January 20, 2017 00:57
syntax-rulesズンドコキヨシ、またはマクロ展開時ズンドコキヨシ
#!r6rs
(import (rnrs))
;; R7RS 処理系で実行する場合は、上の行をコメントアウトし、
;; 下の行のコメントを外す
;; (import (scheme base) (scheme write))
;; R5RS 処理系で実行する場合は、ここから上をすべてコメントアウトする
;; From "Applicative syntax-rules: macros that compose better",
@leque
leque / ckcc.scm
Last active January 20, 2017 00:57
CKスタイルマクロで途中脱出
#!r6rs
(import (rnrs))
;; From "Applicative syntax-rules: macros that compose better",
;; http://okmij.org/ftp/Scheme/macros.html#ck-macros
(define-syntax ck
(syntax-rules (quote)
;; yield the value on empty stack
((ck () 'v) v)
;; re-focus on the other argument, ea
@potix2
potix2 / gist:3339485
Created August 13, 2012 11:01
ApacheBenchでJSONをPOSTする
% ab -n 10 -c 10 -p json.file -T "application/json; charset=utf-8" http://localhost/
(use srfi-1)
(use gauche.partcont)
(define (main args)
(reset
(let* ((p1 (shift k (call-with-input-file (second args) k)))
(p2 (shift k (call-with-output-file (third args) k))))
(copy-port p1 p2))))
;; -> "./vminsn.scm", line 1375: Assertion failed: SCM_PAIRP((vm)->handlers)
@Jxck
Jxck / README.md
Created December 16, 2012 09:16
libuv TCP server/client sample

how to compile

$ gcc -g -Wall -I /path/to/libuv/include /path/to/libuv/uv.a -framework CoreServices server.c -o server
$ gcc -g -Wall -I /path/to/libuv/include /path/to/libuv/uv.a -framework CoreServices client.c -o client
@leque
leque / freer.ml
Last active September 30, 2021 07:44
Freer monad in OCaml
(*
Requirement: higher, ppx_deriving.show
*)
(*
Lightweight higher-kinded polymorphism
https://ocamllabs.github.io/higher/lightweight-higher-kinded-polymorphism.pdf
*)
open Higher
@aradarbel10
aradarbel10 / Main.hs
Created December 6, 2022 15:40
A minimalistic example of bidirectional type checking for system F
{-# LANGUAGE StrictData, DerivingVia, OverloadedRecordDot #-}
{-
(compiled with GHC 9.4.2)
-}
{-
HEADS UP
this is an example implementation of a non-trivial type system using bidirectional type checking.
it is...
@qnighy
qnighy / rust-patterns.md
Last active March 20, 2024 03:33
Rustのパターンっぽいやつメモ

パターンとはその言語が抽象化できなかった敗北の歴史である。 しかしどんなに優れた言語であってもあらゆる繰り返しに勝てるわけではない。 人は必ずメタ繰り返しを欲するからだ。 そしてそれはRustも例外ではない。

ここでは、OOPでも知られているパターンよりも、Rustに特有のパターンを思いつく限りまとめてみた。名前は適当。

  • crate splitting
    • でかいcrateを分割して、見通しを良くする・再コンパイルの分量を削減する・並列コンパイルを可能にする
  • 親玉crate(全てにdependする)と殿crate(全てにdependされる)があることが多いので、だいたい束みたいな形になる。