module Unison.Codebase.SqliteCodebase.Migrations.MigrateSchema1To2.DbHelpers ( dbBranchHash, dbPatchHash, syncCausalHash, ) where import Data.Set qualified as Set import Data.Vector qualified as Vector import U.Codebase.HashTags (BranchHash (..), CausalHash (..), PatchHash (..)) import U.Codebase.Reference qualified as S hiding (Reference) import U.Codebase.Reference qualified as S.Reference import U.Codebase.Referent qualified as S.Referent import U.Codebase.Sqlite.Branch.Full (DbMetadataSet) import U.Codebase.Sqlite.Branch.Full qualified as S import U.Codebase.Sqlite.Branch.Full qualified as S.Branch.Full import U.Codebase.Sqlite.Branch.Full qualified as S.MetadataSet import U.Codebase.Sqlite.Causal qualified as S import U.Codebase.Sqlite.DbId qualified as Db import U.Codebase.Sqlite.Patch.Full qualified as S import U.Codebase.Sqlite.Patch.TermEdit qualified as S (TermEdit) import U.Codebase.Sqlite.Patch.TermEdit qualified as S.TermEdit import U.Codebase.Sqlite.Patch.TypeEdit qualified as S (TypeEdit) import U.Codebase.Sqlite.Patch.TypeEdit qualified as S.TypeEdit import U.Codebase.Sqlite.Queries qualified as Q import U.Codebase.Sqlite.Reference qualified as S import U.Codebase.Sqlite.Referent qualified as S import Unison.Hash (Hash) import Unison.Hashing.V2 qualified as Hashing import Unison.Prelude import Unison.Sqlite (Transaction) import Unison.Util.Map qualified as Map import Unison.Util.Set qualified as Set syncCausalHash :: S.SyncCausalFormat -> Transaction CausalHash syncCausalHash :: SyncCausalFormat -> Transaction CausalHash syncCausalHash S.SyncCausalFormat {$sel:valueHash:SyncCausalFormat :: forall causalHash valueHash. SyncCausalFormat' causalHash valueHash -> valueHash valueHash = BranchHashId valueHashId, $sel:parents:SyncCausalFormat :: forall causalHash valueHash. SyncCausalFormat' causalHash valueHash -> Vector causalHash parents = Vector CausalHashId parentChIds} = do (Causal -> CausalHash) -> Transaction Causal -> Transaction CausalHash forall a b. (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap (Hash -> CausalHash CausalHash (Hash -> CausalHash) -> (Causal -> Hash) -> Causal -> CausalHash forall b c a. (b -> c) -> (a -> b) -> a -> c . Causal -> Hash forall a. ContentAddressable a => a -> Hash Hashing.contentHash) (Transaction Causal -> Transaction CausalHash) -> Transaction Causal -> Transaction CausalHash forall a b. (a -> b) -> a -> b $ Hash -> Set Hash -> Causal Hashing.Causal (Hash -> Set Hash -> Causal) -> Transaction Hash -> Transaction (Set Hash -> Causal) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> forall a b. Coercible a b => a -> b forall a b. Coercible a b => a -> b coerce @(Transaction BranchHash) @(Transaction Hash) (BranchHashId -> Transaction BranchHash Q.expectBranchHash BranchHashId valueHashId) Transaction (Set Hash -> Causal) -> Transaction (Set Hash) -> Transaction Causal forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> (Vector CausalHash -> Set Hash) -> Transaction (Vector CausalHash) -> Transaction (Set Hash) forall a b. (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap ([Hash] -> Set Hash forall a. Ord a => [a] -> Set a Set.fromList ([Hash] -> Set Hash) -> (Vector CausalHash -> [Hash]) -> Vector CausalHash -> Set Hash forall b c a. (b -> c) -> (a -> b) -> a -> c . forall a b. Coercible a b => a -> b forall a b. Coercible a b => a -> b coerce @[CausalHash] @[Hash] ([CausalHash] -> [Hash]) -> (Vector CausalHash -> [CausalHash]) -> Vector CausalHash -> [Hash] forall b c a. (b -> c) -> (a -> b) -> a -> c . Vector CausalHash -> [CausalHash] forall a. Vector a -> [a] Vector.toList) ((CausalHashId -> Transaction CausalHash) -> Vector CausalHashId -> Transaction (Vector CausalHash) forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Vector a -> f (Vector b) traverse CausalHashId -> Transaction CausalHash Q.expectCausalHash Vector CausalHashId parentChIds) dbBranchHash :: S.DbBranch -> Transaction BranchHash dbBranchHash :: DbBranch -> Transaction BranchHash dbBranchHash (S.Branch.Full.Branch Map TextId (Map (Referent'' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) tms Map TextId (Map (TypeReference' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) tps Map TextId PatchObjectId patches Map TextId (BranchObjectId, CausalHashId) children) = (Branch -> BranchHash) -> Transaction Branch -> Transaction BranchHash forall a b. (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap (Hash -> BranchHash BranchHash (Hash -> BranchHash) -> (Branch -> Hash) -> Branch -> BranchHash forall b c a. (b -> c) -> (a -> b) -> a -> c . Branch -> Hash forall a. ContentAddressable a => a -> Hash Hashing.contentHash) (Transaction Branch -> Transaction BranchHash) -> Transaction Branch -> Transaction BranchHash forall a b. (a -> b) -> a -> b $ Map NameSegment (Map Referent MdValues) -> Map NameSegment (Map MetadataValue MdValues) -> Map NameSegment Hash -> Map NameSegment Hash -> Branch Hashing.Branch (Map NameSegment (Map Referent MdValues) -> Map NameSegment (Map MetadataValue MdValues) -> Map NameSegment Hash -> Map NameSegment Hash -> Branch) -> Transaction (Map NameSegment (Map Referent MdValues)) -> Transaction (Map NameSegment (Map MetadataValue MdValues) -> Map NameSegment Hash -> Map NameSegment Hash -> Branch) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Map TextId (Map (Referent'' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) -> Transaction (Map NameSegment (Map Referent MdValues)) doTerms Map TextId (Map (Referent'' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) tms Transaction (Map NameSegment (Map MetadataValue MdValues) -> Map NameSegment Hash -> Map NameSegment Hash -> Branch) -> Transaction (Map NameSegment (Map MetadataValue MdValues)) -> Transaction (Map NameSegment Hash -> Map NameSegment Hash -> Branch) forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Map TextId (Map (TypeReference' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) -> Transaction (Map NameSegment (Map MetadataValue MdValues)) doTypes Map TextId (Map (TypeReference' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) tps Transaction (Map NameSegment Hash -> Map NameSegment Hash -> Branch) -> Transaction (Map NameSegment Hash) -> Transaction (Map NameSegment Hash -> Branch) forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Map TextId PatchObjectId -> Transaction (Map NameSegment Hash) doPatches Map TextId PatchObjectId patches Transaction (Map NameSegment Hash -> Branch) -> Transaction (Map NameSegment Hash) -> Transaction Branch forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Map TextId (BranchObjectId, CausalHashId) -> Transaction (Map NameSegment Hash) doChildren Map TextId (BranchObjectId, CausalHashId) children where doTerms :: Map Db.TextId (Map S.Referent S.DbMetadataSet) -> Transaction (Map Hashing.NameSegment (Map Hashing.Referent Hashing.MdValues)) doTerms :: Map TextId (Map (Referent'' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) -> Transaction (Map NameSegment (Map Referent MdValues)) doTerms = (TextId -> Transaction NameSegment) -> (Map (Referent'' TextId ObjectId) (MetadataSetFormat' TextId ObjectId) -> Transaction (Map Referent MdValues)) -> Map TextId (Map (Referent'' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) -> Transaction (Map NameSegment (Map Referent MdValues)) forall (f :: * -> *) a' a b b'. (Applicative f, Ord a') => (a -> f a') -> (b -> f b') -> Map a b -> f (Map a' b') Map.bitraverse TextId -> Transaction NameSegment s2hNameSegment ((Referent'' TextId ObjectId -> Transaction Referent) -> (MetadataSetFormat' TextId ObjectId -> Transaction MdValues) -> Map (Referent'' TextId ObjectId) (MetadataSetFormat' TextId ObjectId) -> Transaction (Map Referent MdValues) forall (f :: * -> *) a' a b b'. (Applicative f, Ord a') => (a -> f a') -> (b -> f b') -> Map a b -> f (Map a' b') Map.bitraverse Referent'' TextId ObjectId -> Transaction Referent s2hReferent MetadataSetFormat' TextId ObjectId -> Transaction MdValues s2hMetadataSet) doTypes :: Map Db.TextId (Map S.Reference S.DbMetadataSet) -> Transaction (Map Hashing.NameSegment (Map Hashing.Reference Hashing.MdValues)) doTypes :: Map TextId (Map (TypeReference' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) -> Transaction (Map NameSegment (Map MetadataValue MdValues)) doTypes = (TextId -> Transaction NameSegment) -> (Map (TypeReference' TextId ObjectId) (MetadataSetFormat' TextId ObjectId) -> Transaction (Map MetadataValue MdValues)) -> Map TextId (Map (TypeReference' TextId ObjectId) (MetadataSetFormat' TextId ObjectId)) -> Transaction (Map NameSegment (Map MetadataValue MdValues)) forall (f :: * -> *) a' a b b'. (Applicative f, Ord a') => (a -> f a') -> (b -> f b') -> Map a b -> f (Map a' b') Map.bitraverse TextId -> Transaction NameSegment s2hNameSegment ((TypeReference' TextId ObjectId -> Transaction MetadataValue) -> (MetadataSetFormat' TextId ObjectId -> Transaction MdValues) -> Map (TypeReference' TextId ObjectId) (MetadataSetFormat' TextId ObjectId) -> Transaction (Map MetadataValue MdValues) forall (f :: * -> *) a' a b b'. (Applicative f, Ord a') => (a -> f a') -> (b -> f b') -> Map a b -> f (Map a' b') Map.bitraverse TypeReference' TextId ObjectId -> Transaction MetadataValue s2hReference MetadataSetFormat' TextId ObjectId -> Transaction MdValues s2hMetadataSet) doPatches :: Map Db.TextId Db.PatchObjectId -> Transaction (Map Hashing.NameSegment Hash) doPatches :: Map TextId PatchObjectId -> Transaction (Map NameSegment Hash) doPatches = (TextId -> Transaction NameSegment) -> (PatchObjectId -> Transaction Hash) -> Map TextId PatchObjectId -> Transaction (Map NameSegment Hash) forall (f :: * -> *) a' a b b'. (Applicative f, Ord a') => (a -> f a') -> (b -> f b') -> Map a b -> f (Map a' b') Map.bitraverse TextId -> Transaction NameSegment s2hNameSegment (ObjectId -> Transaction Hash Q.expectPrimaryHashByObjectId (ObjectId -> Transaction Hash) -> (PatchObjectId -> ObjectId) -> PatchObjectId -> Transaction Hash forall b c a. (b -> c) -> (a -> b) -> a -> c . PatchObjectId -> ObjectId Db.unPatchObjectId) doChildren :: Map Db.TextId (Db.BranchObjectId, Db.CausalHashId) -> Transaction (Map Hashing.NameSegment Hash) doChildren :: Map TextId (BranchObjectId, CausalHashId) -> Transaction (Map NameSegment Hash) doChildren = (TextId -> Transaction NameSegment) -> ((BranchObjectId, CausalHashId) -> Transaction Hash) -> Map TextId (BranchObjectId, CausalHashId) -> Transaction (Map NameSegment Hash) forall (f :: * -> *) a' a b b'. (Applicative f, Ord a') => (a -> f a') -> (b -> f b') -> Map a b -> f (Map a' b') Map.bitraverse TextId -> Transaction NameSegment s2hNameSegment \(BranchObjectId _boId, CausalHashId chId) -> HashId -> Transaction Hash Q.expectHash (CausalHashId -> HashId Db.unCausalHashId CausalHashId chId) dbPatchHash :: S.Patch -> Transaction PatchHash dbPatchHash :: Patch -> Transaction PatchHash dbPatchHash S.Patch {Map (Referent'' TextId HashId) (Set (TermEdit' TextId ObjectId)) termEdits :: Map (Referent'' TextId HashId) (Set (TermEdit' TextId ObjectId)) $sel:termEdits:Patch :: forall t h o. Patch' t h o -> Map (Referent'' t h) (Set (TermEdit' t o)) S.termEdits, Map (Reference' TextId HashId) (Set (TypeEdit' TextId ObjectId)) typeEdits :: Map (Reference' TextId HashId) (Set (TypeEdit' TextId ObjectId)) $sel:typeEdits:Patch :: forall t h o. Patch' t h o -> Map (Reference' t h) (Set (TypeEdit' t o)) S.typeEdits} = (Patch -> PatchHash) -> Transaction Patch -> Transaction PatchHash forall a b. (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap (Hash -> PatchHash PatchHash (Hash -> PatchHash) -> (Patch -> Hash) -> Patch -> PatchHash forall b c a. (b -> c) -> (a -> b) -> a -> c . Patch -> Hash forall a. ContentAddressable a => a -> Hash Hashing.contentHash) (Transaction Patch -> Transaction PatchHash) -> Transaction Patch -> Transaction PatchHash forall a b. (a -> b) -> a -> b $ Map Referent (Set TermEdit) -> Map MetadataValue (Set TypeEdit) -> Patch Hashing.Patch (Map Referent (Set TermEdit) -> Map MetadataValue (Set TypeEdit) -> Patch) -> Transaction (Map Referent (Set TermEdit)) -> Transaction (Map MetadataValue (Set TypeEdit) -> Patch) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Map (Referent'' TextId HashId) (Set (TermEdit' TextId ObjectId)) -> Transaction (Map Referent (Set TermEdit)) doTermEdits Map (Referent'' TextId HashId) (Set (TermEdit' TextId ObjectId)) termEdits Transaction (Map MetadataValue (Set TypeEdit) -> Patch) -> Transaction (Map MetadataValue (Set TypeEdit)) -> Transaction Patch forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Map (Reference' TextId HashId) (Set (TypeEdit' TextId ObjectId)) -> Transaction (Map MetadataValue (Set TypeEdit)) doTypeEdits Map (Reference' TextId HashId) (Set (TypeEdit' TextId ObjectId)) typeEdits where doTermEdits :: Map S.ReferentH (Set S.TermEdit) -> Transaction (Map Hashing.Referent (Set Hashing.TermEdit)) doTermEdits :: Map (Referent'' TextId HashId) (Set (TermEdit' TextId ObjectId)) -> Transaction (Map Referent (Set TermEdit)) doTermEdits = (Referent'' TextId HashId -> Transaction Referent) -> (Set (TermEdit' TextId ObjectId) -> Transaction (Set TermEdit)) -> Map (Referent'' TextId HashId) (Set (TermEdit' TextId ObjectId)) -> Transaction (Map Referent (Set TermEdit)) forall (f :: * -> *) a' a b b'. (Applicative f, Ord a') => (a -> f a') -> (b -> f b') -> Map a b -> f (Map a' b') Map.bitraverse Referent'' TextId HashId -> Transaction Referent s2hReferentH ((TermEdit' TextId ObjectId -> Transaction TermEdit) -> Set (TermEdit' TextId ObjectId) -> Transaction (Set TermEdit) forall (f :: * -> *) b a. (Applicative f, Ord b) => (a -> f b) -> Set a -> f (Set b) Set.traverse TermEdit' TextId ObjectId -> Transaction TermEdit s2hTermEdit) doTypeEdits :: Map S.ReferenceH (Set S.TypeEdit) -> Transaction (Map Hashing.Reference (Set Hashing.TypeEdit)) doTypeEdits :: Map (Reference' TextId HashId) (Set (TypeEdit' TextId ObjectId)) -> Transaction (Map MetadataValue (Set TypeEdit)) doTypeEdits = (Reference' TextId HashId -> Transaction MetadataValue) -> (Set (TypeEdit' TextId ObjectId) -> Transaction (Set TypeEdit)) -> Map (Reference' TextId HashId) (Set (TypeEdit' TextId ObjectId)) -> Transaction (Map MetadataValue (Set TypeEdit)) forall (f :: * -> *) a' a b b'. (Applicative f, Ord a') => (a -> f a') -> (b -> f b') -> Map a b -> f (Map a' b') Map.bitraverse Reference' TextId HashId -> Transaction MetadataValue s2hReferenceH ((TypeEdit' TextId ObjectId -> Transaction TypeEdit) -> Set (TypeEdit' TextId ObjectId) -> Transaction (Set TypeEdit) forall (f :: * -> *) b a. (Applicative f, Ord b) => (a -> f b) -> Set a -> f (Set b) Set.traverse TypeEdit' TextId ObjectId -> Transaction TypeEdit s2hTypeEdit) s2hMetadataSet :: DbMetadataSet -> Transaction Hashing.MdValues s2hMetadataSet :: MetadataSetFormat' TextId ObjectId -> Transaction MdValues s2hMetadataSet = \case S.MetadataSet.Inline Set (TypeReference' TextId ObjectId) rs -> Set MetadataValue -> MdValues Hashing.MdValues (Set MetadataValue -> MdValues) -> Transaction (Set MetadataValue) -> Transaction MdValues forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (TypeReference' TextId ObjectId -> Transaction MetadataValue) -> Set (TypeReference' TextId ObjectId) -> Transaction (Set MetadataValue) forall (f :: * -> *) b a. (Applicative f, Ord b) => (a -> f b) -> Set a -> f (Set b) Set.traverse TypeReference' TextId ObjectId -> Transaction MetadataValue s2hReference Set (TypeReference' TextId ObjectId) rs s2hNameSegment :: Db.TextId -> Transaction Hashing.NameSegment s2hNameSegment :: TextId -> Transaction NameSegment s2hNameSegment = (Text -> NameSegment) -> Transaction Text -> Transaction NameSegment forall a b. (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Text -> NameSegment Hashing.NameSegment (Transaction Text -> Transaction NameSegment) -> (TextId -> Transaction Text) -> TextId -> Transaction NameSegment forall b c a. (b -> c) -> (a -> b) -> a -> c . TextId -> Transaction Text Q.expectText s2hReferent :: S.Referent -> Transaction Hashing.Referent s2hReferent :: Referent'' TextId ObjectId -> Transaction Referent s2hReferent = \case S.Referent.Ref TypeReference' TextId ObjectId r -> MetadataValue -> Referent Hashing.ReferentRef (MetadataValue -> Referent) -> Transaction MetadataValue -> Transaction Referent forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> TypeReference' TextId ObjectId -> Transaction MetadataValue s2hReference TypeReference' TextId ObjectId r S.Referent.Con TypeReference' TextId ObjectId r ConstructorId cid -> MetadataValue -> ConstructorId -> Referent Hashing.ReferentCon (MetadataValue -> ConstructorId -> Referent) -> Transaction MetadataValue -> Transaction (ConstructorId -> Referent) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> TypeReference' TextId ObjectId -> Transaction MetadataValue s2hReference TypeReference' TextId ObjectId r Transaction (ConstructorId -> Referent) -> Transaction ConstructorId -> Transaction Referent forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ConstructorId -> Transaction ConstructorId forall a. a -> Transaction a forall (f :: * -> *) a. Applicative f => a -> f a pure (ConstructorId -> ConstructorId forall a b. (Integral a, Num b) => a -> b fromIntegral ConstructorId cid) s2hReferentH :: S.ReferentH -> Transaction Hashing.Referent s2hReferentH :: Referent'' TextId HashId -> Transaction Referent s2hReferentH = \case S.Referent.Ref Reference' TextId HashId r -> MetadataValue -> Referent Hashing.ReferentRef (MetadataValue -> Referent) -> Transaction MetadataValue -> Transaction Referent forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Reference' TextId HashId -> Transaction MetadataValue s2hReferenceH Reference' TextId HashId r S.Referent.Con Reference' TextId HashId r ConstructorId cid -> MetadataValue -> ConstructorId -> Referent Hashing.ReferentCon (MetadataValue -> ConstructorId -> Referent) -> Transaction MetadataValue -> Transaction (ConstructorId -> Referent) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Reference' TextId HashId -> Transaction MetadataValue s2hReferenceH Reference' TextId HashId r Transaction (ConstructorId -> Referent) -> Transaction ConstructorId -> Transaction Referent forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ConstructorId -> Transaction ConstructorId forall a. a -> Transaction a forall (f :: * -> *) a. Applicative f => a -> f a pure (ConstructorId -> ConstructorId forall a b. (Integral a, Num b) => a -> b fromIntegral ConstructorId cid) s2hReference :: S.Reference -> Transaction Hashing.Reference s2hReference :: TypeReference' TextId ObjectId -> Transaction MetadataValue s2hReference = \case S.ReferenceBuiltin TextId t -> Text -> MetadataValue Hashing.ReferenceBuiltin (Text -> MetadataValue) -> Transaction Text -> Transaction MetadataValue forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> TextId -> Transaction Text Q.expectText TextId t S.Reference.Derived ObjectId h ConstructorId i -> Hash -> ConstructorId -> MetadataValue Hashing.ReferenceDerived (Hash -> ConstructorId -> MetadataValue) -> Transaction Hash -> Transaction (ConstructorId -> MetadataValue) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> ObjectId -> Transaction Hash Q.expectPrimaryHashByObjectId ObjectId h Transaction (ConstructorId -> MetadataValue) -> Transaction ConstructorId -> Transaction MetadataValue forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ConstructorId -> Transaction ConstructorId forall a. a -> Transaction a forall (f :: * -> *) a. Applicative f => a -> f a pure ConstructorId i s2hReferenceH :: S.ReferenceH -> Transaction Hashing.Reference s2hReferenceH :: Reference' TextId HashId -> Transaction MetadataValue s2hReferenceH = \case S.ReferenceBuiltin TextId t -> Text -> MetadataValue Hashing.ReferenceBuiltin (Text -> MetadataValue) -> Transaction Text -> Transaction MetadataValue forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> TextId -> Transaction Text Q.expectText TextId t S.Reference.Derived HashId h ConstructorId i -> Hash -> ConstructorId -> MetadataValue Hashing.ReferenceDerived (Hash -> ConstructorId -> MetadataValue) -> Transaction Hash -> Transaction (ConstructorId -> MetadataValue) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> HashId -> Transaction Hash Q.expectHash HashId h Transaction (ConstructorId -> MetadataValue) -> Transaction ConstructorId -> Transaction MetadataValue forall a b. Transaction (a -> b) -> Transaction a -> Transaction b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ConstructorId -> Transaction ConstructorId forall a. a -> Transaction a forall (f :: * -> *) a. Applicative f => a -> f a pure ConstructorId i s2hTermEdit :: S.TermEdit -> Transaction Hashing.TermEdit s2hTermEdit :: TermEdit' TextId ObjectId -> Transaction TermEdit s2hTermEdit = \case S.TermEdit.Replace Referent'' TextId ObjectId r Typing _typing -> Referent -> TermEdit Hashing.TermEditReplace (Referent -> TermEdit) -> Transaction Referent -> Transaction TermEdit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Referent'' TextId ObjectId -> Transaction Referent s2hReferent Referent'' TextId ObjectId r TermEdit' TextId ObjectId S.TermEdit.Deprecate -> TermEdit -> Transaction TermEdit forall a. a -> Transaction a forall (f :: * -> *) a. Applicative f => a -> f a pure TermEdit Hashing.TermEditDeprecate s2hTypeEdit :: S.TypeEdit -> Transaction Hashing.TypeEdit s2hTypeEdit :: TypeEdit' TextId ObjectId -> Transaction TypeEdit s2hTypeEdit = \case S.TypeEdit.Replace TypeReference' TextId ObjectId r -> MetadataValue -> TypeEdit Hashing.TypeEditReplace (MetadataValue -> TypeEdit) -> Transaction MetadataValue -> Transaction TypeEdit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> TypeReference' TextId ObjectId -> Transaction MetadataValue s2hReference TypeReference' TextId ObjectId r TypeEdit' TextId ObjectId S.TypeEdit.Deprecate -> TypeEdit -> Transaction TypeEdit forall a. a -> Transaction a forall (f :: * -> *) a. Applicative f => a -> f a pure TypeEdit Hashing.TypeEditDeprecate