Skip to content

Commit cc43f6c

Browse files
Change the option naming to follow the convention
1 parent 84e6baa commit cc43f6c

6 files changed

Lines changed: 42 additions & 42 deletions

File tree

src/Streamly/Coreutils/Ln.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Streamly.Coreutils.Ln
1212
( ln
1313

1414
-- * Options
15-
, Ln
15+
, LnOptions
1616
, force
1717
, symbolic
1818
)
@@ -25,21 +25,21 @@ import qualified System.PosixCompat.Files as Posix
2525
import Streamly.FileSystem.Path (Path)
2626
import qualified Streamly.FileSystem.Path as Path
2727

28-
data Ln = Ln
28+
data LnOptions = LnOptions
2929
{ lnForce :: Bool
3030
, lnSymbolic :: Bool
3131
}
3232

33-
defaultConfig :: Ln
34-
defaultConfig = Ln False False
33+
defaultConfig :: LnOptions
34+
defaultConfig = LnOptions False False
3535

36-
force :: Bool -> Ln -> Ln
36+
force :: Bool -> LnOptions -> LnOptions
3737
force opt cfg = cfg {lnForce = opt}
3838

39-
symbolic :: Bool -> Ln -> Ln
39+
symbolic :: Bool -> LnOptions -> LnOptions
4040
symbolic opt cfg = cfg {lnSymbolic = opt}
4141

42-
ln :: (Ln -> Ln) -> Path -> Path -> IO ()
42+
ln :: (LnOptions -> LnOptions) -> Path -> Path -> IO ()
4343
ln f src tgt = do
4444
let opt = f defaultConfig
4545
when (lnForce opt == False) $ do

src/Streamly/Coreutils/Ls.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Streamly.Coreutils.Ls
1313
ls
1414

1515
-- * Options
16-
, Ls
16+
, LsOptions
1717
, recursive
1818
)
1919
where
@@ -33,15 +33,15 @@ import qualified Streamly.Internal.FileSystem.DirIO as Dir
3333
-- with newlines and short or long info in this API which are directly
3434
-- printable. In the "find" API we can return Path and structured Stat data
3535
-- instead for programmatic control.
36-
newtype Ls = Ls {lsRecursive :: Bool}
36+
newtype LsOptions = LsOptions {lsRecursive :: Bool}
3737

38-
defaultConfig :: Ls
39-
defaultConfig = Ls False
38+
defaultConfig :: LsOptions
39+
defaultConfig = LsOptions False
4040

41-
recursive :: Bool -> Ls -> Ls
41+
recursive :: Bool -> LsOptions -> LsOptions
4242
recursive opt cfg = cfg {lsRecursive = opt}
4343

44-
ls :: (Ls -> Ls) -> Path -> Stream IO (Either Path Path)
44+
ls :: (LsOptions -> LsOptions) -> Path -> Stream IO (Either Path Path)
4545
ls f dir = do
4646
case lsRecursive (f defaultConfig) of
4747
False -> Dir.readEitherPaths id dir

src/Streamly/Coreutils/Mv.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Streamly.Coreutils.Mv
1313
mv
1414

1515
-- * Options
16-
, Mv
16+
, MvOptions
1717
, force
1818
)
1919
where
@@ -23,15 +23,15 @@ import System.Directory (doesPathExist, renamePath)
2323
import Streamly.FileSystem.Path (Path)
2424
import qualified Streamly.FileSystem.Path as Path
2525

26-
newtype Mv = Mv {mvForce :: Bool}
26+
newtype MvOptions = MvOptions {mvForce :: Bool}
2727

28-
defaultConfig :: Mv
29-
defaultConfig = Mv False
28+
defaultConfig :: MvOptions
29+
defaultConfig = MvOptions False
3030

31-
force :: Bool -> Mv -> Mv
31+
force :: Bool -> MvOptions -> MvOptions
3232
force opt cfg = cfg {mvForce = opt}
3333

34-
mv :: (Mv -> Mv) -> Path -> Path -> IO ()
34+
mv :: (MvOptions -> MvOptions) -> Path -> Path -> IO ()
3535
mv f old new = do
3636
let opt = f defaultConfig
3737
oldStr = Path.toString old

src/Streamly/Coreutils/Stat.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Streamly.Coreutils.Stat
1616
stat
1717

1818
-- * Options
19-
, Stat
19+
, StatOptions
2020
, followLinks
2121
) where
2222

@@ -27,15 +27,15 @@ import Streamly.FileSystem.Path (Path)
2727
import qualified Streamly.FileSystem.Path as Path
2828
import qualified System.PosixCompat.Files as Files
2929

30-
newtype Stat = Stat {deRef :: Bool}
30+
newtype StatOptions = StatOptions {deRef :: Bool}
3131

32-
defaultConfig :: Stat
33-
defaultConfig = Stat True
32+
defaultConfig :: StatOptions
33+
defaultConfig = StatOptions True
3434

35-
followLinks :: Bool -> Stat -> Stat
35+
followLinks :: Bool -> StatOptions -> StatOptions
3636
followLinks opt cfg = cfg {deRef = opt}
3737

38-
stat :: (Stat -> Stat) -> Path -> IO FileStatus
38+
stat :: (StatOptions -> StatOptions) -> Path -> IO FileStatus
3939
stat f path = do
4040
let opt = f defaultConfig
4141
case deRef opt of

src/Streamly/Coreutils/Tail.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Streamly.Coreutils.Tail
1717
tail
1818

1919
-- * Options
20-
, Tail
20+
, TailOptions
2121
, follow
2222
, lines
2323
, bytes
@@ -38,14 +38,14 @@ import qualified Streamly.System.Command as Command
3838

3939
import Prelude hiding (tail, lines)
4040

41-
data Tail = Tail
41+
data TailOptions = TailOptions
4242
{ _follow :: Bool
4343
, _offset :: Either Int Int -- Left = lines, Right = bytes
4444
, _reverse :: Bool
4545
}
4646

47-
defaultConfig :: Tail
48-
defaultConfig = Tail
47+
defaultConfig :: TailOptions
48+
defaultConfig = TailOptions
4949
{ _follow = False
5050
, _offset = Left 10
5151
, _reverse = False -- False means default i.e. from the end
@@ -54,7 +54,7 @@ defaultConfig = Tail
5454
-- | Run forever following any appends to the file.
5555
--
5656
-- Same as @--follow@ flag in the standard tail command.
57-
follow :: Bool -> Tail -> Tail
57+
follow :: Bool -> TailOptions -> TailOptions
5858
follow opt cfg = cfg {_follow = opt}
5959

6060
-- Note we could have used negative offset to indicate from the end and
@@ -63,20 +63,20 @@ follow opt cfg = cfg {_follow = opt}
6363

6464
-- | Read the specified number of lines at the end of the file.
6565
--
66-
lines :: Int -> Tail -> Tail
66+
lines :: Int -> TailOptions -> TailOptions
6767
lines x cfg = cfg {_offset = Left x, _reverse = False}
6868

6969
-- | Read the specified number of bytes at the end of the file.
7070
--
71-
bytes :: Int -> Tail -> Tail
71+
bytes :: Int -> TailOptions -> TailOptions
7272
bytes x cfg = cfg {_offset = Right x, _reverse = False}
7373

7474
-- | Read from the specified line number up to the end of file.
75-
fromLine :: Int -> Tail -> Tail
75+
fromLine :: Int -> TailOptions -> TailOptions
7676
fromLine x cfg = cfg {_offset = Left x, _reverse = True}
7777

7878
-- | Read from the specified byte count up to the end of file.
79-
fromByte :: Int -> Tail -> Tail
79+
fromByte :: Int -> TailOptions -> TailOptions
8080
fromByte x cfg = cfg {_offset = Right x, _reverse = True}
8181

8282
-- XXX Replace the "tail" shell command with Haskell native implementation. A
@@ -92,7 +92,7 @@ fromByte x cfg = cfg {_offset = Right x, _reverse = True}
9292
--
9393
-- Note: currently this function depends on the @tail@ executable being
9494
-- installed in the PATH.
95-
tail :: (Tail -> Tail) -> Path -> Stream IO (Array Word8)
95+
tail :: (TailOptions -> TailOptions) -> Path -> Stream IO (Array Word8)
9696
tail modifier path =
9797
let p = Path.toString path
9898
cfg = modifier defaultConfig

src/Streamly/Coreutils/Touch.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Streamly.Coreutils.Touch
1313
touch
1414

1515
-- * Options
16-
, Touch
16+
, TouchOptions
1717
, create -- XXX rename for conflicts
1818
, followLinks -- XXX this is a common option in multiple commands
1919
)
@@ -30,21 +30,21 @@ import qualified System.Posix.Files as Posix (touchSymbolicLink)
3030
#endif
3131
import qualified System.PosixCompat.Files as Posix
3232

33-
data Touch = Touch
33+
data TouchOptions = TouchOptions
3434
{
3535
createNew :: Bool
3636
, deRef :: Bool -- touch the referenced file for symbolic link
3737
}
3838

39-
defaultConfig :: Touch
40-
defaultConfig = Touch True True
39+
defaultConfig :: TouchOptions
40+
defaultConfig = TouchOptions True True
4141

4242
-- | Default is 'True'.
43-
followLinks :: Bool -> Touch -> Touch
43+
followLinks :: Bool -> TouchOptions -> TouchOptions
4444
followLinks opt cfg = cfg {deRef = opt}
4545

4646
-- | Default is 'True'.
47-
create :: Bool -> Touch -> Touch
47+
create :: Bool -> TouchOptions -> TouchOptions
4848
create opt cfg = cfg {createNew = opt}
4949

5050
-- | If the file does not exist create it only if both followLinks and create
@@ -62,7 +62,7 @@ create opt cfg = cfg {createNew = opt}
6262
-- * create True
6363
-- * followLinks True
6464
--
65-
touch :: (Touch -> Touch) -> Path -> IO ()
65+
touch :: (TouchOptions -> TouchOptions) -> Path -> IO ()
6666
touch f path = do
6767
let opt = f defaultConfig
6868
pathStr = Path.toString path

0 commit comments

Comments
 (0)