Koriel.Monadic
from Koriel
Koriel.Monadic
新規に設計中の中間表現
コンセプト
Koriel.Coreの反省点のフィードバック
複数の言語へのコンパイルを容易に
中間表現のシリアライゼーション
MoggiのNotions of computation and monadsっぽい
GRINの影響
メモリ操作と例外をいい感じに表現
Koriel.Monadicの型システム
castの役割
polymorphic types
型変数aをTPtr TAnyに置き換える
recursive types
fold, unfold
castの置き換え
Λ, fold, unfoldに分けるべき?
ΛはExp?Value?
Λ a. eなのでExp
最終的に型消去する?
Λ, fold, unfoldなどをcast系演算子として捉える
それぞれをcastで置き換えるパス(=型消去)
再帰型の扱い(ここでの「再帰型」は、例えば type Tree = Leaf | Node Int Tree Tree のように、型名の再帰的な束縛を指す。μによる表現は「μ型」と呼ぶことにする)
多くの言語(LLVM IRを含む)に再帰型がある
ここでの「再帰型」は、例えば type Tree = Leaf | Node Int Tree Tree のように、型名の再帰的な束縛を指す
再帰型を持つ言語を、別の再帰型を持つ言語へコンパイルする際に、再帰型を除去する必要はない
再帰型を持たない言語も存在する
確かCranelift IRにはない
再帰型を持つ言語から、再帰型を持たない言語へコンパイルする際に、再帰型を除去する必要はある
以上のことから、LLVM IRをメインターゲットとするKoriel.Monadicでは、μ型を導入する必要はない。
Overview | GRIN Compiler https://grin-compiler.github.io/
Unraveling Recursion: Compiling an IR with Recursion to System F https://homepages.inf.ed.ac.uk/wadler/papers/mpc-2019/unraveling.pdf
On the Semantic Expressiveness of Recursive Types https://dl.acm.org/doi/pdf/10.1145/3434302
tr.pdf https://www.cs.cmu.edu/~rwh/papers/datatypes/tr.pdf
Moggi91.pdf http://www.cs.cmu.edu/~crary/819-f09/Moggi91.pdf