-- Copyright © 2025 Hashirama Senju {- this is an extremely fast and memory-constant program that lists mdx files in directories in recursive mode; the output is utf8, so that it can display japanese characters. notice that you can remove the filter and generalize this to search for any file that you want. -} {-# LANGUAGE OverloadedStrings #-} import Data.DirStream import Pipes import Pipes.Safe import System.IO (stdout, hSetEncoding, utf8) import qualified Data.Text as T import qualified Data.Text.IO as TIO import Filesystem.Path.CurrentOS (encodeString, extension) import Control.Monad (when) main :: IO () main = do hSetEncoding stdout utf8 runSafeT $ runEffect $ -- do a favor to yourself and please point to where the dictionaries actually are. for (every (descendentOf "/mnt/Data/Japanese_Resources/Dictionaries/")) $ \fp -> when (extension fp == Just "mdx") $ liftIO $ TIO.putStrLn $ T.pack $ encodeString fp