Skip to content

Commit 456316c

Browse files
Cleanup and doc updates
1 parent e56e5b2 commit 456316c

6 files changed

Lines changed: 33 additions & 32 deletions

File tree

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Streamly Coreutils
22

33
This repository provides Haskell functions that reimplement common
4-
GNU `coreutils` commands, leveraging the `streamly` library for
4+
GNU `coreutils` commands, utilizing the `streamly` library for
55
efficient, streaming data processing where applicable. The goal is to
66
offer a functional and highly performant alternative to traditional
77
shell commands within Haskell applications, enabling complex data
8-
transformations and system interactions using a pure functional
9-
paradigm. Where applicable, these implementations are designed to be
8+
transformations, system programming and scripting using a pure functional
9+
paradigm. Where applicable, the implementation is designed to be
1010
highly concurrent, for example, the `ls` equivalent can list directory
1111
contents concurrently for improved performance.
1212

@@ -15,11 +15,16 @@ contents concurrently for improved performance.
1515
Currently, this library provides implementations for the
1616
following coreutils-inspired as well as some additional commands:
1717

18-
* Filesystem: `cp`, `rm`, `mv`, `ln`, `readlink`, `test`, `stat`, `touch`
19-
* Directories: `ls`, `dirname`, `mkdir`, `cd`, `pwd`, `home` and others
18+
* Dir traversal: `ls`, `cp -r`, `rm -r`
19+
* Dir modify: `touch`, `ln`, `cp`, `mkdir`, `rm`, `mv`
20+
* File stat: `test`, `stat`, `touch`
21+
* File read/write: `cp`
22+
* Symlink read: `readlink`
23+
* Processes: `cd`, `pwd`, `sleep`
24+
* Environment: `home`
2025
* Text Processing: `cut`, `tail`
21-
* Processes: `sleep`
22-
* Shell: `which`, executing shell commands with streaming
26+
* Shell: streaming composition of shell commands
27+
* Paths: `dirname`, `which`
2328

2429
## Important API Notice
2530

src/Streamly/Coreutils.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
-- Portability : GHC
88
--
99
module Streamly.Coreutils
10-
( module Streamly.Coreutils.Uniq
11-
, module Streamly.Coreutils.Cp
10+
( module Streamly.Coreutils.Cp
1211
, module Streamly.Coreutils.FileTest
1312
)
1413
where
1514

16-
import Streamly.Coreutils.Uniq
1715
import Streamly.Coreutils.Cp
1816
import Streamly.Coreutils.FileTest

src/Streamly/Coreutils/Cut.hs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
-- Functionality equivalent to the @cut@ command.
1010

1111
module Streamly.Coreutils.Cut
12-
( foldIndicesBy
12+
( foldIndicesBy -- XXX rename to cut
13+
14+
-- * Deprecated
1315
, decodeLatin1
1416
, readLines
1517
, splitByWord8
@@ -41,7 +43,9 @@ decodeLatin1 arr =
4143
& Stream.toList
4244
& runIdentity
4345

44-
-- XXX this should go in unicode text file reading module - Unicode.FileIO?
46+
-- XXX this should go in unicode text file reading module - Unicode.FileIO or
47+
-- cat coreutil? Redirection ">" can have its own "pipeTo" or "redirectTo"
48+
-- function.
4549
-- e.g. readUtf8, writeUtf8, readLines, readWords, readWordsBy, readDSV,
4650
-- readDSVSeq
4751

@@ -119,9 +123,12 @@ filterIndices :: Monad m =>
119123
[Int] -> Stream m a -> Stream m a
120124
filterIndices xs = filterByMask (Stream.fromList (makeIndexMask xs))
121125

122-
-- | Split the lines in a file using the given separator and then fold the
123-
-- selected indices (indices start from 0) in each line using the supplied
124-
-- fold.
126+
-- XXX Rename to "cut" using "CutOptions". fold, indices can be part of
127+
-- CutOptions with defaults.
128+
129+
-- | @foldIndicesBy fold indices separator file@. Split the lines in a file
130+
-- using the given separator and then fold the selected indices (indices start
131+
-- from 0) in each line using the supplied fold.
125132
--
126133
-- For example to generate an array of the selected indices for each line:
127134
--

src/Streamly/Coreutils/FileTest.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module Streamly.Coreutils.FileTest
116116
--
117117
-- On POSIX systems, this checks the standard Unix permission bits.
118118
--
119-
-- On Windows, only one or two predicates make sense:
119+
-- On Windows, only select few predicates make sense:
120120
--
121121
-- * 'hasOwnerWrite' - returns false if the file is marked read only via attributes.
122122
-- * 'hasOwnerExec' - returns true based on the file extension: @.bat@, @.cmd@,
@@ -150,9 +150,9 @@ module Streamly.Coreutils.FileTest
150150

151151
-- *** Mode based access
152152
-- | These APIs perform only the file permission mode checks, actual
153-
-- readability, writability or executability may depend many other factors
153+
-- readability, writability or executability may depend on many other factors
154154
-- like filesystem mount permissions, access control lists (ACLs) etc. For
155-
-- deeper checks see: 'isReadable', 'isWritable', 'isExecutable'.
155+
-- more comprehensive checks see: 'isReadable', 'isWritable', 'isExecutable'.
156156
--
157157
, isReadableByMode
158158
, isWritableByMode
@@ -209,6 +209,8 @@ module Streamly.Coreutils.FileTest
209209
--
210210
-- >>> let _ = modifiedWithin (days 1 + hours 5 + minutes 10 + seconds 20)
211211

212+
-- XXX These can be moved to the streamly time module.
213+
212214
-- *** Time units
213215
, seconds
214216
, minutes

src/Streamly/Coreutils/Touch.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ module Streamly.Coreutils.Touch
1414

1515
-- * Options
1616
, Touch
17-
, create
18-
, followLinks
17+
, create -- XXX rename for conflicts
18+
, followLinks -- XXX this is a common option in multiple commands
1919
)
2020
where
2121

streamly-coreutils.cabal

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 2.4
22
name: streamly-coreutils
33
version: 0.1.0
4-
synopsis: GNU Coreutils like API for Streamly
4+
synopsis: GNU Coreutils like API for Haskell
55
description:
66
Streaming Haskell implementations of GNU coreutils, built on
77
Streamly. Provides familiar, composable, high-performance,
@@ -171,17 +171,6 @@ library
171171
-- Test suites
172172
-------------------------------------------------------------------------------
173173

174-
-- test-suite coreutils-test
175-
-- import: compile-options
176-
-- type: exitcode-stdio-1.0
177-
-- main-is: Main.hs
178-
-- hs-source-dirs: test
179-
-- build-depends:
180-
-- streamly-coreutils
181-
-- , streamly-core
182-
-- , base >= 4.8 && < 5
183-
-- default-language: Haskell2010
184-
185174
test-suite Streamly.Coreutils.Rm
186175
import: compile-options
187176
type: exitcode-stdio-1.0

0 commit comments

Comments
 (0)