- commit
- 75263fd
- parent
- 0e109fc
- author
- Evgenii Akentev
- date
- 2023-07-23 19:18:22 +0400 +04
Add proper description.
4 files changed,
+18,
-17
+2,
-2
1@@ -1,5 +1,5 @@
2-# Revision history for line-indexed-file-cursor
3+# Revision history for line-indexed-cursor
4
5-## 0.1.0.0 -- YYYY-mm-dd
6+## 0.1.0.0 -- 2023-08-23
7
8 * First version. Released on an unsuspecting world.
+2,
-1
1@@ -1,6 +1,8 @@
2 cabal-version: 3.0
3 name: line-indexed-cursor
4 version: 0.1.0.0
5+synopsis: Line-indexed file reader.
6+description: Lazily builds the index with the line numbers while reading the file making it possible to rewind to them quickly later.
7 license: MIT
8 license-file: LICENSE
9 author: Evgenii Akentev
10@@ -15,7 +17,6 @@ common warnings
11 -Wincomplete-record-updates -Wredundant-constraints -Widentities
12 -Wunused-packages -Wmissing-deriving-strategies
13
14-
15 library
16 import: warnings
17 exposed-modules: System.IO.LineIndexedCursor
+1,
-1
1@@ -21,7 +21,7 @@ module System.IO.LineIndexedCursor
2 import Data.Maybe (fromMaybe)
3 import qualified Data.Array as A
4 import Data.ByteString (ByteString, hGetLine)
5-import Control.Concurrent.MVar
6+import Control.Concurrent.MVar (MVar, newMVar, readMVar, modifyMVar, modifyMVar_)
7 import System.IO (Handle, hTell, hSeek, SeekMode(..), hIsEOF)
8
9 defaultListCapacity :: Integer
+13,
-13
1@@ -33,18 +33,6 @@ main = hspec $ do
2 l'' <- getCurrentLine c
3 l'' `shouldBe` Just "Pellentesque accumsan dolor at nisl pulvinar, ut bibendum diam egestas."
4
5- ln' <- goToLine c 3
6- ln' `shouldBe` 3
7-
8- ln'' <- goToLine c 2
9- ln'' `shouldBe` 2
10-
11- ln''' <- goToLine c 1
12- ln''' `shouldBe` 1
13-
14- ln'''' <- goToLine c 0
15- ln'''' `shouldBe` 0
16-
17 it "goToLine works" $ \(_, c) -> do
18 ln <- goToLine c 10
19 ln `shouldBe` 10
20@@ -84,7 +72,7 @@ main = hspec $ do
21 s <- getCursorState c
22 s `shouldBe` [0,57,117,191,244,316,384,429,511,561,616,668,715,761,799,851,907,941,981,1024,1068]
23
24- it "read line, then go to beginning and forth" $ \(_, c) -> do
25+ it "read line, then go to the beginning and forth" $ \(_, c) -> do
26 cln <- getCurrentLineNumber c
27 cln `shouldBe` 0
28
29@@ -126,3 +114,15 @@ main = hspec $ do
30
31 ln'''' <- goToLine c 10
32 ln'''' `shouldBe` 10
33+
34+ ln''''' <- goToLine c 3
35+ ln''''' `shouldBe` 3
36+
37+ ln'''''' <- goToLine c 2
38+ ln'''''' `shouldBe` 2
39+
40+ ln''''''' <- goToLine c 1
41+ ln''''''' `shouldBe` 1
42+
43+ ln'''''''' <- goToLine c 0
44+ ln'''''''' `shouldBe` 0