@@ -54,7 +54,6 @@ import Data.HashMap.Strict (HashMap)
5454import Data.HashMap.Strict qualified as HashMap
5555import Data.HashSet (HashSet )
5656import Data.HashSet qualified as HashSet
57- import Data.Hashable (Hashable )
5857import Data.List (genericLength , sortOn )
5958import Data.List.NonEmpty (NonEmpty ((:|) ))
6059import Data.Map.Strict qualified as Map
@@ -119,11 +118,11 @@ loadAllTagTexts = Set.fromList . mapMaybe (tag_text . entityVal) <$> loadAllTags
119118
120119-- | Load 'Tag' references only for text strings existing in the collection.
121120loadTagRefsByText ::
122- (Foldable f , MonadStorage m ) => f Text -> m (HashSet (ObjectRef Tag ))
121+ (Foldable f , MonadStorage m ) => f Text -> m (Set (ObjectRef Tag ))
123122loadTagRefsByText queryTags = do
124123 allTags <- loadAll
125124 pure $
126- HashSet . fromList
125+ Set . fromList
127126 [ docIdToRef entityId
128127 | Entity {entityId, entityVal = Tag {tag_text = Just tag}} <- allTags
129128 , tag `elem` queryTags
@@ -137,9 +136,9 @@ loadTagsByRefs refs =
137136 fmap (ref,) . tag_text . entityVal <$> load (refToDocId ref)
138137
139138-- | Create tag objects with given texts.
140- createTags :: MonadStorage m => Set Text -> m (HashSet (ObjectRef Tag ))
139+ createTags :: MonadStorage m => Set Text -> m (Set (ObjectRef Tag ))
141140createTags tags =
142- fmap HashSet . fromList $
141+ fmap Set . fromList $
143142 for (toList tags) $ \ tag -> do
144143 tagFrame@ ObjectFrame {uuid} <- newObjectFrame Tag {tag_text = Just tag}
145144 createDocument tagFrame
@@ -151,9 +150,9 @@ createTags tags =
151150-- It returns references that should be added to note_tags.
152151-- References may content ones that note_tags has already.
153152getOrCreateTags ::
154- (Foldable f , MonadStorage m ) => f Text -> m (HashSet (ObjectRef Tag ))
153+ (Foldable f , MonadStorage m ) => f Text -> m (Set (ObjectRef Tag ))
155154getOrCreateTags tags
156- | null tags = pure HashSet . empty
155+ | null tags = pure Set . empty
157156 | otherwise = do
158157 allTags <- loadAllTagTexts
159158 existentTagRefs <- loadTagRefsByText tags
@@ -373,9 +372,9 @@ updateTrackedNote oldNotes NoteView{note, tags} =
373372 note_status_setIfDiffer note_status
374373 note_text_zoom $ RGA. edit text
375374 -- Add new tags
376- currentRefs <- HashSet . fromList <$> note_tags_read
377- traverse_ note_tags_add $ newRefs \- currentRefs
378- traverse_ note_tags_remove $ currentRefs \- newRefs
375+ currentRefs <- Set . fromList <$> note_tags_read
376+ traverse_ note_tags_add $ newRefs \\ currentRefs
377+ traverse_ note_tags_remove $ currentRefs \\ newRefs
379378 Nothing ->
380379 throwError " External note is expected to be supplied with tracking"
381380 where
@@ -529,9 +528,9 @@ cmdEdit edit input = case edit of
529528 for_ text $ note_text_zoom . RGA. editText
530529 -- add new tags
531530 unless (null addTags) $ do
532- currentRefs <- HashSet . fromList <$> note_tags_read
531+ currentRefs <- Set . fromList <$> note_tags_read
533532 -- skip tags if note_tags has them already
534- let newRefs = refsToAdd \- currentRefs
533+ let newRefs = refsToAdd \\ currentRefs
535534 mapM_ note_tags_add newRefs
536535 -- delete tags
537536 unless (null deleteTags) $
@@ -617,6 +616,3 @@ docIdToRef docId =
617616 case decodeDocId docId of
618617 Nothing -> error " Decode UUID from DocId failed. DocId is "
619618 Just (_, uid) -> ObjectRef uid
620-
621- (\-) :: (Eq a , Hashable a ) => HashSet a -> HashSet a -> HashSet a
622- (\-) = HashSet. difference
0 commit comments