Skip to content
Back to skills

Low Level

ASecurity

Avoid low-level operations in Haskell such as Foreign modules, GHC.Foreign, and library Internal modules, and avoid choosing raw ByteString paths just for speed. Use public high-level APIs with simple high-level concurrency, and consult with measurements before going low-level for speed. Use when writing or optimizing Haskell code for performance, file system traversal, or concurrency.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsgoapiperformance

Works with

  • api

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add ncaq/konoka --skill low-level --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Low Level?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Low Level
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ncaq-low-level/badge)](https://www.skillsdirectory.com/skills/ncaq-low-level)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: low-level
description: Avoid low-level operations in Haskell such as Foreign modules, GHC.Foreign, and library Internal modules, and avoid choosing raw ByteString paths just for speed. Use public high-level APIs with simple high-level concurrency, and consult with measurements before going low-level for speed. Use when writing or optimizing Haskell code for performance, file system traversal, or concurrency.
user-invocable: false
---

# 低レベルな操作を避ける

以下のような低レベルな操作は使いません。

- `Foreign.*`や`GHC.Foreign`によるポインタやCの文字列の操作
- ライブラリの`Internal`や`Internals`のモジュール

ポインタの操作の誤りは型検査で検出されず、
メモリの破壊のようなHaskellでは本来起きないクラッシュを起こします。
内部モジュールは不変条件を守る責任が利用者に移り、
互換性の保証も無いことが多いです。
どちらもコードを読む人に低レベルな知識を要求します。

`RawFilePath`のような`ByteString`のままのパスの操作も、速度のためだけに選ぶのは避けます。

## 速度が要る時も公開APIと高水準の並列で書く

速度が足りない時も、まず`listDirectory`や`System.Posix.Files`のような公開APIで書きます。
並列化は、仕事をパスごとなどの単位に分けて、
高水準の関数でワーカに渡し、
結果を最後に集める素直な形にします。
CPUを使う仕事は`pooledForConcurrently`で、
IOを待つ時間が長い仕事は`pooledForConcurrentlyN`で並行度を明示して渡します。
`pooledForConcurrently`はワーカの数をcapabilityの数に絞るので、
IOを待つ仕事に使うと並行度が足りなくなるためです。
`forConcurrently`のように並行度に上限の無い関数は、
要素の数が多いとファイルディスクリプタを使い切るので避けます。
結果は戻り値で集めるのを基本にします。
ワーカ間で状態を共有する必要がある時は、
[haskell-tasuke:mutable](../mutable/SKILL.md)の通りSTMの変数を使います。

それでも桁違いに遅く、低レベルな操作に降りないと解決しないと考えられる場合は、
勝手に降りずに、計測値を示してユーザに相談します。

## 使ってよい場合

Cのライブラリへのバインディングを書くことそのものが目的の場合は、
`Foreign.*`を使って構いません。
その場合も、
[haskell-tasuke:unsafe](../unsafe/SKILL.md)の通り、
モジュールの内部に閉じ込めて安全なAPIだけを公開します。

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.