Data.Listのwords関数がそれっぽい挙動をしている
https://downloads.haskell.org/~ghc/7.4.1/docs/html/libraries/base/src/Data-List.html
import Data.Char ( isSpace ) words :: String -> [String] words s = case dropWhile {-partain:Char.-}isSpace s of "" -> [] s' -> w : words s'' where (w, s'') = break {-partain:Char.-}isSpace s'
こんなかんじか
結局isSpaceっていうのを使ってる
import Data.Char ( isSpace ) hogewords :: String -> [String] hogewords s = case dropWhile {-partain:Char.-}isSpace s of "" -> [] s' -> w : hogewords s'' where (w, s'') = break {-partain:Char.-}isSpace s' main = do print $ hogewords "hoge moge"
Data.Char(isSpace)の定義
git.haskell.org/packages/base/GHC/Unicode.hs
isSpace :: Char -> Bool -- isSpace includes non-breaking space -- Done with explicit equalities both for efficiency, and to avoid a tiresome -- recursion with GHC.List elem isSpace c = c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v' || c == '\xa0' || iswspace (fromIntegral (ord c)) /= 0