diff --git a/app/hfd.hs b/app/hfd.hs index 7918a96d..156ad4c7 100644 --- a/app/hfd.hs +++ b/app/hfd.hs @@ -25,7 +25,7 @@ import qualified Streamly.Data.Stream.Prelude as Stream import qualified Streamly.FileSystem.Handle as Handle import qualified Streamly.FileSystem.Path as Path -import Streamly.Coreutils.Find +import Coreutils.Find ( FindOptions , findByteChunked , maxResults @@ -114,7 +114,7 @@ parserInfo = (configParser <**> helper) (fullDesc <> briefDesc - <> progDesc "A basic fd-like driver for Streamly.Coreutils.Find." + <> progDesc "A basic fd-like driver for Coreutils.Find." <> header "hfd") main :: IO () diff --git a/benchmark/Main.hs b/benchmark/Main.hs index dc8738d5..46debf38 100644 --- a/benchmark/Main.hs +++ b/benchmark/Main.hs @@ -7,7 +7,7 @@ import Control.Monad.IO.Class (MonadIO) import Gauge import Streamly.Data.Stream (Stream) import System.Random -import Streamly.Coreutils.Uniq +import Coreutils.Uniq import qualified Streamly.Data.Stream as S import qualified Streamly.Data.Fold as Fold diff --git a/design/design-notes.md b/design/design-notes.md index bf58eb35..11d5d79c 100644 --- a/design/design-notes.md +++ b/design/design-notes.md @@ -29,28 +29,6 @@ sugegsted above. We can basically wrap the Haskell functions in CLI parser and an output renderer to make a Unix like utility. -## Module Naming - -We can either keep each utility in its own module or bundle them into a smaller -set of modules. The latter would help reduce the imports. But it may be easier -to remember the module names if they are based on the utility name. - -We should keep the naming non-conflicting such that if some wants to bundle -them in a single module and re-export it should be possible. In fact we can -provide a single coreutils module exporting everything. - -Each command must have its own module e.g. Coreutils.Cp for the cp command. - -The command options could be called "Options" in each module but then -we may not be able to export all commands from a single module which is -desirable. So we can choose to call the options of a command by the same -name as the command itself e.g. "CpOptions". We would not expose the -CpOptions record outside the module but we would still need to export -the type. Using a unique type for each command would help us use it -unqualified. - -The command runner would be called "cp" so it would be "cp :: CpOptions -> IO ()". - ## API for utilities There are two ways of writing the API, (1) use separate functions diff --git a/design/naming.md b/design/naming.md new file mode 100644 index 00000000..dfa36fea --- /dev/null +++ b/design/naming.md @@ -0,0 +1,53 @@ +## Module Naming + +## Problem + +Multiple Haskell modules (`touch`, `mv`, `rm`) expose option setters with the +same names (e.g., `force`, `recursive`), causing name conflicts when +aggregating them into a single module. + +## Options considered + +1. Import modules separately (qualified) +2. Rename functions to be unique (`mvForce`, `rmForce`, etc.) +3. Use typeclasses to overload names +4. Provide an aggregated module with aliases + +## Decision + +Use separate modules with qualified imports. Each command can have its own +module e.g. Coreutils.Cp for the cp command. It may be easy to remember the +module names if they are based on the utility name. + +## Rationale + +This avoids naming conflicts without renaming functions, keeps the API +intuitive and avoids unnecessary complexity. + +The downside is too many imports. But users get to choose what they +import them as, that gives the flexibility of choosing the prefix +rather than hardocding it in the function name itself. Imports can be +automatically managed. + +Things that do not conflict can still be imported as a single import i.e. +as Coreutils. + +## Best Effort + +Let users bundle it if they want to. We can try to keep the naming +non-conflicting as much as we can such that if someone wants to bundle them in +a single module and re-export it should be possible with least effort. + +To avoid conflicts, the options for Cp could be called "CpOptions" and +similarly for each module. Otherwise, we may not be able to export all +commands from a single module which is desirable. Using a unique type +for each command would help us use it unqualified. + +The command runner would be called "cp" so it would be "cp :: CpOptions -> IO +()". + +## Example usage + +`Touch.touch (Touch.create False . Touch.followLinks False) path` +`Mv.mv (Mv.force True) old new` +`Rm.rm (Rm.withForce Rm.Force . Rm.recursive True) path` diff --git a/hie.yaml b/hie.yaml index f8f7c320..a2837b03 100644 --- a/hie.yaml +++ b/hie.yaml @@ -7,7 +7,7 @@ cradle: - path: "./src" component: "lib:streamly-coreutils" - path: "./test" - component: "test:Streamly.Coreutils.Rm" + component: "test:Coreutils.Rm" dependencies: - streamly-coreutils.cabal - hie.yaml diff --git a/src/Coreutils.hs b/src/Coreutils.hs new file mode 100644 index 00000000..f3f8e81d --- /dev/null +++ b/src/Coreutils.hs @@ -0,0 +1,16 @@ +-- | +-- Module : Coreutils +-- Copyright : (c) 2020 Composewell Technologies +-- License : Apache-2.0 +-- Maintainer : streamly@composewell.com +-- Stability : experimental +-- Portability : GHC +-- +module Coreutils + ( module Coreutils.Cp + , module Coreutils.FileTest + ) +where + +import Coreutils.Cp +import Coreutils.FileTest diff --git a/src/Streamly/Coreutils/Chmod.hs b/src/Coreutils/Chmod.hs similarity index 98% rename from src/Streamly/Coreutils/Chmod.hs rename to src/Coreutils/Chmod.hs index 50bc9624..dd2e5c58 100644 --- a/src/Streamly/Coreutils/Chmod.hs +++ b/src/Coreutils/Chmod.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Chmod +-- Module : Coreutils.Chmod -- Copyright : (c) 2026 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -17,7 +17,7 @@ -- >>> _ = chmod (additive True) (groupWrite False) -- chmod g-w FILE -- >>> _ = chmod (modeFrom file) (groupWrite True) -- chmod --reference=ref FILE -module Streamly.Coreutils.Chmod +module Coreutils.Chmod ( -- * Runner chmod @@ -60,7 +60,7 @@ import qualified Streamly.FileSystem.Path as Path -- $setup -- >>> :set -XQuasiQuotes --- >>> import Streamly.Coreutils.Chmod +-- >>> import Coreutils.Chmod -- >>> import Streamly.FileSystem.Path (path) -- >>> file = [path|a.txt|] diff --git a/src/Streamly/Coreutils/Common.hs b/src/Coreutils/Common.hs similarity index 95% rename from src/Streamly/Coreutils/Common.hs rename to src/Coreutils/Common.hs index 6fc81b2d..8dd9225e 100644 --- a/src/Streamly/Coreutils/Common.hs +++ b/src/Coreutils/Common.hs @@ -2,7 +2,7 @@ {-# LANGUAGE PatternSynonyms #-} -- | This module is deprecated. Use 'Data.Bool' and 'Bool' instead. -module Streamly.Coreutils.Common +module Coreutils.Common {-# DEPRECATED "This module is deprecated. Please use 'Bool' from 'Data.Bool' instead." #-} ( Switch #if __GLASGOW_HASKELL__ >= 914 diff --git a/src/Streamly/Coreutils/Cp.hs b/src/Coreutils/Cp.hs similarity index 97% rename from src/Streamly/Coreutils/Cp.hs rename to src/Coreutils/Cp.hs index 0e3301e6..7312ea47 100644 --- a/src/Streamly/Coreutils/Cp.hs +++ b/src/Coreutils/Cp.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Cp +-- Module : Coreutils.Cp -- Copyright : (c) 2022 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Copy a file or directory. -module Streamly.Coreutils.Cp +module Coreutils.Cp ( cp -- * Cp options @@ -28,7 +28,7 @@ import qualified Streamly.Internal.FileSystem.FileIO as File import Streamly.FileSystem.Path (Path) import qualified Streamly.FileSystem.Path as Path -import Streamly.Coreutils.FileTest +import Coreutils.FileTest -- Note: Recursive copy can be done using find. -- diff --git a/src/Streamly/Coreutils/Cut.hs b/src/Coreutils/Cut.hs similarity index 98% rename from src/Streamly/Coreutils/Cut.hs rename to src/Coreutils/Cut.hs index 2503463d..ecabbb68 100644 --- a/src/Streamly/Coreutils/Cut.hs +++ b/src/Coreutils/Cut.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Cut +-- Module : Coreutils.Cut -- Copyright : (c) 2025 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Functionality equivalent to the @cut@ command. -module Streamly.Coreutils.Cut +module Coreutils.Cut ( foldIndicesBy -- XXX rename to cut -- * Deprecated diff --git a/src/Streamly/Coreutils/Directory.hs b/src/Coreutils/Directory.hs similarity index 93% rename from src/Streamly/Coreutils/Directory.hs rename to src/Coreutils/Directory.hs index 3ec984e7..a542627b 100644 --- a/src/Streamly/Coreutils/Directory.hs +++ b/src/Coreutils/Directory.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Directory +-- Module : Coreutils.Directory -- Copyright : (c) 2022 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Perform directory related operations. -module Streamly.Coreutils.Directory +module Coreutils.Directory ( home , pwd , cd diff --git a/src/Streamly/Coreutils/Dirname.hs b/src/Coreutils/Dirname.hs similarity index 85% rename from src/Streamly/Coreutils/Dirname.hs rename to src/Coreutils/Dirname.hs index 167f2237..d6c96bcd 100644 --- a/src/Streamly/Coreutils/Dirname.hs +++ b/src/Coreutils/Dirname.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Dirname +-- Module : Coreutils.Dirname -- Copyright : (c) 2022 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Strip the last component from file name. -module Streamly.Coreutils.Dirname +module Coreutils.Dirname (dirname) where diff --git a/src/Streamly/Coreutils/FileTest.hs b/src/Coreutils/FileTest.hs similarity index 98% rename from src/Streamly/Coreutils/FileTest.hs rename to src/Coreutils/FileTest.hs index 5ee5488b..1e909d6f 100644 --- a/src/Streamly/Coreutils/FileTest.hs +++ b/src/Coreutils/FileTest.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.FileTest +-- Module : Coreutils.FileTest -- Copyright : (c) 2021 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -72,7 +72,7 @@ -- >>> _ <- test [path|/usr/bin/ls|] (isReadable `and_` size (> 4096)) -- >>> _ <- test [path|/usr/bin/ls|] (modifyTimeComparedTo [path|reference.txt|] (>)) -module Streamly.Coreutils.FileTest +module Coreutils.FileTest ( -- * File Test Predicate Type FileTest @@ -249,13 +249,13 @@ import System.Posix.Types (Fd, FileMode) import qualified System.PosixCompat.Files as Files #if !defined(CABAL_OS_WINDOWS) -import qualified Streamly.Coreutils.FileTest.Posix as FileTest +import qualified Coreutils.FileTest.Posix as FileTest #else -import qualified Streamly.Coreutils.FileTest.Windows as FileTest +import qualified Coreutils.FileTest.Windows as FileTest #endif import Streamly.FileSystem.Path (Path) -import Streamly.Coreutils.FileTest.Common +import Coreutils.FileTest.Common import Prelude hiding (and, or) -- $setup diff --git a/src/Streamly/Coreutils/FileTest/Common.hs b/src/Coreutils/FileTest/Common.hs similarity index 99% rename from src/Streamly/Coreutils/FileTest/Common.hs rename to src/Coreutils/FileTest/Common.hs index c2f2811e..17cf5432 100644 --- a/src/Streamly/Coreutils/FileTest/Common.hs +++ b/src/Coreutils/FileTest/Common.hs @@ -3,14 +3,14 @@ {-# LANGUAGE ScopedTypeVariables #-} -- | --- Module : Streamly.Coreutils.FileTest.Common +-- Module : Coreutils.FileTest.Common -- Copyright : (c) 2021 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com -- Stability : experimental -- Portability : GHC -- --- See "Streamly.Coreutils.FileTest" module for general module level +-- See "Coreutils.FileTest" module for general module level -- documentation. This module provides both posix and windows implementations. -- -- Design Notes: @@ -68,7 +68,7 @@ -- XXX Need tests for Windows. Especially for file access permissions. How do -- ACLs affect it? Also file times. -module Streamly.Coreutils.FileTest.Common +module Coreutils.FileTest.Common ( -- * File Test Predicate Type Predicate (..) diff --git a/src/Streamly/Coreutils/FileTest/Posix.hs b/src/Coreutils/FileTest/Posix.hs similarity index 92% rename from src/Streamly/Coreutils/FileTest/Posix.hs rename to src/Coreutils/FileTest/Posix.hs index 03eb6d70..3f66eddf 100644 --- a/src/Streamly/Coreutils/FileTest/Posix.hs +++ b/src/Coreutils/FileTest/Posix.hs @@ -1,16 +1,16 @@ -- | --- Module : Streamly.Coreutils.FileTest.Posix +-- Module : Coreutils.FileTest.Posix -- Copyright : (c) 2021 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com -- Stability : experimental -- Portability : GHC -- --- See "Streamly.Coreutils.FileTest" module for general module level +-- See "Coreutils.FileTest" module for general module level -- documentation. This is a posix specific version of --- "Streamly.Coreutils.FileTest" with some additional posix specific functions. +-- "Coreutils.FileTest" with some additional posix specific functions. -module Streamly.Coreutils.FileTest.Posix +module Coreutils.FileTest.Posix ( testFd , testHandle , sameFileAs @@ -36,7 +36,7 @@ import qualified System.Posix.Terminal as Terminal import Streamly.FileSystem.Path (Path) import qualified Streamly.FileSystem.Path as Path -import Streamly.Coreutils.FileTest.Common +import Coreutils.FileTest.Common -- XXX 'getFdStatus' is not implemented for Windows in unix-compat. diff --git a/src/Streamly/Coreutils/FileTest/Windows.hsc b/src/Coreutils/FileTest/Windows.hsc similarity index 99% rename from src/Streamly/Coreutils/FileTest/Windows.hsc rename to src/Coreutils/FileTest/Windows.hsc index ff8abce8..038dc077 100644 --- a/src/Streamly/Coreutils/FileTest/Windows.hsc +++ b/src/Coreutils/FileTest/Windows.hsc @@ -2,7 +2,7 @@ {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ScopedTypeVariables #-} -module Streamly.Coreutils.FileTest.Windows +module Coreutils.FileTest.Windows ( sameFileAs , isTerminalFd {- @@ -83,7 +83,7 @@ import qualified System.Win32.Types as Win32 import Foreign import Streamly.FileSystem.Path (Path) import qualified Streamly.FileSystem.Path as Path -import Streamly.Coreutils.FileTest.Common +import Coreutils.FileTest.Common ------------------------------------------------------------------------------- -- Types diff --git a/src/Streamly/Coreutils/Find.hs b/src/Coreutils/Find.hs similarity index 99% rename from src/Streamly/Coreutils/Find.hs rename to src/Coreutils/Find.hs index ef797d25..b2d71897 100644 --- a/src/Streamly/Coreutils/Find.hs +++ b/src/Coreutils/Find.hs @@ -3,7 +3,7 @@ {-# OPTIONS_GHC -Wno-unused-binds #-} {-# OPTIONS_GHC -Wno-unused-imports #-} -- | --- Module : Streamly.Coreutils.Find +-- Module : Coreutils.Find -- Copyright : (c) 2026 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -61,7 +61,7 @@ -- time hfind > /dev/null # This, Haskell implementation -- @ -module Streamly.Coreutils.Find +module Coreutils.Find ( find , findChunked diff --git a/src/Streamly/Coreutils/Id.hs b/src/Coreutils/Id.hs similarity index 98% rename from src/Streamly/Coreutils/Id.hs rename to src/Coreutils/Id.hs index d22c8454..a594eecb 100644 --- a/src/Streamly/Coreutils/Id.hs +++ b/src/Coreutils/Id.hs @@ -1,6 +1,6 @@ {-# OPTIONS_GHC -Wno-missing-signatures #-} -- | --- Module : Streamly.Coreutils.Id +-- Module : Coreutils.Id -- Copyright : (c) 2022 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -12,7 +12,7 @@ -- Provides the read-only functionality of the @id@, @whoami@, and @logname@ -- coreutils commands, intended for programmatic use. -module Streamly.Coreutils.Id +module Coreutils.Id ( -- * Options -- | Start from 'defaultConfig' (effective user) and compose modifiers. @@ -76,7 +76,7 @@ import qualified System.Posix.User as Posix -- an arbitrary named user (i.e. @id \@) is a separate concern -- that requires reading the user/group database (@/etc/passwd@, -- @/etc/group@, NSS, etc.). That functionality will live in a separate --- module (e.g. @Streamly.Coreutils.UserDB@) and is not implemented here. +-- module (e.g. @Coreutils.UserDB@) and is not implemented here. -- -- * __Scope: read-only.__ Setting the uid/gid of the current process -- (@setuid@, @setgid@) is the domain of @sudo@-style utilities and has @@ -131,7 +131,7 @@ import qualified System.Posix.User as Posix ------------------------------------------------------------------------------ -- These functions are user/group-DB lookups. They logically belong in a --- future Streamly.Coreutils.UserDB module and will likely move there; a +-- future Coreutils.UserDB module and will likely move there; a -- re-export from here may be kept for backwards compatibility when that -- happens. diff --git a/src/Streamly/Coreutils/Ln.hs b/src/Coreutils/Ln.hs similarity index 91% rename from src/Streamly/Coreutils/Ln.hs rename to src/Coreutils/Ln.hs index d29a462d..851db26d 100644 --- a/src/Streamly/Coreutils/Ln.hs +++ b/src/Coreutils/Ln.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Ln +-- Module : Coreutils.Ln -- Copyright : (c) 2022 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- create a link to TARGET with the given name -module Streamly.Coreutils.Ln +module Coreutils.Ln ( ln -- * Options @@ -19,7 +19,7 @@ module Streamly.Coreutils.Ln where import Control.Monad (when) -import Streamly.Coreutils.FileTest (test, doesItExist) +import Coreutils.FileTest (test, doesItExist) import qualified System.PosixCompat.Files as Posix import Streamly.FileSystem.Path (Path) diff --git a/src/Streamly/Coreutils/Ls.hs b/src/Coreutils/Ls.hs similarity index 96% rename from src/Streamly/Coreutils/Ls.hs rename to src/Coreutils/Ls.hs index 52758583..2255975f 100644 --- a/src/Streamly/Coreutils/Ls.hs +++ b/src/Coreutils/Ls.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Ls +-- Module : Coreutils.Ls -- Copyright : (c) 2022 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- List directory contents. -module Streamly.Coreutils.Ls +module Coreutils.Ls ( ls diff --git a/src/Streamly/Coreutils/Mkdir.hs b/src/Coreutils/Mkdir.hs similarity index 97% rename from src/Streamly/Coreutils/Mkdir.hs rename to src/Coreutils/Mkdir.hs index 1764d536..01364f7c 100644 --- a/src/Streamly/Coreutils/Mkdir.hs +++ b/src/Coreutils/Mkdir.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Mkdir +-- Module : Coreutils.Mkdir -- Copyright : (c) 2022 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -18,7 +18,7 @@ -- create the directories when doctest is run which is an unexpected side -- effect. We can do that in CIs though. -- -module Streamly.Coreutils.Mkdir +module Coreutils.Mkdir ( mkdir diff --git a/src/Streamly/Coreutils/Mv.hs b/src/Coreutils/Mv.hs similarity index 94% rename from src/Streamly/Coreutils/Mv.hs rename to src/Coreutils/Mv.hs index 7b3166f6..a12743c2 100644 --- a/src/Streamly/Coreutils/Mv.hs +++ b/src/Coreutils/Mv.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Mv +-- Module : Coreutils.Mv -- Copyright : (c) 2022 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Rename source to dest, or move source(s) to directory. -module Streamly.Coreutils.Mv +module Coreutils.Mv ( mv diff --git a/src/Streamly/Coreutils/ReadLink.hs b/src/Coreutils/ReadLink.hs similarity index 87% rename from src/Streamly/Coreutils/ReadLink.hs rename to src/Coreutils/ReadLink.hs index baa74265..b5a8c3c1 100644 --- a/src/Streamly/Coreutils/ReadLink.hs +++ b/src/Coreutils/ReadLink.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.ReadLink +-- Module : Coreutils.ReadLink -- Copyright : (c) 2022 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Returns resolved symbolic link target. -module Streamly.Coreutils.ReadLink +module Coreutils.ReadLink (readLink) where diff --git a/src/Streamly/Coreutils/ResolvePath.hs b/src/Coreutils/ResolvePath.hs similarity index 99% rename from src/Streamly/Coreutils/ResolvePath.hs rename to src/Coreutils/ResolvePath.hs index d5bf594f..6bb18bec 100644 --- a/src/Streamly/Coreutils/ResolvePath.hs +++ b/src/Coreutils/ResolvePath.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.ResolvePath +-- Module : Coreutils.ResolvePath -- Copyright : (c) 2022 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -77,7 +77,7 @@ -- via @..@: @\/link\/..@ lexically resolves to @\/@, but physically -- resolves to the parent of the symlink's target. -module Streamly.Coreutils.ResolvePath +module Coreutils.ResolvePath ( ResolvePathOptions , ExistenceCheck (..) , ResolutionMode (..) diff --git a/src/Streamly/Coreutils/Rm.hs b/src/Coreutils/Rm.hs similarity index 98% rename from src/Streamly/Coreutils/Rm.hs rename to src/Coreutils/Rm.hs index 8d663011..6d0d0a0d 100644 --- a/src/Streamly/Coreutils/Rm.hs +++ b/src/Coreutils/Rm.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Rm +-- Module : Coreutils.Rm -- Copyright : (c) 2022 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -69,7 +69,7 @@ -- TODO: replace the error calls with exceptions -module Streamly.Coreutils.Rm +module Coreutils.Rm ( rm , rmContents @@ -85,10 +85,10 @@ module Streamly.Coreutils.Rm where import Control.Monad (forM_, when) -import Streamly.Coreutils.FileTest +import Coreutils.FileTest (doesItExist, test, testl, isDir, isWritableByMode) #if defined(CABAL_OS_WINDOWS) -import Streamly.Coreutils.FileTest.Windows (isDirSymLink) +import Coreutils.FileTest.Windows (isDirSymLink) #endif import System.Directory ( getPermissions diff --git a/src/Streamly/Coreutils/Sh.hs b/src/Coreutils/Sh.hs similarity index 98% rename from src/Streamly/Coreutils/Sh.hs rename to src/Coreutils/Sh.hs index e1b79673..b0381b2e 100644 --- a/src/Streamly/Coreutils/Sh.hs +++ b/src/Coreutils/Sh.hs @@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ConstraintKinds #-} -- | --- Module : Streamly.Coreutils.Sh +-- Module : Coreutils.Sh -- Copyright : (c) 2021 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -29,7 +29,7 @@ -- This example demonstrates piping the output of @echo@ shell command into -- the @tr@ command, using Streamly's streaming abstractions. -- -module Streamly.Coreutils.Sh +module Coreutils.Sh ( -- * Generation toBytes @@ -73,7 +73,7 @@ import qualified Streamly.Internal.System.Process as Process -- >>> import qualified Streamly.Data.Fold as Fold -- >>> import qualified Streamly.Data.Stream as Stream -- >>> import qualified Streamly.Internal.System.Process as Process --- >>> import qualified Streamly.Coreutils.Sh as Sh +-- >>> import qualified Coreutils.Sh as Sh -- >>> import qualified Streamly.Unicode.Stream as Unicode -- | A modifier for stream generation APIs in "Streamly.System.Process" to diff --git a/src/Streamly/Coreutils/Sleep.hs b/src/Coreutils/Sleep.hs similarity index 81% rename from src/Streamly/Coreutils/Sleep.hs rename to src/Coreutils/Sleep.hs index 6d100820..5f860721 100644 --- a/src/Streamly/Coreutils/Sleep.hs +++ b/src/Coreutils/Sleep.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Sleep +-- Module : Coreutils.Sleep -- Copyright : (c) 2022 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Delay for a number of seconds. -module Streamly.Coreutils.Sleep +module Coreutils.Sleep (sleep) where diff --git a/src/Streamly/Coreutils/Stat.hs b/src/Coreutils/Stat.hs similarity index 93% rename from src/Streamly/Coreutils/Stat.hs rename to src/Coreutils/Stat.hs index 338f4b59..2eb81e26 100644 --- a/src/Streamly/Coreutils/Stat.hs +++ b/src/Coreutils/Stat.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Stat +-- Module : Coreutils.Stat -- Copyright : (c) 2022 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -11,7 +11,7 @@ -- XXX Reexport the required Posix types? -module Streamly.Coreutils.Stat +module Coreutils.Stat ( stat diff --git a/src/Streamly/Coreutils/String.hs b/src/Coreutils/String.hs similarity index 88% rename from src/Streamly/Coreutils/String.hs rename to src/Coreutils/String.hs index 5b61fcff..00c07a58 100644 --- a/src/Streamly/Coreutils/String.hs +++ b/src/Coreutils/String.hs @@ -1,12 +1,12 @@ -- | --- Module : Streamly.Coreutils.String +-- Module : Coreutils.String -- Copyright : (c) 2022 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com -- Stability : experimental -- Portability : GHC -- -module Streamly.Coreutils.String +module Coreutils.String ( deIndent ) diff --git a/src/Streamly/Coreutils/Tail.hs b/src/Coreutils/Tail.hs similarity index 98% rename from src/Streamly/Coreutils/Tail.hs rename to src/Coreutils/Tail.hs index c9c74385..f89c3a6d 100644 --- a/src/Streamly/Coreutils/Tail.hs +++ b/src/Coreutils/Tail.hs @@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -- | --- Module : Streamly.Coreutils.Tail +-- Module : Coreutils.Tail -- Copyright : (c) 2025 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -12,7 +12,7 @@ -- TODO: we can add a tail1 or last to read the last line. -- TODO: tail/head can be replaced with a single file reading utility which can -- read lines or bytes in a range. -module Streamly.Coreutils.Tail +module Coreutils.Tail ( tail diff --git a/src/Streamly/Coreutils/Touch.hs b/src/Coreutils/Touch.hs similarity index 94% rename from src/Streamly/Coreutils/Touch.hs rename to src/Coreutils/Touch.hs index 7bcf3fdb..4187999f 100644 --- a/src/Streamly/Coreutils/Touch.hs +++ b/src/Coreutils/Touch.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Touch +-- Module : Coreutils.Touch -- Copyright : (c) 2022 Composewell Technologies -- License : BSD-3-Clause -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Update the access and modification times of a file to the current time. -module Streamly.Coreutils.Touch +module Coreutils.Touch ( touch @@ -20,7 +20,7 @@ module Streamly.Coreutils.Touch where import Control.Monad (unless) -import Streamly.Coreutils.FileTest (test, doesItExist) +import Coreutils.FileTest (test, doesItExist) import System.IO (openFile, IOMode(WriteMode), hClose) import Streamly.FileSystem.Path (Path) import qualified Streamly.FileSystem.Path as Path diff --git a/src/Streamly/Coreutils/Uniq.hs b/src/Coreutils/Uniq.hs similarity index 99% rename from src/Streamly/Coreutils/Uniq.hs rename to src/Coreutils/Uniq.hs index cf608804..5f77d1ae 100644 --- a/src/Streamly/Coreutils/Uniq.hs +++ b/src/Coreutils/Uniq.hs @@ -1,4 +1,4 @@ -module Streamly.Coreutils.Uniq +module Coreutils.Uniq ( Output(..) , UniqResult(..) , UniqOptions(..) diff --git a/src/Streamly/Coreutils/Which.hs b/src/Coreutils/Which.hs similarity index 91% rename from src/Streamly/Coreutils/Which.hs rename to src/Coreutils/Which.hs index 15985421..003dab6c 100644 --- a/src/Streamly/Coreutils/Which.hs +++ b/src/Coreutils/Which.hs @@ -1,5 +1,5 @@ -- | --- Module : Streamly.Coreutils.Which +-- Module : Coreutils.Which -- Copyright : (c) 2022 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com @@ -8,7 +8,7 @@ -- -- Find an executable in a given search PATH. -module Streamly.Coreutils.Which +module Coreutils.Which ( which , whichAll diff --git a/src/Streamly/Coreutils.hs b/src/Streamly/Coreutils.hs deleted file mode 100644 index b7d730e1..00000000 --- a/src/Streamly/Coreutils.hs +++ /dev/null @@ -1,16 +0,0 @@ --- | --- Module : Streamly.Coreutils --- Copyright : (c) 2020 Composewell Technologies --- License : Apache-2.0 --- Maintainer : streamly@composewell.com --- Stability : experimental --- Portability : GHC --- -module Streamly.Coreutils - ( module Streamly.Coreutils.Cp - , module Streamly.Coreutils.FileTest - ) -where - -import Streamly.Coreutils.Cp -import Streamly.Coreutils.FileTest diff --git a/streamly-coreutils.cabal b/streamly-coreutils.cabal index 9c50e507..9203696b 100644 --- a/streamly-coreutils.cabal +++ b/streamly-coreutils.cabal @@ -33,8 +33,7 @@ extra-doc-files: CHANGELOG.md , README.md , NOTICE - , design/proposal.md - , design/design-notes.md + , design/*.md source-repository head type: git @@ -168,39 +167,39 @@ library hs-source-dirs: src exposed-modules: - Streamly.Coreutils - , Streamly.Coreutils.Chmod - , Streamly.Coreutils.Common - , Streamly.Coreutils.Cp - , Streamly.Coreutils.Cut - , Streamly.Coreutils.Directory - , Streamly.Coreutils.Dirname - , Streamly.Coreutils.FileTest - , Streamly.Coreutils.Find - , Streamly.Coreutils.Ln - , Streamly.Coreutils.Ls - , Streamly.Coreutils.Mkdir - , Streamly.Coreutils.Mv - , Streamly.Coreutils.ReadLink - , Streamly.Coreutils.ResolvePath - , Streamly.Coreutils.Rm - , Streamly.Coreutils.Sh - , Streamly.Coreutils.Sleep - , Streamly.Coreutils.Stat - , Streamly.Coreutils.Tail - , Streamly.Coreutils.Touch - , Streamly.Coreutils.Which + Coreutils.Chmod + , Coreutils.Cp + , Coreutils.Cut + , Coreutils.Directory + , Coreutils.Dirname + , Coreutils.FileTest + , Coreutils.Find + , Coreutils.Ln + , Coreutils.Ls + , Coreutils.Mkdir + , Coreutils.Mv + , Coreutils.ReadLink + , Coreutils.ResolvePath + , Coreutils.Rm + , Coreutils.Sh + , Coreutils.Sleep + , Coreutils.Stat + , Coreutils.Tail + , Coreutils.Touch + , Coreutils.Which if os(windows) exposed-modules: - Streamly.Coreutils.FileTest.Windows + Coreutils.FileTest.Windows else exposed-modules: - Streamly.Coreutils.FileTest.Posix - , Streamly.Coreutils.Id + Coreutils.FileTest.Posix + , Coreutils.Id other-modules: - Streamly.Coreutils.FileTest.Common - , Streamly.Coreutils.String - , Streamly.Coreutils.Uniq + Coreutils + , Coreutils.Common + , Coreutils.FileTest.Common + , Coreutils.String + , Coreutils.Uniq default-language: Haskell2010 @@ -231,7 +230,7 @@ executable hfd -- Test suites ------------------------------------------------------------------------------- -test-suite Streamly.Coreutils.Rm +test-suite Coreutils.Rm import: compile-options type: exitcode-stdio-1.0 main-is: Streamly/Test/Coreutils/Rm.hs diff --git a/test/Main.hs b/test/Main.hs index a1cde83e..9e42f235 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -5,7 +5,7 @@ where import qualified Streamly.Data.Stream as S import qualified Streamly.Data.Fold as FL -import Streamly.Coreutils.Uniq +import Coreutils.Uniq import Control.Monad.IO.Class (MonadIO) import Streamly.Data.Stream (Stream) diff --git a/test/Streamly/Test/Coreutils/Rm.hs b/test/Streamly/Test/Coreutils/Rm.hs index 7f8853b6..f5ca85de 100644 --- a/test/Streamly/Test/Coreutils/Rm.hs +++ b/test/Streamly/Test/Coreutils/Rm.hs @@ -8,7 +8,7 @@ -- Stability : experimental -- Portability : GHC -- --- Tests for 'Streamly.Coreutils.Rm'. Behavior mirrors GNU @rm@ unless noted +-- Tests for 'Coreutils.Rm'. Behavior mirrors GNU @rm@ unless noted -- otherwise in the module documentation. -- -- = Test Structure @@ -64,8 +64,8 @@ import System.Posix.User (getRealUserID) import System.Posix.Types (FileMode) import Test.Hspec -import Streamly.Coreutils.Rm hiding (rm) -import qualified Streamly.Coreutils.Rm as Rm +import Coreutils.Rm hiding (rm) +import qualified Coreutils.Rm as Rm import qualified Streamly.FileSystem.Path as Path -------------------------------------------------------------------------------