Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead code #5392

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions codebase2/codebase-sqlite/U/Codebase/Causal/Squash.hs

This file was deleted.

8 changes: 0 additions & 8 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/Branch/Format.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module U.Codebase.Sqlite.Branch.Format
( BranchFormat' (..),
BranchFormat,
HashBranchFormat,
BranchLocalIds,
BranchLocalIds' (..),
HashBranchLocalIds,
Expand Down Expand Up @@ -49,13 +48,6 @@ data
-- | The 'BranchFormat'' used to store a branch in Sqlite
type BranchFormat = BranchFormat' TextId ObjectId PatchObjectId (BranchObjectId, CausalHashId) BranchObjectId

-- | A BranchFormat which uses Hashes and Text for all its references, no
-- Ids which are specific to a particular codebase.
type HashBranchFormat = BranchFormat' Text ComponentHash PatchHash (BranchHash, CausalHash)

-- = Full BranchLocalIds LocalBranch
-- \| Diff BranchObjectId BranchLocalIds LocalDiff

-- | A 'BranchLocalIds' is a mapping between local ids (local to this object) encoded as offsets, and actual database ids.
--
-- For example, a @branchTextLookup@ vector of @[50, 74]@ means "local id 0 corresponds to database text id 50, and
Expand Down
20 changes: 0 additions & 20 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/Branch/Full.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ patches_ f Branch {..} = (\newPatches -> Branch terms types newPatches children)
childrenHashes_ :: Traversal (Branch' t h p c) (Branch' t h p c') c c'
childrenHashes_ f Branch {..} = Branch terms types patches <$> traverse f children

branchCausalHashes_ :: Traversal (Branch' t h p c) (Branch' t h p c') c c'
branchCausalHashes_ f Branch {..} =
Branch terms types patches <$> traverse f children

type LocalMetadataSet = MetadataSetFormat' LocalTextId LocalDefnId

type DbMetadataSet = MetadataSetFormat' TextId ObjectId
Expand Down Expand Up @@ -105,19 +101,3 @@ quadmapM ft fh fp fc (Branch terms types patches children) =
doTerms = Map.bitraverse (bitraverse (bitraverse ft fh) (bitraverse ft fh)) doMetadata
doTypes = Map.bitraverse (bitraverse ft fh) doMetadata
doMetadata (Inline s) = Inline <$> Set.traverse (bitraverse ft fh) s

-- | Traversal over text references in a branch
t_ :: (Ord t', Ord h) => Traversal (Branch' t h p c) (Branch' t' h p c) t t'
t_ f = quadmapM f pure pure pure

-- | Traversal over hash references in a branch
h_ :: (Ord t, Ord h') => Traversal (Branch' t h p c) (Branch' t h' p c) h h'
h_ f = quadmapM pure f pure pure

-- | Traversal over patch references in a branch
p_ :: (Ord t, Ord h) => Traversal (Branch' t h p c) (Branch' t h p' c) p p'
p_ f = quadmapM pure pure f pure

-- | Traversal over child references in a branch
c_ :: (Ord t, Ord h) => Traversal (Branch' t h p c) (Branch' t h p c') c c'
c_ f = quadmapM pure pure pure f
5 changes: 1 addition & 4 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/Causal.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module U.Codebase.Sqlite.Causal
( DbCausal,
GDbCausal (..),
( GDbCausal (..),
SyncCausalFormat,
SyncCausalFormat' (..),
)
Expand All @@ -16,8 +15,6 @@ data GDbCausal causalHash valueHash = DbCausal
parents :: Set causalHash
}

type DbCausal = GDbCausal CausalHashId BranchHashId

data SyncCausalFormat' causalHash valueHash = SyncCausalFormat
{ valueHash :: valueHash,
parents :: Vector causalHash
Expand Down
8 changes: 4 additions & 4 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/DbId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Unison.Sqlite (FromField, ToField)

newtype HashVersion = HashVersion Word64
deriving stock (Eq, Ord, Show)
deriving (Num, Real, Enum, Integral, Bits, FromField, ToField) via Word64
deriving (Num, ToField) via Word64

newtype ObjectId = ObjectId Word64
deriving (Eq, Ord, Show)
Expand All @@ -25,15 +25,15 @@ newtype HashId = HashId Word64

newtype PatchObjectId = PatchObjectId {unPatchObjectId :: ObjectId}
deriving (Eq, Ord)
deriving (Num, Real, Enum, Integral, Bits, FromField, ToField) via ObjectId
deriving (Num, Real, Enum, Integral, Bits) via ObjectId

newtype BranchObjectId = BranchObjectId {unBranchObjectId :: ObjectId}
deriving (Eq, Ord)
deriving (Num, Real, Enum, Integral, Bits, FromField, ToField) via ObjectId

newtype BranchHashId = BranchHashId {unBranchHashId :: HashId}
deriving (Eq, Ord)
deriving (Num, Real, Enum, Integral, Bits, FromField, ToField) via HashId
deriving (FromField, ToField) via HashId

newtype CausalHashId = CausalHashId {unCausalHashId :: HashId}
deriving (Eq, Ord)
Expand All @@ -53,7 +53,7 @@ newtype RemoteProjectId = RemoteProjectId {unRemoteProjectId :: Text}

newtype SchemaVersion = SchemaVersion Word64
deriving (Eq, Ord, Show)
deriving (Num, Real, Enum, Integral, Bits, FromField, ToField) via Word64
deriving (Num, Real, Enum, Integral, FromField, ToField) via Word64

instance Show PatchObjectId where
show h = "PatchObjectId (" ++ show (unPatchObjectId h) ++ ")"
Expand Down
8 changes: 0 additions & 8 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/Decode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module U.Codebase.Sqlite.Decode
decodeSyncTermAndType,
decodeTermElementDiscardingTerm,
decodeTermElementDiscardingType,
decodeTermElementWithType,
decodeTermFormat,

-- * @temp_entity.blob@
Expand Down Expand Up @@ -133,13 +132,6 @@ decodeTermElementDiscardingType :: C.Reference.Pos -> ByteString -> Either Decod
decodeTermElementDiscardingType i =
getFromBytesOr ("lookupTermElementDiscardingType " <> tShow i) (Serialization.lookupTermElementDiscardingType i)

decodeTermElementWithType ::
C.Reference.Pos ->
ByteString ->
Either DecodeError (LocalIds, TermFormat.Term, TermFormat.Type)
decodeTermElementWithType i =
getFromBytesOr ("lookupTermElement" <> tShow i) (Serialization.lookupTermElement i)

------------------------------------------------------------------------------------------------------------------------
-- temp_entity.blob

Expand Down
9 changes: 0 additions & 9 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/LocalIds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ newtype LocalPatchObjectId = LocalPatchObjectId Word64 deriving (Eq, Ord, Show,

newtype LocalBranchChildId = LocalBranchChildId Word64 deriving (Eq, Ord, Show, Num, Real, Enum, Integral, Bits) via Word64

-- | causal hashes are treated differently from HashIds, which don't have dependencies
newtype LocalCausalHashId = LocalCausalHashId Word64 deriving (Eq, Ord, Show, Num, Real, Enum, Integral, Bits) via Word64

instance Bitraversable LocalIds' where
bitraverse f g (LocalIds t d) = LocalIds <$> traverse f t <*> traverse g d

Expand All @@ -48,9 +45,3 @@ instance Bifoldable LocalIds' where

instance Bifunctor LocalIds' where
bimap f g (LocalIds t d) = LocalIds (f <$> t) (g <$> d)

t_ :: Traversal (LocalIds' t h) (LocalIds' t' h) t t'
t_ f (LocalIds t d) = LocalIds <$> traverse f t <*> pure d

h_ :: Traversal (LocalIds' t h) (LocalIds' t h') h h'
h_ f (LocalIds t d) = LocalIds <$> pure t <*> traverse f d
26 changes: 0 additions & 26 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/NameLookups.hs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should either tear out this module and all its dependencies entirely, or just leave the whole thing alone; picking it apart is probably just going to make it much more difficult to restore if we decide to use it later (and I still suspect that some day we'll want to use this). I.e. if we remove the whole thing we can just find the last time the files existed and restore those, but if we gut them bit by bit it's going to be hard to tell where in history they were properly intact.

The entire module is actually unused, but weeder won't pick up on that because I think it's just gated behind some conditional that's currently always false.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
-- access to those domain types given the package dependency tree.
module U.Codebase.Sqlite.NameLookups
( ReversedName (..),
ReversedPath (..),
PathSegments (..),
NamespaceText,
reversedNameToNamespaceText,
reversedNameToPathSegments,
pathSegmentsToText,
textToPathSegments,
)
Expand All @@ -20,20 +16,11 @@ import Unison.Prelude
newtype ReversedName = ReversedName (NonEmpty Text)
deriving stock (Eq, Ord, Show)

instance From ReversedName (NonEmpty Text)

instance From (NonEmpty Text) ReversedName

instance From ReversedName [Text] where
from (ReversedName n) = toList n

newtype ReversedPath = ReversedPath [Text]
deriving (Eq, Ord, Show)

instance From ReversedPath [Text]

instance From [Text] ReversedPath

newtype PathSegments = PathSegments [Text]
deriving stock (Eq, Ord, Show)
deriving newtype (Semigroup, Monoid)
Expand All @@ -42,10 +29,6 @@ instance From PathSegments [Text]

instance From [Text] PathSegments

-- | A namespace rendered as a path, no leading '.'
-- E.g. "base.data"
type NamespaceText = Text

-- |
-- >>> pathSegmentsToText (PathSegments ["base", "data", "List"])
-- "base.data.List"
Expand All @@ -57,12 +40,3 @@ pathSegmentsToText (PathSegments txt) = Text.intercalate "." txt
-- PathSegments ["base","data","List"]
textToPathSegments :: Text -> PathSegments
textToPathSegments txt = PathSegments $ Text.splitOn "." txt

-- |
-- >>> reversedSegmentsToNamespaceText (["List", "data", "base"])
-- "base.data.List"
reversedNameToNamespaceText :: ReversedName -> NamespaceText
reversedNameToNamespaceText (ReversedName txt) = Text.intercalate "." . reverse . toList $ txt

reversedNameToPathSegments :: ReversedName -> PathSegments
reversedNameToPathSegments (ReversedName revName) = PathSegments . reverse . toList $ revName
34 changes: 0 additions & 34 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/NamedRef.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module U.Codebase.Sqlite.NamedRef where

import Data.List.NonEmpty qualified as NEL
import Data.List.NonEmpty qualified as NonEmpty
import Data.Text qualified as Text
import U.Codebase.Sqlite.NameLookups (ReversedName)
Expand All @@ -11,11 +10,6 @@ data ConstructorType
= DataConstructor
| EffectConstructor

instance ToField (ConstructorType) where
toField ct = case ct of
DataConstructor -> (SQLInteger 0)
EffectConstructor -> (SQLInteger 1)

instance FromField (ConstructorType) where
fromField f =
fromField @Int f >>= \case
Expand All @@ -26,16 +20,6 @@ instance FromField (ConstructorType) where
data NamedRef ref = NamedRef {reversedSegments :: ReversedName, ref :: ref}
deriving stock (Show, Functor, Foldable, Traversable)

instance (ToRow ref) => ToRow (NamedRef ref) where
toRow (NamedRef {reversedSegments = segments, ref}) =
[toField reversedName] <> toRow ref
where
reversedName =
segments
& into @[Text]
& Text.intercalate "."
& (<> ".") -- Add trailing dot, see notes on scoped_term_name_lookup schema

instance (FromRow ref) => FromRow (NamedRef ref) where
fromRow = do
reversedSegments <-
Expand All @@ -47,21 +31,3 @@ instance (FromRow ref) => FromRow (NamedRef ref) where
& into @ReversedName
ref <- fromRow
pure (NamedRef {reversedSegments, ref})

-- | The new 'scoped' name lookup format is different from the old version.
--
-- Specifically, the scoped format adds the 'lastNameSegment' as well as adding a trailing '.' to the db format
-- of both the namespace and reversed_name.
--
-- This type has a ToRow instance of the form:
-- [reversedName, namespace, lastNameSegment] <> ref fields...
newtype ScopedRow ref
= ScopedRow (NamedRef ref)

instance (ToRow ref) => ToRow (ScopedRow ref) where
toRow (ScopedRow (NamedRef {reversedSegments = revSegments, ref})) =
SQLText reversedName : SQLText namespace : SQLText lastNameSegment : toRow ref
where
reversedName = (Text.intercalate "." . into @[Text] $ revSegments) <> "."
namespace = (Text.intercalate "." . reverse . NEL.tail . from $ revSegments) <> "."
lastNameSegment = NEL.head . from $ revSegments
Loading
Loading