Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "himari",
"description": "HimariカスタムPreludeを使用したHaskellプロジェクト開発支援プラグイン",
"version": "0.1.0",
"author": {
"name": "ncaq",
"url": "https://github.com/ncaq"
},
"repository": "https://github.com/ncaq/himari",
"license": "Apache-2.0"
}
107 changes: 107 additions & 0 deletions skills/himari/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
name: himari
description: |
HimariカスタムPreludeを使用したHaskellプロジェクトの開発支援。
Himariモジュールのimport方法、lensアクセサ生成(makeFieldsId)、
convertibleによる型変換、MonadUnliftIOの活用、
エラーハンドリングのベストプラクティスをガイドします。
Haskell、カスタムPrelude、lens、rio代替を扱う際に適用されます。
---

# Himari Haskell Development Guide

HimariはrioライブラリのシンプルなカスタムPrelude代替です。

## Preludeのimport

```haskell
import Himari
```

## 言語設定

パッケージレベルで以下を設定済み:

```cabal
default-language: GHC2024
default-extensions:
NoImplicitPrelude
```

追加の言語拡張はモジュールレベルで個別に設定。

## 禁止事項

### 危険な言語拡張

- `AllowAmbiguousTypes`
- `ImplicitParams`
- `IncoherentInstances`
- `OverlappingInstances`
Comment on lines +38 to +40
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

危険な言語拡張のリストが不完全です。以下の言語拡張も禁止事項に含める必要があります:

  • ImpredicativeTypes
  • LiberalTypeSynonyms
  • RebindableSyntax

これらの拡張はcoding-style.mdと内部ガイドラインには記載されていますが、こちらには含まれていません。一貫性のため、全ての禁止されている言語拡張をリストアップするか、または詳細はcoding-style.mdを参照するように記載してください。

Suggested change
- `ImplicitParams`
- `IncoherentInstances`
- `OverlappingInstances`
- `ImplicitParams`
- `ImpredicativeTypes`
- `IncoherentInstances`
- `LiberalTypeSynonyms`
- `OverlappingInstances`
- `RebindableSyntax`

Copilot uses AI. Check for mistakes.
- `UndecidableInstances`
- `UndecidableSuperClasses`

### 危険な関数

- `error` - 純粋関数空間での例外は禁止
- `fromJust` - 部分関数
- `read` - 部分関数、代わりに`readMaybe`を使用
- `unsafePerformIO`系全般

Comment on lines +48 to +50
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

部分関数のリストが不完全です。coding-style.mdではhead, tail, (!!)も禁止されていますが、SKILL.mdには記載されていません。一貫性のため、全ての禁止されている部分関数をリストアップするか、または詳細はcoding-style.mdを参照するように記載してください。

Suggested change
- `read` - 部分関数、代わりに`readMaybe`を使用
- `unsafePerformIO`系全般
- `read` - 部分関数、代わりに`readMaybe`を使用
- `head` - 部分関数
- `tail` - 部分関数
- `(!!)` - 部分関数
- `unsafePerformIO`系全般
※ 他の禁止されている部分関数や詳細な理由については `coding-style.md` を参照してください。

Copilot uses AI. Check for mistakes.
## 型変換

`convert`関数で汎用的な型変換を行う:

```haskell
import Data.Convertible

-- pack/unpack/encodeUtf8/decodeUtf8より優先
text :: Text
text = convert someString
```

## 文字列型

`String`より`Text`を優先。`String`は非効率で日本語がエスケープされる。

## lensアクセサ

`NoFieldSelectors`拡張を前提に`makeFieldsId`を使用:

```haskell
data User = User
{ name :: Text
, email :: Text
}

makeFieldsId ''User
-- フィールドにプレフィクスやアンダースコアは不要
```
Comment on lines +71 to +79
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Template HaskellのLANGUAGEプラグマが記載されていません。makeFieldsIdを使用する際はTemplateHaskell拡張が必要です。コード例に以下を追加してください:

{-# LANGUAGE TemplateHaskell #-}

これはcoding-style.mdの185-202行目の例では正しく記載されています。

Copilot uses AI. Check for mistakes.

既存の型クラスがあれば自動的にインスタンスとして定義される。

## エラーハンドリング

- 例外には型をつけて`throwM`で投げる
- `throwString`より構造的なエラー型を定義
- `IO`文脈では`Either`/`Maybe`でのラップは非推奨、素直に例外を使用
- エラーを握り潰すのは禁止、最低限警告ログを出力

## IO抽象化

`IO`を直接使わず型クラスで抽象化:

```haskell
-- 良い例
foo :: MonadIO m => m ()

-- 悪い例
foo :: IO ()
```

`IO`内で`MonadUnliftIO`アクションを実行する場合は`askRunInIO`を使用。

## 詳細ドキュメント

- [coding-style.md](./coding-style.md) - 詳細なコーディング規約
- [examples.md](./examples.md) - 具体的な使用例
Loading