@@ -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
3939import 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
5858follow 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
6767lines 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
7272bytes 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
7676fromLine 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
8080fromByte 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 )
9696tail modifier path =
9797 let p = Path. toString path
9898 cfg = modifier defaultConfig
0 commit comments