No slash command · from haskell-tasuke
Forbid unsafe Haskell functions such as unsafePerformIO, unsafeCoerce, and other unsafe-prefixed functions. Use when writing or reviewing Haskell code that uses any unsafe-prefixed function.
Ships in haskell-tasuke. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
名前にunsafeが付く関数は、
参照透過性や型安全性といったHaskellの根幹の保証を破壊するため、
原則として使用を禁止します。
unsafe接頭辞は「これを使うと言語の保証が効かなくなる」という作者からの警告です。
IOアクションを純粋なコンテキストで実行します。
参照透過性を破壊します。 GHCの最適化により評価回数や評価順序が変わったり、 共有によって一度しか実行されなかったりするため、 副作用のタイミングを予測できなくなります。
unsafePerformIOの制約をさらに緩めたものです。
複数のスレッドから同時に、
あるいは重複して実行される可能性があり、
unsafePerformIOよりも危険です。
IOアクションを遅延実行します。
実際に値が必要になるまで実行が遅延されるため、
副作用の発生タイミングが完全に非決定的になります。
遅延IOにまつわる諸問題の原因です。
IOにおける不動点を計算します。
まだ定まっていない値を参照するとデッドロックや実行時エラーになります。
ある型の値を無検査で別の型へ変換します。 型システムを完全に迂回するため、 誤用するとセグメンテーション違反など、 Haskellでは本来起こり得ないクラッシュを引き起こします。
bytestringのunsafeIndexや、
vectorのunsafeReadなど、
ライブラリにも境界チェックを省略するunsafe接頭辞の関数があります。
これらもパフォーマンスのために安全性を犠牲にしているので、
原則として安全版であるindexMaybeや!?などを使ってください。
Data.Coerce.coerceはunsafeCoerceと名前も用途も似ていますが別物です。
coerceはCoercible制約によってコンパイル時に安全性が保証されるため、
こちらは禁止しません。
newtypeの包み直しなどではunsafeCoerceではなくcoerceを使ってください。
FFIのバインディングや、
NOINLINEと組み合わせたグローバルな可変変数の定義など、
unsafePerformIOが事実上の定石になっている領域があります。
そうした場合でも、 ライブラリやモジュールの内部に閉じ込めて、 外部には純粋で安全なAPIだけを公開してください。 そしてなぜ安全と言えるのかをコメントで必ず明示してください。
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub ncaq/konoka --plugin haskell-tasuke19 skills in this plugin
/bracketUse bracket or with-style functions to guarantee resource cleanup even on exceptions instead of separate do blocks. Use when writing or reviewing Haskell code that acquires and releases resources./bump-cabal-index-stateUpdate Cabal project index-state to the latest timestamp. Use when it needs to bump the cabal index-state./cabal-commandUse cabal with --disable-optimization for development builds and tests, and add --enable-tests to avoid rebuilds. Use when running or suggesting cabal build or test commands in Haskell development./exceptionDo not throw exceptions from pure code with error or throw, give exceptions structured types, and never silently swallow errors in IO. Use when writing or reviewing Haskell error handling, exceptions, or IO code./exportExplicitly enumerate Haskell module exports instead of exporting everything implicitly, and use re-export sparingly. Use when writing or reviewing Haskell module export lists./function-resultDo not discard a function's final value with return (), pure (), or void; adjust the type to return the value and let the caller discard it when unneeded. Use when writing or reviewing Haskell functions that return unit or discard results.