Add function that remembers whitespace

オープン
#294 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
haskell
領域
backend

調査の方向性

まず、既存の words 関数と lines 関数、および issue で提案されている wsSplit の実装を読んでください。ライブラリが Unicode の空白文字と通常のテストをどのように扱っているかを確認し、そのうえでサンプルの入力と出力を使い、空白文字の連続と非空白文字の連続が交互に現れる構成を保持することを完了条件として定義してください。

索引モデルが issue の本文から書いたものです。

説明

feature request

It would be nice to have a function like words/lines that remembers the relevant whitespace information. One implementation (which I haven't tested very thoroughly and is probably not the best one could do) is as follows:

wsSplit :: Text -> [Either Text Text]
wsSplit t@(Text arr off len)
  | Text.null t           = []
  | isSpace (Text.head t) = loop 0 0 True
  | otherwise             = loop 0 0 False
  where
    loop !start !n !wasSpace
        | n >= len = if wasSpace
                     then [Left  $ Text arr (start+off) (n-start)]
                     else [Right $ Text arr (start+off) (n-start)]
        | isSpace c && wasSpace = loop start (n + d) True
        | wasSpace  = Left  (Text arr (start+off) (n-start)) : loop n (n+d) False
        | isSpace c = Right (Text arr (start+off) (n-start)) : loop n (n+d) True
        | otherwise = loop start (n+d) False
        where Iter c d = iter t n
> wsSplit "hello    \t \n there!  \n"
[Right "hello",Left "    \t \n ",Right "there!",Left "  \n"]
主要言語
Haskell
スター
424
フォーク
167
平均マージ
1日 21時間
マージ済み PR(30日)
6

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

haskell/text のほかの issue

haskell/text の issue をすべて見る

似ている issue

Haskell の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。