@@ -150,7 +150,7 @@ handleUpdate2 = do
150150 Cli. respond Output. UpdateTypecheckingSuccess
151151 pure secondTuf
152152
153- saveTuf (findCtorNames namesExcludingLibdeps ctorNames Nothing ) secondTuf
153+ saveTuf (findCtorNames Output. UOUUpdate namesExcludingLibdeps ctorNames Nothing ) secondTuf
154154 Cli. respond Output. Success
155155
156156-- TODO: find a better module for this function, as it's used in a couple places
@@ -284,22 +284,23 @@ buildBigUnisonFile ::
284284 Map ForwardName (Referent , Name ) ->
285285 Transaction (UnisonFile Symbol Ann )
286286buildBigUnisonFile abort c tuf dependents names ctorNames =
287- addDefinitionsToUnisonFile abort c names ctorNames dependents (UF. discardTypes tuf)
287+ addDefinitionsToUnisonFile Output. UOUUpdate abort c names ctorNames dependents (UF. discardTypes tuf)
288288
289289-- | @addDefinitionsToUnisonFile abort codebase names ctorNames definitions file@ adds all @definitions@ to @file@, avoiding
290290-- overwriting anything already in @file@. Every definition is put into the file with every naming it has in @names@ "on
291291-- the left-hand-side of the equals" (but yes type decls don't really have a LHS).
292292--
293293-- TODO: find a better module for this function, as it's used in a couple places
294294addDefinitionsToUnisonFile ::
295+ Output. UpdateOrUpgrade ->
295296 (forall void . Output -> Transaction void ) ->
296297 Codebase IO Symbol Ann ->
297298 Names ->
298299 Map ForwardName (Referent , Name ) ->
299300 Map Reference. Id ReferenceType ->
300301 UnisonFile Symbol Ann ->
301302 Transaction (UnisonFile Symbol Ann )
302- addDefinitionsToUnisonFile abort c names ctorNames dependents initialUnisonFile =
303+ addDefinitionsToUnisonFile operation abort c names ctorNames dependents initialUnisonFile =
303304 -- for each dependent, add its definition with all its names to the UnisonFile
304305 foldM addComponent initialUnisonFile (Map. toList dependents')
305306 where
@@ -358,7 +359,7 @@ addDefinitionsToUnisonFile abort c names ctorNames dependents initialUnisonFile
358359 overwriteConstructorNames :: Name -> DataDeclaration Symbol Ann -> Transaction (DataDeclaration Symbol Ann )
359360 overwriteConstructorNames name dd =
360361 let constructorNames :: Transaction [Symbol ]
361- constructorNames = case findCtorNames names ctorNames (Just $ Decl. constructorCount dd) name of
362+ constructorNames = case findCtorNames operation names ctorNames (Just $ Decl. constructorCount dd) name of
362363 Left err -> abort err
363364 Right array ->
364365 case traverse (fmap Name. toVar . Name. stripNamePrefix name) array of
@@ -387,8 +388,8 @@ forwardCtorNames names =
387388 ]
388389
389390-- | given a decl name, find names for all of its constructors, in order.
390- findCtorNames :: Names -> Map ForwardName (Referent , Name ) -> Maybe Int -> Name -> Either Output. Output [Name ]
391- findCtorNames names forwardCtorNames ctorCount n =
391+ findCtorNames :: Output. UpdateOrUpgrade -> Names -> Map ForwardName (Referent , Name ) -> Maybe Int -> Name -> Either Output. Output [Name ]
392+ findCtorNames operation names forwardCtorNames ctorCount n =
392393 let declRef = Set. findMin $ Relation. lookupDom n names. types
393394 f = ForwardName. fromName n
394395 (_, centerRight) = Map. split f forwardCtorNames
@@ -407,7 +408,7 @@ findCtorNames names forwardCtorNames ctorCount n =
407408 ctorCountGuess = fromMaybe (Map. size m) ctorCount
408409 in if Map. size m == ctorCountGuess && all (isJust . flip Map. lookup m . fromIntegral ) [0 .. ctorCountGuess - 1 ]
409410 then Right $ Map. elems m
410- else Left $ Output. UpdateIncompleteConstructorSet n m ctorCount
411+ else Left $ Output. UpdateIncompleteConstructorSet operation n m ctorCount
411412
412413-- Used by `findCtorNames` to filter `forwardCtorNames` to a narrow range which will be searched linearly.
413414-- >>> incrementLastSegmentChar $ ForwardName.fromName $ Name.unsafeFromText "foo.bar.quux"
0 commit comments