Skip to content

Commit 47c91ec

Browse files
committed
Improve readability of numbers in traces and errors
Use stock derived show for newtypes RunNumber, TableId and CursorId, rather than newtype derived. This means they get rendered as "RunNumber 3" rather than 3. This makes traces easier to read. It also means when things are shown in errors or ghci output, the result can be pasted back in again as valid syntax. Carefully checked that show was not being used for anything other than derived show for other types, so we don't change the rendering of anything important. Did this by temporarily removing the show instance entirely and looking for build errors. Fixed two such cases in file path rendering.
1 parent 9607654 commit 47c91ec

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Database/LSMTree/Internal/Paths.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ runChecksumsPath :: RunFsPaths -> FsPath
209209
runChecksumsPath = flip runFilePathWithExt "checksums"
210210

211211
runFilePathWithExt :: RunFsPaths -> String -> FsPath
212-
runFilePathWithExt (RunFsPaths dir n) ext =
212+
runFilePathWithExt (RunFsPaths dir (RunNumber n)) ext =
213213
dir </> mkFsPath [show n] <.> ext
214214

215215
runFileExts :: ForRunFiles String
@@ -311,7 +311,7 @@ writeBufferChecksumsPath :: WriteBufferFsPaths -> FsPath
311311
writeBufferChecksumsPath = flip writeBufferFilePathWithExt "checksums"
312312

313313
writeBufferFilePathWithExt :: WriteBufferFsPaths -> String -> FsPath
314-
writeBufferFilePathWithExt (WriteBufferFsPaths dir n) ext =
314+
writeBufferFilePathWithExt (WriteBufferFsPaths dir (RunNumber n)) ext =
315315
dir </> mkFsPath [show n] <.> ext
316316

317317

src/Database/LSMTree/Internal/RunNumber.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ module Database.LSMTree.Internal.RunNumber (
77
import Control.DeepSeq (NFData)
88

99
newtype RunNumber = RunNumber Int
10-
deriving newtype (Eq, Ord, Show, NFData)
10+
deriving stock (Eq, Ord, Show)
11+
deriving newtype (NFData)
1112

1213
newtype TableId = TableId Int
13-
deriving newtype (Eq, Ord, Show, NFData)
14+
deriving stock (Eq, Ord, Show)
15+
deriving newtype (NFData)
1416

1517
newtype CursorId = CursorId Int
16-
deriving newtype (Eq, Ord, Show, NFData)
18+
deriving stock (Eq, Ord, Show)
19+
deriving newtype (NFData)

0 commit comments

Comments
 (0)