Skip to content

Instantly share code, notes, and snippets.

View vain0x's full-sized avatar
🐧
safe and sound, well-typed

vain0x vain0x

🐧
safe and sound, well-typed
View GitHub Profile
@gintenlabo
gintenlabo / optional_ref.hpp
Created October 19, 2010 14:29
boost::optional<T&> の省メモリな代替
//
// etude::optional_ref<T>
// ポインタの安全で軽快な代替として使えるクラス
// 一部を除き boost::optional<T&> と同じように使えます。
// 詳しくは http://d.hatena.ne.jp/gintenlabo/20101019/1287500776 を参照。
//
// Copyright (C) 2010 Takaya Saito (SubaruG).
// このコードは NYSL (http://www.kmonos.net/nysl/) の下で公開されています。
// 自分で書いたコードと同じように、自由に利用、改変、再配布を行って構いません。
// 何かあったら: gintensubaru あっと gmail.com まで。
@theburningmonk
theburningmonk / FSharpSerialization.fsx
Created March 18, 2012 12:54
Serializing/Deserializing F# Record and DU types
#r "System.Xml.dll"
#r "System.Runtime.Serialization.dll"
open Microsoft.FSharp.Reflection
open System.IO
open System.Reflection
open System.Runtime.Serialization
open System.Runtime.Serialization.Formatters.Binary
open System.Runtime.Serialization.Json
open System.Text
@pocketberserker
pocketberserker / AsyncInCSharpAndFSharp.ja.rst
Last active October 6, 2022 02:53
Async in C# and F#: Asynchronous gotchas in C# (Japanese translation)

C# と F# の Async: C# の非同期の落とし穴

原文:Async in C# and F#: Asynchronous gotchas in C#
原文著者:Tomas Petricek (@tomaspetricek)
翻訳者:@pocketberserker

2月に、私は毎年恒例のMVPサミット ── Microsoft が MVP のために主催するイベント ── に出席しました。私はボストンとニューヨークを訪問する機会を利用して、二つの F# に関する講演と Channel9 lecture about type providers の収録を行いました。他のすべての活動(しばしばパブで他の F#er を議論に巻き込んだり、朝まで長い睡眠)にもかかわらず、私はいくつかの講演に参加し果せました。

@pchiusano
pchiusano / Layout.elm
Created December 10, 2014 20:56
Annotated layout trees
module Elmz.Layout where
import List
import Array (Array)
import Either(..)
import Graphics.Element as E
import Graphics.Element (Direction, Element, Position)
type Pt = { x : Int, y: Int }
@vain0x
vain0x / dict_math_signs.txt
Last active July 7, 2024 01:01
数学記号辞書
|| ∨ 記号 (代替表記)
&& ∧ 記号 (代替表記)
! ¬ 記号 (代替表記)
|ー ├ 記号 (略記)
|= ⊨ 記号 (略記)
<: ⊂ 記号 (一般的でない代替表記)
<:= ⊆ 記号 (一般的でない代替表記)
:> ⊃ 記号 (一般的でない代替表記)
:>= ⊇ 記号 (一般的でない代替表記)
:: ∈ 記号 (一般的でない代替表記)
@barneycarroll
barneycarroll / patdj.js
Last active November 8, 2019 06:28
DOM patching without: provide two DOM elements, the second (and contents) will be modified such that it resembles the first
function patdj(target, update, preserve = true) {
if (update.nodeType != 1 && update.nodeType == target.nodeType)
target.nodeValue = update.nodeValue
else if (update.nodeType != target.nodeType || update.tagName !== target.tagName || update.type !== target.type){
const { nextSibling, parentNode } = target;
const replacement = preserve ? update.cloneNode(true) : update;
parentNode.removeChild(target);
@mrange
mrange / README.md
Last active April 16, 2024 14:09
[F#] Implementing Coroutines (async/await) using continuations

[F#] Implementing Coroutines (async/await) using continuations

Coroutines or async/await is not a new concept as it was named in 1958 by Melvin Conway. Coroutines had support in languages such as Simula(1962), Smalltalk(1972) and Modula-2(1978) but I think one can argue that coroutines came into mainstream with C# 5(2012) when Microsoft added async/await to C#.

The problem with subroutines

A thread can only execute a single subroutine at a time as a subroutine starts and then runs to completion. In a server environment subroutines can be problematic as in order to service connections concurrently we would usually would start a thread per connection, this was the idiom a few years ago. A thread depending on the operating system and settings needs about 1 MiB of user stack space meaning 1,024 threads needs 1 GiB of for just user stack space. In addition there's the cost of kernel stack space, book-keeping and scheduling of threads. This drives cost of VM/hardwa

@kt3k
kt3k / why-i-contribute-to-deno.md
Last active January 4, 2023 10:28
私が Deno にコントリビュートする理由

私が Deno にコントリビュートする理由

2018 年 6 月の JSConf EU で Deno が初めて発表されてから 1 年が経ちました.

日本では 2018 年 12 月ごろから Deno の周辺で作業をする人が増え, 2019 年 1 月頃から定期的に Deno もくもく会 #deno_ja が開催されるようになりました.

#deno_ja では毎回, 冒頭で簡単な自己紹介をするのですが, よくよく聞いていると早く Deno を始めた人でも 12 月ぐらいの人が多いことに気づきました. 自分だけが Deno 公開直後の 5 月からコントリビュートしています. そして, なぜその時期から Deno にコントリビュートしているのか, #deno_ja の中でも自分からあまり説明できていないことに気がつきました.

この記事は, なぜ自分がそこまで Deno にコントリビュートするのかの理由を出来る限り言語化してみる試みです.

@qnighy
qnighy / juxtaposition-application.md
Created February 22, 2022 13:18
並置による関数適用に関する所感

並置による関数適用

並置による関数適用の善し悪しについて盛り上っているので、自分の意見を表明しておく。以下の2本立て。

  • 純粋に構文論的な議論 (構文拡張の余地を残す)
  • 意味論との関係での議論 (副作用の表示)

先に結論だけ書くと、私はどちらかといえば括弧による関数適用のほうが好みです。

そもそも並置による関数適用とは

@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...