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 / 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 / example.flix
Last active March 22, 2026 08: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実装による

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


@lagenorhynque
lagenorhynque / functional-calisthenics-in-kotlin.md
Last active December 8, 2025 10:52
Functional Calisthenics in Kotlin: Kotlinで「関数型エクササイズ」を実践しよう

Functional Calisthenics

in Kotlin

Kotlinで「関数型エクササイズ」を実践しよう


@lagenorhynque
lagenorhynque / arith.clj
Last active September 5, 2025 14:27
『型システムのしくみ』(Type Systems Distilled with TypeScript) type checker implementations in Clojure
(ns arith
(:require
[clojure.spec.alpha :as s]))
;;; definition of terms
;;; <term> ::= true
;;; | false
;;; | (if <term> <term> <term>)
;;; | <number>
;;; | (+ <term>*)
@lagenorhynque
lagenorhynque / Factorial.hs
Created June 3, 2025 06:47
Factorial and Fibonacci functions in Haskell, Scala, Clojure and Elixir
module Factorial where
factorial :: Integral a => a -> a
factorial 0 = 1
factorial n = n * factorial (n - 1)
factorialSeq :: Integral a => [a]
factorialSeq = scanl (*) 1 [1..]
@lagenorhynque
lagenorhynque / FunctorApplicativeMonadTraversable.hs
Last active May 9, 2025 15:26
KotlinとHaskellでのFunctor, Applicative, Monad, Traversable (相当)の実装
λ> data Box a = Box a deriving (Show, Eq)
type Box :: * -> *
data Box a = ...
-- Functorの実装
λ> :{
λ| instance Functor Box where
λ| fmap f (Box x) = Box $ f x
λ| :}
-- Applicativeの実装
λ> :{