Skip to content

Instantly share code, notes, and snippets.

View lagenorhynque's full-sized avatar
🐬
architecting & managing

Kent OHASHI lagenorhynque

🐬
architecting & managing
View GitHub Profile
@lagenorhynque
lagenorhynque / repl_session.flix
Last active June 10, 2026 02:16
Higher-rank polymorphism availability in Flix, Haskell, and Scala
// コンパイルできる
flix> def applyTwice(f: a -> a, x: a, y: a): (a, a) = (f(x), f(y))
Ok.
// コンパイルできない: 関数 needsRankN は a について多相だが、引数 f は単相である(そして多相にする手段が現状ない)ため
flix> def needsRankN(f: a -> a): (Int32, String) = (f(1), f("hello"))
-- Type Error [E7796] ------------------------------------------------------- $3
>> Unexpected type: expected 'Int32 -> a', found 'a -> a'.
1 | def needsRankN(f: a -> a): (Int32, String) = (f(1), f("hello"))
@lagenorhynque
lagenorhynque / repl_session.flix
Last active June 10, 2026 01:14
Records in Standard ML and Flix
flix> let {name | _} = {name = "Peter", age = 58}; name
Peter
flix> (p -> p#name)({name = "Peter", age = 58})
Peter
flix> ((p: {name = String | _}) -> p#name)({name = "Peter", age = 58})
-- Type Error [E7796] ------------------------------------------- __SHELL__.flix
>> Unexpected type: expected '{ age = Int32, name = String } -> String', found '{ name = String | _ } -> String'.
2 | def _f() = { println(((p: {name = String | _}) -> p#name)({name = "Peter", age = 58})) };
@lagenorhynque
lagenorhynque / mkslides.yml
Last active May 28, 2026 06:48
"Simple Made Easy" Made Easier: Clojureに学ぶsimplicity
slides:
charset: utf-8
theme: night
highlight_theme: monokai-sublime
separator_vertical: ^\s*----\s*$
revealjs:
transition: convex
plugins:
- extra_css:
- https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
@lagenorhynque
lagenorhynque / tagless_final.flix
Last active April 6, 2026 10:15
Tagless final pattern in Flix
// expressions as a type class
trait Expr[repr: Type -> Type] {
pub def int(n: Int32): repr[Int32]
pub def bool(b: Bool): repr[Bool]
pub def add(e1: repr[Int32], e2: repr[Int32]): repr[Int32]
pub def mul(e1: repr[Int32], e2: repr[Int32]): repr[Int32]
pub def eq(e1: repr[a], e2: repr[a]): repr[Bool] with Eq[a]
}
// an evaluator
@lagenorhynque
lagenorhynque / enum_with_record.flix
Last active April 6, 2026 02:55
Singleton enum with record in Flix
enum Person({ name = String, age = Int32 })
instance ToString[Person] {
pub def toString(p: Person): String = match p {
case Person.Person({ name, age }) =>
"Person(name = ${name}, age = ${age})"
}
}
def example(): Unit \ IO =
@lagenorhynque
lagenorhynque / mkslides.yml
Last active June 17, 2026 11:34
速習FP in Scala with Flix: Flix言語で親しむ純粋関数型のコード設計
slides:
charset: utf-8
theme: night
highlight_theme: monokai-sublime
separator_vertical: ^\s*----\s*$
revealjs:
transition: convex
plugins:
- extra_css:
- https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
@lagenorhynque
lagenorhynque / example.flix
Last active June 16, 2026 04:53
🐬's first Flix example code
use Sys.Process
// The main entry point.
def main(): Unit \ {Process, Abort, IO} =
println("Hello World!");
let n = 5;
println("The square of ${n} is ${square(n)}.");
runProcess()
@lagenorhynque
lagenorhynque / mkslides.yml
Last active January 30, 2026 00:28
Property-Based Testing with test.check and clojure.spec: ClojureでPBTに(再)入門しよう
slides:
charset: utf-8
theme: night
highlight_theme: monokai-sublime
separator_vertical: ^\s*----\s*$
revealjs:
transition: convex
plugins:
- extra_css:
- https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
@lagenorhynque
lagenorhynque / abstract-syntax-tree.drawio.svg
Last active December 10, 2025 08:11
🐬の推し本紹介2025: 『コーディングを支える技術 ―⁠―成り立ちから学ぶプログラミング作法』
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Kotlinでミニマルな

Result実装による

関数型エラーハンドリング