codesnippets:filesystemioandstreams
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| codesnippets:filesystemioandstreams [2021/04/22 11:42] โ f2b216 | codesnippets:filesystemioandstreams [2025/10/08 00:48] (current) โ external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ~~DISCUSSION ~~ | ||
| ====== Filesystem IO and streams ====== | ====== Filesystem IO and streams ====== | ||
| Line 144: | Line 145: | ||
| ] | ] | ||
| </ | </ | ||
| - | * compiles ... | + | * compiles, error and warning free, with compiler: GHC 8.10.4, using compiler option -Wall |
| * executes with output as file copy of " | * executes with output as file copy of " | ||
| + | * example, with conversions | ||
| + | * code:< | ||
| + | import qualified FileSystem as FS | ||
| + | import qualified System.IO as SysIo | ||
| + | import qualified Data.Char as Ch | ||
| + | |||
| + | main :: IO () | ||
| + | main = | ||
| + | FS.processData | ||
| + | (FS.DataReader (FS.FileInp " | ||
| + | [ | ||
| + | FS.DataWriter (FS.FileOut " | ||
| + | FS.DataWriter FS.StdOut hPutToLower, | ||
| + | FS.DataWriter FS.StdErr SysIo.hPutStr | ||
| + | ] | ||
| + | |||
| + | hGetToUpper :: SysIo.Handle -> IO String | ||
| + | hGetToUpper h = | ||
| + | do | ||
| + | s <- SysIo.hGetContents h | ||
| + | return (fmap Ch.toUpper s) | ||
| + | |||
| + | hPutToLower :: SysIo.Handle -> String -> IO () | ||
| + | hPutToLower h s = SysIo.hPutStr h (fmap Ch.toLower s) | ||
| + | </ | ||
| + | * input, file " | ||
| + | The quick brown fox jumps over the lazy dog. | ||
| + | </ | ||
| + | * output, in terminal:< | ||
| + | the quick brown fox jumps over the lazy dog. | ||
| + | THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. | ||
| + | </ | ||
| + | * output, file " | ||
| + | THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== โ ===== | ||
| + | ~~DISCUSSION~~ | ||
codesnippets/filesystemioandstreams.1619084577.txt.gz ยท Last modified: (external edit)
