Skip to content

Commit dc0ddaf

Browse files
committed
Make SnapshotLabel a newtype
1 parent 31983c6 commit dc0ddaf

File tree

9 files changed

+23
-8
lines changed

9 files changed

+23
-8
lines changed

lsm-tree.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ library
179179
, lsm-tree:kmerge
180180
, lsm-tree:monkey
181181
, primitive ^>=0.9
182+
, text ^>=2.1.1
182183
, vector ^>=0.13
183184
, vector-algorithms ^>=0.9
184185

src/Database/LSMTree/Internal.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,12 +1077,10 @@ readCursorWhile resolve keyIsWanted n Cursor {..} fromEntry = do
10771077
Snapshots
10781078
-------------------------------------------------------------------------------}
10791079

1080-
type SnapshotLabel = String
1081-
10821080
{-# SPECIALISE snapshot ::
10831081
ResolveSerialisedValue
10841082
-> SnapshotName
1085-
-> String
1083+
-> SnapshotLabel
10861084
-> Table IO h
10871085
-> IO Int #-}
10881086
-- | See 'Database.LSMTree.Normal.snapshot''.

src/Database/LSMTree/Internal/Snapshot.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
{-# OPTIONS_GHC -Wno-orphans #-}
33

44
module Database.LSMTree.Internal.Snapshot (
5+
SnapshotLabel (..)
56
-- * Snapshot format
6-
numSnapRuns
7+
, numSnapRuns
78
, SnapLevels
89
, SnapLevel (..)
910
, SnapMergingRun (..)
@@ -23,6 +24,8 @@ import Control.Monad.Primitive (PrimMonad)
2324
import Control.TempRegistry
2425
import Data.Foldable (forM_)
2526
import Data.Primitive.PrimVar
27+
import Data.String
28+
import Data.Text (Text)
2629
import qualified Data.Vector as V
2730
import Database.LSMTree.Internal.Config
2831
import Database.LSMTree.Internal.Entry
@@ -39,6 +42,11 @@ import Database.LSMTree.Internal.UniqCounter (UniqCounter,
3942
import System.FS.API (HasFS)
4043
import System.FS.BlockIO.API (HasBlockIO)
4144

45+
-- | Custom text to include in a snapshot file
46+
newtype SnapshotLabel = SnapshotLabel Text
47+
deriving stock (Show, Eq, Read)
48+
deriving newtype (Semigroup, IsString)
49+
4250
{-------------------------------------------------------------------------------
4351
Levels snapshot format
4452
-------------------------------------------------------------------------------}

src/Database/LSMTree/Monoidal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
13
-- TODO: remove once the API is implemented.
24
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
35

src/Database/LSMTree/Normal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
13
-- TODO: remove once the API is implemented.
24
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
35

test/Test/Database/LSMTree/Class/Monoidal.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{-# LANGUAGE BlockArguments #-}
1+
{-# LANGUAGE BlockArguments #-}
2+
{-# LANGUAGE OverloadedStrings #-}
23

34
module Test.Database.LSMTree.Class.Monoidal (tests) where
45

test/Test/Database/LSMTree/Class/Normal.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{-# LANGUAGE BlockArguments #-}
1+
{-# LANGUAGE BlockArguments #-}
2+
{-# LANGUAGE OverloadedStrings #-}
23

34
module Test.Database.LSMTree.Class.Normal (
45
tests

test/Test/Database/LSMTree/Internal.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
{-# LANGUAGE LambdaCase #-}
2-
{-# LANGUAGE RecordWildCards #-}
1+
{-# LANGUAGE LambdaCase #-}
2+
{-# LANGUAGE OverloadedStrings #-}
3+
{-# LANGUAGE RecordWildCards #-}
34

45
{- HLINT ignore "Use <=<" -}
56

test/Test/Database/LSMTree/Normal/StateMachine.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{-# LANGUAGE LambdaCase #-}
1111
{-# LANGUAGE MultiParamTypeClasses #-}
1212
{-# LANGUAGE NamedFieldPuns #-}
13+
{-# LANGUAGE OverloadedStrings #-}
1314
{-# LANGUAGE QuantifiedConstraints #-}
1415
{-# LANGUAGE RankNTypes #-}
1516
{-# LANGUAGE ScopedTypeVariables #-}

0 commit comments

Comments
 (0)