Skip to content

Commit 056a349

Browse files
committed
Fix predictable order of fields
1 parent 69f65a4 commit 056a349

258 files changed

Lines changed: 3016 additions & 2877 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/haskell.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
# ghc-version: '8.10.7'
2727

2828
- name: Cache
29-
uses: actions/cache@v1
29+
uses: actions/cache@v4.2.3
3030
env:
3131
cache-name: cache-stack
3232
with:

ff-core/lib/FF.hs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import Data.HashMap.Strict (HashMap)
5454
import Data.HashMap.Strict qualified as HashMap
5555
import Data.HashSet (HashSet)
5656
import Data.HashSet qualified as HashSet
57-
import Data.Hashable (Hashable)
5857
import Data.List (genericLength, sortOn)
5958
import Data.List.NonEmpty (NonEmpty ((:|)))
6059
import 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.
121120
loadTagRefsByText ::
122-
(Foldable f, MonadStorage m) => f Text -> m (HashSet (ObjectRef Tag))
121+
(Foldable f, MonadStorage m) => f Text -> m (Set (ObjectRef Tag))
123122
loadTagRefsByText 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))
141140
createTags 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.
153152
getOrCreateTags ::
154-
(Foldable f, MonadStorage m) => f Text -> m (HashSet (ObjectRef Tag))
153+
(Foldable f, MonadStorage m) => f Text -> m (Set (ObjectRef Tag))
155154
getOrCreateTags 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

Comments
 (0)