Dynamically check `FsPath` invariants
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- haskell
調査の方向性
まず FsPath の定義と pull request 72 の設計に関する議論を読んでください。提案されている invariant、unsafeFsPathFromList、fsPathFromList API を既存のパスの挙動と比較し、force と assert のトレードオフを検討してください。動的チェックが妥当かどうかについて合意し、検証済みの構築と escape hatch による構築の挙動をオペレーティングシステム間で一貫する形で定義できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
First suggested in https://github.com/input-output-hk/fs-sim/pull/72#issue-2337874221. FsPath has a number of invariants, and we currently rely on the user to satisfy them. It might be nice to check these invariants dynamically, while also providing an escape hatch for users in case they want to skip the check. For example:
newtype FsPath = UnsafeFsPath { fsPathToList :: [Strict.Text] }
deriving (Eq, Ord, Generic)
deriving newtype NFData
invariant :: FsPath -> Bool
invariant (UnsafeFsPath xs) = all p xs
where p x = -- Paths are monotonic
x /= ".."
&& -- Paths can not have empty directory/file names
not (any Strict.null xs)
&& -- There are no path separators in individual names
not (Text.any (`Text.elem` allPathSeparators) x)
allPathSeparators :: Text
allPathSeparators = Text.pack (Posix.pathSeparators ++ Windows.pathSeparators)
unsafeFsPathFromList :: [Strict.Text] -> FsPath
unsafeFsPathFromList xs = assert (invariant fsp) $ fsp
where fsp = UnsafeFsPath (force xs)
fsPathFromList :: [Strict.Text] -> Maybe FsPath
fsPathFromList xs
| invariant fsp = Just fsp
| otherwise = Nothing
where fsp = UnsafeFsPath (force xs)
Note two things in the example above:
- Both
unsafeFsPathFromListandfsPathFromListensure that the resultingFsPathcontains no thunks my usingforce. Maybe we want toassertinstead that theFsPathcontains no thunks inunsafeFsPathFromList, and have the user ensure that fact. - To ensure similar behaviour across OS distributions, invariant checks do not depend on the underlying OS distribution, hence
allPathSeparators.
We should also consider whether this design pattern is overkill: in practice, users are probably unlikely to use non-sensible path names
- 主要言語
- Haskell
- スター
- 2
- フォーク
- 6
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
IntersectMBO/fs-sim のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
IntersectMBO/fs-sim#137 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 45/100
IntersectMBO/fs-sim#136 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
IntersectMBO/fs-sim#135 ·
-
No 0.4.1.0 tagオープン
難易度 1/5 1時間未満 初心者へのやさしさ 55/100
IntersectMBO/fs-sim#125 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
IntersectMBO/fs-sim#122 ·
IntersectMBO/fs-sim の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
-
15-minutes 5-minutes algorithm any-language beginner-friendly c cpp csharp easy go good first issue hacktoberfest help wanted java javascript kotlin python rust swift typescript
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
Huerte/algo-solutions-python#260 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
IntersectMBO/cardano-ledger#6276 ·
メンテナーはふだん 1 日以内に返信