Skip to content

Commit 69f65a4

Browse files
committed
Update
1 parent be4d2e2 commit 69f65a4

3 files changed

Lines changed: 13 additions & 18 deletions

File tree

ff-core/lib/FF.hs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ updateTrackedNotes newNotes = do
397397
cmdNewNote :: MonadStorage m => New -> Day -> m (EntityDoc Note)
398398
cmdNewNote New{text, start, end, isWiki, tags} today = do
399399
let start' = fromMaybe today start
400-
whenJust end $ assertStartBeforeEnd start'
400+
for_ end $ assertStartBeforeEnd start'
401401
(status, note_end, noteStart) <-
402402
case end of
403403
_ | not isWiki -> pure (TaskStatus Active, end, start')
@@ -504,7 +504,7 @@ cmdEdit edit input = case edit of
504504
fmap toList . for ids $ \nid ->
505505
modifyAndView nid $ do
506506
-- check text editability
507-
whenJust text $ const assertNoteIsNative
507+
for_ text $ const assertNoteIsNative
508508
-- check start and end editability
509509
when (isJust start || isJust end) $ do
510510
status <- note_status_read
@@ -519,14 +519,14 @@ cmdEdit edit input = case edit of
519519
<$> (start <|> curStart)
520520
<*> (end' <|> curEnd)
521521
end' = end >>= assignToMaybe
522-
whenJust newStartEnd $
522+
for_ newStartEnd $
523523
uncurry assertStartBeforeEnd
524524
-- update
525-
whenJust end $ \case
525+
for_ end $ \case
526526
Clear -> note_end_clear
527527
Set e -> note_end_set e
528-
whenJust start note_start_set
529-
whenJust text $ note_text_zoom . RGA.editText
528+
for_ start note_start_set
529+
for_ text $ note_text_zoom . RGA.editText
530530
-- add new tags
531531
unless (null addTags) $ do
532532
currentRefs <- HashSet.fromList <$> note_tags_read
@@ -580,7 +580,7 @@ note_status_setIfDiffer newStatus = do
580580
assertNoteIsNative :: (MonadE m, MonadObjectState Note m) => m ()
581581
assertNoteIsNative = do
582582
tracking <- note_track_read
583-
whenJust tracking $ \Track{track_url} ->
583+
for_ tracking $ \Track{track_url} ->
584584
throwErrorText $
585585
"A tracked note must be edited in its source"
586586
<> maybe "" (" :" <>) track_url
@@ -606,11 +606,6 @@ noDataDirectoryMessage :: String
606606
noDataDirectoryMessage =
607607
"Data directory isn't set, run `ff config dataDir --help`"
608608

609-
whenJust :: Applicative m => Maybe a -> (a -> m ()) -> m ()
610-
whenJust m f = case m of
611-
Nothing -> pure ()
612-
Just x -> f x
613-
614609
sponsors :: [Text]
615610
sponsors = ["Alexander Granin", "Nadezda"]
616611

ff-test/ff-test.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ test-suite ff-test
1818
github,
1919
hedgehog,
2020
interpolate,
21-
mtl,
2221
tasty,
2322
tasty-golden,
2423
tasty-hedgehog,

ff-test/test/Gen.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ noteStatus :: Gen NoteStatus
5858
noteStatus = choice [TaskStatus <$> status, pure Wiki]
5959

6060
track :: Gen Track
61-
track = Track
62-
<$> (Just <$> text (Range.linear 1 100) unicode)
63-
<*> (Just <$> text (Range.linear 1 100) unicode)
64-
<*> (Just <$> text (Range.linear 1 100) unicode)
65-
<*> (Just <$> text (Range.linear 1 100) unicode)
61+
track = do
62+
track_provider <- Just <$> text (Range.linear 1 100) unicode
63+
track_source <- Just <$> text (Range.linear 1 100) unicode
64+
track_externalId <- Just <$> text (Range.linear 1 100) unicode
65+
track_url <- Just <$> text (Range.linear 1 100) unicode
66+
pure Track{..}
6667

6768
status :: Gen Status
6869
status = enumBounded

0 commit comments

Comments
 (0)