Skip to content

Instantly share code, notes, and snippets.

@LCamel
LCamel / a.txt
Created June 4, 2026 07:39
abstract / elaborate
不改的壞處(全是工程債,無 soundness)
1. 渲染邏輯被迫雙份維護(最實際的成本)
Abstract 和 Typed 各有一份幾乎平行的 handleExpr(Render Expr),Pretty 也各一套。任何「表達式怎麼顯示」的調整要改兩處,且容易
drift——現在兩份已有細微差異。
2. 拔不掉 Abstract render/pretty cluster(你的原始目標被擋住)
Render Expr/Chain/CaseClause/Interval/... 一整包得留著,純粹因為 array bound 還是 Abstract.Expr。死重量。
3. 心智模型是假的,會誤導人
@LCamel
LCamel / a.hs
Last active June 3, 2026 10:22
array bound 是 abstract 的 Expr
{-# LANGUAGE OverloadedStrings #-}
-- 這幾個 OPTIONS 是為了讓 refutable 的 let/where pattern binding 不被
-- 專案的 -Werror=incomplete-patterns 擋下(純 demo,無所謂 totality)。
{-# OPTIONS_GHC -Wno-incomplete-patterns -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-error=incomplete-patterns -Wno-error=incomplete-uni-patterns #-}
-- 用法:
-- cd gcl
-- stack ghci gcl:lib
-- :load a.hs
@LCamel
LCamel / Fib.js
Last active May 15, 2026 16:04
Stream
genFib = function* () {
let [curr, next] = [0, 1];
while (true) {
yield curr;
[curr, next] = [next, curr + next];
}
};
fib = genFib();
while (true) {
@LCamel
LCamel / agda.dot
Last active April 3, 2026 15:21
The Hierarchy of Core Terms in Agda
digraph AgdaCoreTermHierarchy {
rankdir=BT;
fontname="Helvetica,Arial,sans-serif";
nodesep=0.7;
ranksep=0.9;
node [shape=box, style="rounded,filled", fillcolor="#f0f8ff", fontname="Helvetica,Arial,sans-serif", penwidth=1.5, color="#4682b4"];
edge [color="#d35400", fontname="Helvetica,Arial,sans-serif", fontsize=11, fontcolor="#d35400"];
@LCamel
LCamel / orphan.txt
Created March 20, 2026 02:01
orphan
● 分析完成。252 個 orphan instances 分佈在 28 個檔案,可以分成三大類:
---
結論:大部分 orphan 是架構上難以避免的
1. 結構上必要的 orphan(~100+ 個)— 不建議動
Pretty / Render instances 是最大宗。原因是經典的循環依賴問題:
Syntax/Abstract/Types.hs 定義 Expr, Stmt, Type ...
-- NextDidChange.csp
-- FDR4 model to verify the NextDidChange property of the GCL Server-Edit protocol.
--
-- Reference: https://github.com/scmlab/gcl-all/wiki/Server-Edit
--
-- Property (NextDidChange):
-- If workspace/applyEdit succeeds (client applied the edit),
-- then the next textDocument/didChange the server receives
-- belongs to that edit.
--
@LCamel
LCamel / Load2.hs
Created February 26, 2026 06:59
Load2.hs
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
module Server.Load2 where
import Data.IntMap (IntMap)
import Data.Text (Text)
import Error (Error (..))
import GCL.Predicate (Hole, PO, Spec)
import GCL.Range (Range)
@LCamel
LCamel / a.sh
Last active February 9, 2026 16:32
xpra
cp -rL /usr/share/xpra $HOME/xpra_copy
sed -i 's/getboolparam("swap_keys", Utilities\.isMacOS())/getboolparam("swap_keys", false)/' \
"$HOME/xpra_copy/www/index.html"
xpra start --bind-tcp=0.0.0.0:8080 --html=$HOME/xpra_copy/www --start=emacs-lucid
@LCamel
LCamel / 0.txt
Last active January 30, 2026 02:59
GCL early load
% grep Trace /tmp/a.txt
[Trace - 2:45:29 AM] Sending request 'initialize - (0)'.
[Trace - 2:45:29 AM] Received response 'initialize - (0)' in 7ms.
[Trace - 2:45:29 AM] Sending notification 'initialized'.
[Trace - 2:45:29 AM] Sending notification 'textDocument/didOpen'.
[Trace - 2:45:29 AM] Sending request 'gcl/reload - (1)'.
[Trace - 2:45:29 AM] Received request 'client/registerCapability - (1)'.
[Trace - 2:45:29 AM] Sending response 'client/registerCapability - (1)'. Processing request took 0ms
[Trace - 2:45:29 AM] Sending notification 'workspace/didChangeConfiguration'.
[Debug] VFS: opening file:///workspaces/gcl[Trace - 2:45:29 AM] Received request 'workspace/configuration - (2)'.
@LCamel
LCamel / keybindings.json
Created January 15, 2026 13:43
VS Code terminal key mapping: user_data_dir/User/keybindings.json
[
{
"key": "shift+enter",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001b\r"
},
"when": "terminalFocus"
}
]