私は、次のコードを持っている:Haskell Pipes:プロデューサの出力をどのように並べ替えるのですか?
import Control.Monad (unless)
import Pipes
import qualified Pipes.Prelude as P
import System.FilePath.Posix ((</>))
import System.Posix.Directory (DirStream, openDirStream, readDirStream)
produceFiles :: DirStream -> Producer FilePath IO()
produceFiles ds = do
path <- lift $ readDirStream ds
yield path
unless (path == "") $ produceFiles ds
getDC :: FilePath -> Producer FilePath IO()
getDC top = do
ds <- lift $ openDirStream top
produceFiles ds
runTest top = runEffect $ getDC top >-> P.map (top</>) >-> P.stdoutLn
それは、ディレクトリtop
内のすべてのファイルを印刷します。出力前に出力を並べ替えるにはどうすればよいですか?出力を最初にリストに流し込んだ後にソートする消費者を書く必要がありますか?私はパイプを使用しています - 4.1.4。