Skip to content

Commit

Permalink
Merge branch 'trunk' into cp/defn-search-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Jul 26, 2024
2 parents cdab05d + b12baa4 commit a49146f
Show file tree
Hide file tree
Showing 126 changed files with 902 additions and 936 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ indent_style = space
insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true

[*.u]
max_line_length = off
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ jobs:
write-mode: overwrite
contents: |
```ucm
.> project.create-empty jit-setup
scratch/main> project.create-empty jit-setup
jit-setup/main> lib.install ${{ env.jit_version }}
```
```unison
Expand Down
4 changes: 4 additions & 0 deletions .ormolu
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
infixl 8 ^?
infixr 4 %%~, %~
infixl 3 <|>
infixl 1 &, <&>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import U.Codebase.HashTags
import Unison.Hashing.V2 qualified as Hashing
import Unison.Hashing.V2.Convert2 (convertBranchV3, v2ToH2Branch)

hashBranch :: forall m. Monad m => Branch m -> m BranchHash
hashBranch :: forall m. (Monad m) => Branch m -> m BranchHash
hashBranch branch =
BranchHash . Hashing.contentHash <$> v2ToH2Branch branch

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ v2ToH2Referent = \case
V2Referent.Ref r -> H2.ReferentRef (v2ToH2Reference r)
V2Referent.Con r cid -> H2.ReferentCon (v2ToH2Reference r) cid

v2ToH2Branch :: Monad m => V2.Branch m -> m H2.Branch
v2ToH2Branch :: (Monad m) => V2.Branch m -> m H2.Branch
v2ToH2Branch V2.Branch {terms, types, patches, children} = do
hterms <-
traverse sequenceA terms
Expand Down Expand Up @@ -166,7 +166,7 @@ hashPatchFormatToH2Patch Memory.PatchFull.Patch {termEdits, typeEdits} =
V2Referent.Con typeRef conId -> do
(H2.ReferentCon (v2ToH2Reference $ second unComponentHash typeRef) conId)

v2ToH2Term :: forall v. Ord v => V2.Term.HashableTerm v -> H2.Term v ()
v2ToH2Term :: forall v. (Ord v) => V2.Term.HashableTerm v -> H2.Term v ()
v2ToH2Term = ABT.transform convertF
where
convertF :: V2.Term.F' Text V2.Term.HashableTermRef V2.Term.TypeRef V2.Term.HashableTermLink V2.Term.TypeLink v a1 -> H2.TermF v () () a1
Expand Down
2 changes: 1 addition & 1 deletion codebase2/codebase-sqlite/U/Codebase/Sqlite/Decode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ decodeWatchResultFormat =
------------------------------------------------------------------------------------------------------------------------
-- unsyncs

unsyncTermComponent :: HasCallStack => TermFormat.SyncLocallyIndexedComponent' t d -> Either DecodeError (TermFormat.LocallyIndexedComponent' t d)
unsyncTermComponent :: (HasCallStack) => TermFormat.SyncLocallyIndexedComponent' t d -> Either DecodeError (TermFormat.LocallyIndexedComponent' t d)
unsyncTermComponent (TermFormat.SyncLocallyIndexedComponent terms) = do
let phi (localIds, bs) = do
(a, b) <- decodeSyncTermAndType bs
Expand Down
2 changes: 1 addition & 1 deletion codebase2/codebase-sqlite/U/Codebase/Sqlite/HashHandle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data HashHandle = HashHandle
toReferenceDecl :: Hash -> C.Type.TypeD Symbol -> C.Reference,
-- | Hash decl's mentions
toReferenceDeclMentions :: Hash -> C.Type.TypeD Symbol -> Set C.Reference,
hashBranch :: forall m. Monad m => Branch m -> m BranchHash,
hashBranch :: forall m. (Monad m) => Branch m -> m BranchHash,
hashBranchV3 :: forall m. BranchV3 m -> BranchHash,
hashCausal ::
-- The causal's namespace hash
Expand Down
24 changes: 12 additions & 12 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/LocalizeObject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,23 @@ localizePatchG (Patch termEdits typeEdits) =
-- General-purpose localization

-- Contains references to branch objects.
class Ord c => ContainsBranches c s where
class (Ord c) => ContainsBranches c s where
branches_ :: Lens' s (Map c LocalBranchChildId)

-- Contains references to definition objects i.e. term/decl component objects.
class Ord d => ContainsDefns d s where
class (Ord d) => ContainsDefns d s where
defns_ :: Lens' s (Map d LocalDefnId)

-- Contains references to objects by their hash.
class Ord h => ContainsHashes h s where
class (Ord h) => ContainsHashes h s where
hashes_ :: Lens' s (Map h LocalHashId)

-- Contains references to patch objects.
class Ord p => ContainsPatches p s where
class (Ord p) => ContainsPatches p s where
patches_ :: Lens' s (Map p LocalPatchObjectId)

-- Contains text.
class Ord t => ContainsText t s where
class (Ord t) => ContainsText t s where
texts_ :: Lens' s (Map t LocalTextId)

-- The inner state of the localization of a branch object.
Expand All @@ -137,16 +137,16 @@ data LocalizeBranchState t d p c = LocalizeBranchState
}
deriving (Show, Generic)

instance Ord t => ContainsText t (LocalizeBranchState t d p c) where
instance (Ord t) => ContainsText t (LocalizeBranchState t d p c) where
texts_ = field @"texts"

instance Ord d => ContainsDefns d (LocalizeBranchState t d p c) where
instance (Ord d) => ContainsDefns d (LocalizeBranchState t d p c) where
defns_ = field @"defns"

instance Ord p => ContainsPatches p (LocalizeBranchState t d p c) where
instance (Ord p) => ContainsPatches p (LocalizeBranchState t d p c) where
patches_ = field @"patches"

instance Ord c => ContainsBranches c (LocalizeBranchState t d p c) where
instance (Ord c) => ContainsBranches c (LocalizeBranchState t d p c) where
branches_ = field @"branches"

-- | Run a computation that localizes a branch object, returning the local ids recorded within.
Expand All @@ -171,13 +171,13 @@ data LocalizePatchState t h d = LocalizePatchState
}
deriving (Show, Generic)

instance Ord t => ContainsText t (LocalizePatchState t h d) where
instance (Ord t) => ContainsText t (LocalizePatchState t h d) where
texts_ = field @"texts"

instance Ord h => ContainsHashes h (LocalizePatchState t h d) where
instance (Ord h) => ContainsHashes h (LocalizePatchState t h d) where
hashes_ = field @"hashes"

instance Ord d => ContainsDefns d (LocalizePatchState t h d) where
instance (Ord d) => ContainsDefns d (LocalizePatchState t h d) where
defns_ = field @"defns"

-- Run a computation that localizes a patch object, returning the local ids recorded within.
Expand Down
2 changes: 1 addition & 1 deletion codebase2/codebase-sqlite/U/Codebase/Sqlite/NamedRef.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ instance (FromRow ref) => FromRow (NamedRef ref) where
newtype ScopedRow ref
= ScopedRow (NamedRef ref)

instance ToRow ref => ToRow (ScopedRow ref) where
instance (ToRow ref) => ToRow (ScopedRow ref) where
toRow (ScopedRow (NamedRef {reversedSegments = revSegments, ref})) =
SQLText reversedName : SQLText namespace : SQLText lastNameSegment : toRow ref
where
Expand Down
2 changes: 1 addition & 1 deletion codebase2/codebase-sqlite/U/Codebase/Sqlite/Patch/Full.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ patchT_ f Patch {termEdits, typeEdits} = do
newTypeEdits <- traverseOf (Map.bitraversed (Reference.t_) (Set.traverse . traverseFirst)) f typeEdits
pure Patch {termEdits = newTermEdits, typeEdits = newTypeEdits}
where
traverseFirst :: Bitraversable b => Traversal (b a c) (b a' c) a a'
traverseFirst :: (Bitraversable b) => Traversal (b a c) (b a' c) a a'
traverseFirst f = bitraverse f pure

patchH_ :: (Ord t, Ord h') => Traversal (Patch' t h o) (Patch' t h' o) h h'
Expand Down
2 changes: 1 addition & 1 deletion codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ module U.Codebase.Sqlite.Queries
-- * Types
NamespaceText,
TextPathSegments,
JsonParseFailure(..),
JsonParseFailure (..),
)
where

Expand Down
6 changes: 3 additions & 3 deletions codebase2/codebase-sqlite/U/Codebase/Sqlite/Serialization.hs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ putDeclFormat = \case
putDeclComponent (DeclFormat.LocallyIndexedComponent v) =
putFramedArray (putPair putLocalIds putDeclElement) v

putDeclElement :: MonadPut m => Decl.DeclR DeclFormat.TypeRef Symbol -> m ()
putDeclElement :: (MonadPut m) => Decl.DeclR DeclFormat.TypeRef Symbol -> m ()
putDeclElement Decl.DataDeclaration {..} = do
putDeclType declType
putModifier modifier
Expand Down Expand Up @@ -499,7 +499,7 @@ getDeclElement =
1 -> pure Decl.Effect
other -> unknownTag "DeclType" other

getModifier :: MonadGet m => m Modifier
getModifier :: (MonadGet m) => m Modifier
getModifier =
getWord8 >>= \case
0 -> pure Decl.Structural
Expand Down Expand Up @@ -720,7 +720,7 @@ getLocalBranch =
x -> unknownTag "getMetadataSetFormat" x

getBranchDiff' ::
MonadGet m =>
(MonadGet m) =>
m branchRef ->
m (BranchFormat.BranchLocalIds' text defRef patchRef childRef) ->
m (BranchFormat.BranchFormat' text defRef patchRef childRef branchRef)
Expand Down
4 changes: 2 additions & 2 deletions codebase2/codebase/U/Codebase/Causal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ data Causal m hc he pe e = Causal
}
deriving stock (Functor, Generic)

instance Eq hc => Eq (Causal m hc he pe e) where
instance (Eq hc) => Eq (Causal m hc he pe e) where
(==) = (==) `on` causalHash

-- | @emap f g@ maps over the values and parents' values with @f@ and @g@.
emap :: Functor m => (e -> e') -> (pe -> pe') -> Causal m hc he pe e -> Causal m hc he pe' e'
emap :: (Functor m) => (e -> e') -> (pe -> pe') -> Causal m hc he pe e -> Causal m hc he pe' e'
emap f g causal@Causal {parents, value} =
causal
{ parents = Map.map (fmap (emap g g)) parents,
Expand Down
6 changes: 3 additions & 3 deletions codebase2/codebase/U/Codebase/Decl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ data DeclR r v = DataDeclaration
}
deriving (Show)

allVars :: Ord v => DeclR r v -> Set v
allVars :: (Ord v) => DeclR r v -> Set v
allVars (DataDeclaration _ _ bound constructorTypes) =
(Set.fromList $ foldMap ABT.allVars constructorTypes) <> Set.fromList bound

vmap :: Ord v' => (v -> v') -> DeclR r v -> DeclR r v'
vmap :: (Ord v') => (v -> v') -> DeclR r v -> DeclR r v'
vmap f (DataDeclaration {declType, modifier, bound, constructorTypes}) =
DataDeclaration
{ declType,
Expand Down Expand Up @@ -82,7 +82,7 @@ data F a
-- to the relevant piece of the component in the component map.
unhashComponent ::
forall v extra.
ABT.Var v =>
(ABT.Var v) =>
Hash ->
-- | A function to convert a reference to a variable. The actual var names aren't important.
(Reference.Id -> v) ->
Expand Down
4 changes: 2 additions & 2 deletions codebase2/codebase/U/Codebase/Term.hs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ extraMapM ftext ftermRef ftypeRef ftermLink ftypeLink fvt = go'
rmapPattern :: (t -> t') -> (r -> r') -> Pattern t r -> Pattern t' r'
rmapPattern ft fr p = runIdentity . rmapPatternM (pure . ft) (pure . fr) $ p

rmapPatternM :: Applicative m => (t -> m t') -> (r -> m r') -> Pattern t r -> m (Pattern t' r')
rmapPatternM :: (Applicative m) => (t -> m t') -> (r -> m r') -> Pattern t r -> m (Pattern t' r')
rmapPatternM ft fr = go
where
go = \case
Expand Down Expand Up @@ -260,7 +260,7 @@ dependencies =
-- to the relevant piece of the component in the component map.
unhashComponent ::
forall v extra.
ABT.Var v =>
(ABT.Var v) =>
-- | The hash of the component, this is used to fill in self-references.
Hash ->
-- | A function to convert a reference to a variable. The actual var names aren't important.
Expand Down
13 changes: 7 additions & 6 deletions codebase2/core/Unison/NameSegment/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ newtype NameSegment = NameSegment
deriving newtype (Alphabetical)

instance
TypeError
( 'TypeError.Text "You cannot implicitly convert a ‘String’ to a ‘NameSegment’. If you need a"
':$$: 'TypeError.Text "special-cased segment it should exist as a constant in"
':$$: 'TypeError.Text "“Unison.NameSegment”, otherwise it should be parsed via"
':$$: 'TypeError.Text "“Unison.Syntax.NameSegment”."
) =>
( TypeError
( 'TypeError.Text "You cannot implicitly convert a ‘String’ to a ‘NameSegment’. If you need a"
':$$: 'TypeError.Text "special-cased segment it should exist as a constant in"
':$$: 'TypeError.Text "“Unison.NameSegment”, otherwise it should be parsed via"
':$$: 'TypeError.Text "“Unison.Syntax.NameSegment”."
)
) =>
IsString NameSegment
where
fromString = undefined
4 changes: 2 additions & 2 deletions codebase2/core/Unison/Util/Alphabetical.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import Data.Text (Text)
class (Eq n) => Alphabetical n where
compareAlphabetical :: n -> n -> Ordering

sortAlphabetically :: Alphabetical a => [a] -> [a]
sortAlphabetically :: (Alphabetical a) => [a] -> [a]
sortAlphabetically as = (\(OrderAlphabetically a) -> a) <$> List.sort (map OrderAlphabetically as)

sortAlphabeticallyOn :: Alphabetical a => (b -> a) -> [b] -> [b]
sortAlphabeticallyOn :: (Alphabetical a) => (b -> a) -> [b] -> [b]
sortAlphabeticallyOn f = List.sortOn (OrderAlphabetically . f)

instance Alphabetical Text where
Expand Down
2 changes: 1 addition & 1 deletion codebase2/util-serialization/U/Util/Serialization.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ getVector getA = do
length <- getVarInt
Vector.replicateM length getA

skipVector :: MonadGet m => m a -> m ()
skipVector :: (MonadGet m) => m a -> m ()
skipVector getA = do
length <- getVarInt
replicateM_ length getA
Expand Down
Loading

0 comments on commit a49146f

Please sign in to comment.