Skip to content

Instantly share code, notes, and snippets.

ドメインモデル貧血症はなぜ生まれるのか — Decision パターンで DDD トリレンマを解くについて、Vladimir Khorikov さんなら「いや、それは impure だよ」と言う気がしてきた。説明してみる。


まず Khorikov さんは、プロセス外への依存をインターフェースやデリゲートで包んでも、純粋性は回復しないと明言している。これは次のようなものを指す。

interface IViewService {
  boolean isFollowing(UserId viewer, UserId author);
  boolean isVip(UserId viewer);
@Hogeyama
Hogeyama / .envrc
Created April 2, 2026 13:31
NixOS + Playwright CLI demo
use flake
PATH_add node_modules/.bin

これは何?

Docker公式ではaptのキャッシュの方法として以下の例を紹介している。 しかし、例の中で言及されていない id をうまく設定しないとキャッシュがうまく動かない(あるいは最悪依存関係が壊れる?)のではないかと気づいたのでデモンストレーションする

# syntax=docker/dockerfile:1
FROM ubuntu
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
@Hogeyama
Hogeyama / add_backlinks.ts
Created September 24, 2025 16:01
Add backlinks to markdown
/**
* Example:
*
* ```java
* withEarlyReturn(Result.class, (c) -> {
* var value = switch (someAction()) {
* case Success(var value) -> {
* return value;
* }
* case Failure(var error) -> {
@Hogeyama
Hogeyama / justfile
Last active December 17, 2025 05:43
md2textile by pandoc, textile2md by orchitech/redmine_reformat microservice
init:
#!/usr/bin/env -S bash -euo pipefail -o noclobber
echo "[Generating Dockerfile...]"
cat - > Dockerfile <<'EOF'
FROM redmine:6.0.3
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
libxml2-dev \
libxslt1-dev \
@Hogeyama
Hogeyama / PostgreSQL.hs
Last active November 4, 2024 17:10
Reusable PostgreSQL TestContainer
module TestUtil.PostgreSQL
( PostgreSQL (..)
, withPostgreSQL
, withSharedPostgreSQL
, runQueryBeforeAll
, runQueryBefore
, stopAllContainers
) where
import Control.Monad.Logger (MonadLoggerIO, runNoLoggingT, runStderrLoggingT)
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+n",
"command": "workbench.action.files.save"
},
{
"key": "ctrl+s",
"command": "-workbench.action.files.save"
},
-- |
-- import文の後に
-- @
-- -- $setup
-- -- >>> import DoctestUtil
-- @
-- と書いておくと便利
module DoctestUtil
( pretty
, capture
@Hogeyama
Hogeyama / unliftio.hs
Last active October 6, 2024 13:37
MonadUnliftIO (ExceptT e m)
-- [Control.Monad.IO.Unlift](https://hackage.haskell.org/package/unliftio-core-0.2.1.0/docs/Control-Monad-IO-Unlift.html#t:MonadUnliftIO)
-- 定義はできるがInverse lawが成り立たないのでダメ
-- withRunInIO (\_ -> throwIO e) === liftIO (throwIO e)
-- にならないといけないが、pure (Left e)になってしまう。
-- たぶんjoinの保存則も成り立たないんじゃないかな。
--
-- あと、askUnliftIOを使うとtryのスコープを抜けてしまって酷いバグになりそう。
-- askUnliftIO = withRunInIO (\run -> return (UnliftIO run))
instance (MonadUnliftIO m, Exception e) => MonadUnliftIO (ExceptT e m) where
withRunInIO inner =