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

関数型言語テイスティング

Haskell, Scala, Clojure, Elixirを比べて味わう関数型プログラミングの旨さ

#fp_matsuri


x icon

@lagenorhynque
lagenorhynque / money.clj
Last active April 11, 2025 01:25
『改訂新版 良いコード/悪いコードで学ぶ設計入門』(ミノ駆動本) 3章のサンプルコードを関数型言語Clojureで書いてみる
(ns money
(:refer-clojure :exclude [+])
(:require
[clojure.spec.alpha :as s])
(:import
(java.util
Currency)))
(s/def ::amount nat-int?)
(s/def ::currency #(instance? Currency %))
@lagenorhynque
lagenorhynque / MyPrelude.hs
Last active March 27, 2025 02:07
Reimplementation of typical higher-order functions in Clojure, Elixir, Scala and Haskell
module MyPrelude where
import Prelude hiding (filter, foldl, foldr, map, reverse)
foldLeft :: (b -> a -> b) -> b -> [a] -> b
foldLeft _ acc [] = acc
foldLeft f acc (x:xs) = foldLeft f (f acc x) xs
reverse' :: [a] -> [a]
reverse' = foldLeft (flip (:)) []
@lagenorhynque
lagenorhynque / functional-language-primitives-from-the-perspective-of-pure-lisp.md
Last active March 27, 2025 02:48
純LISPから考える関数型言語のプリミティブ: Clojure, Elixir, Haskell, Scala

純LISPから考える

関数型言語のプリミティブ

Clojure, Elixir, Haskell, Scala

#lispmeetup


@lagenorhynque
lagenorhynque / from-scala-clojure-to-kotlin.md
Last active February 28, 2025 07:04
From Scala/Clojure to Kotlin
scala> enum ShippingCategory:
| case UsLocalState, UsRemoteState, International
|
// defined class ShippingCategory
scala> object Address:
| class AddressInfo(val country: String, val state: String)
|
| def apply(country: String, state: String) = AddressInfo(country, state)
|
@lagenorhynque
lagenorhynque / start-presentation.sh
Last active January 24, 2025 11:22
TDD with RDD: Clojure/LispのREPLで変わる開発体験
#!/usr/bin/env bash
# npm install -g reveal-md
reveal-md tdd-with-rdd.md --theme night --highlight-theme monokai-sublime -w $@
@lagenorhynque
lagenorhynque / core.clj
Created December 26, 2024 02:07
Test-driven development (TDD) with REPL-driven development in Clojure
(ns clj-tdd-with-rdd.core
(:require
[clojure.spec.alpha :as s]
[clojure.string :as str]))
(s/fdef fizzbuzz
:args (s/cat :n pos-int?)
:ret string?)
(defn fizzbuzz [n]
@lagenorhynque
lagenorhynque / my-favourite-book-in-2024_get-rid-of-your-japanese-accent.md
Last active December 18, 2024 10:22
🐬の推し本紹介2024: 『脱・日本語なまり 英語(+α)実践音声学』
@lagenorhynque
lagenorhynque / do_notation.clj
Created November 22, 2024 08:57
monads and do notation equivalents in Clojure
(ns do-notation
(:require
[clojure.math]))
;;; monad protocol
(defprotocol Monad
(return [this x])
(bind [this f m]))