-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#22] Add contacts #96
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r1.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @willbasky)
ff-core/lib/FF.hs, line 204 at r1 (raw file):
-> Maybe Day -> Maybe Tracked -> m Note
?
ff-core/lib/FF.hs, line 209 at r1 (raw file):
noteText <- rgaFromText text noteStart <- LWW.initialize start noteEnd <- LWW.initialize end
?
ff-core/lib/FF/Options.hs, line 66 at r1 (raw file):
} newtype Contact = ContactShow (Maybe ContactCommand)
Show?
ff-core/lib/FF/Types.hs, line 57 at r1 (raw file):
data Contact = Contact { contactStatus :: LWW Status
Контакт не может быть вики.
ff-core/lib/FF/Types.hs, line 85 at r1 (raw file):
instance Semilattice Note instance Semilattice Contact
Лучше сгруппировать инстансы по типам, а не по классам.
ff-core/lib/FF/Types.hs, line 131 at r1 (raw file):
, csTotal :: Natural } deriving (Eq, Show)
Объедини в один тип с параметром, потому что всё одинаковое. Sample NoteView
, Sample ContactView
ff-core/lib/FF/Types.hs, line 205 at r1 (raw file):
{ cvId = contactId , cvStatus = LWW.query contactStatus , cvName = Text.pack $ RGA.toString contactName
rgaToText
ff-core/lib/FF.hs, line 204 at r1 (raw file): Previously, cblp (Yuriy Syrovetskiy) wrote…
? |
ff-core/lib/FF.hs, line 204 at r1 (raw file): Previously, willbasky (Vladislav Sabanov) wrote…
Длинно было. |
ff-core/lib/FF/Options.hs, line 66 at r1 (raw file):
показывает все контакты |
ff-core/lib/FF/Types.hs, line 57 at r1 (raw file): Previously, cblp (Yuriy Syrovetskiy) wrote…
А что значит тут вики? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @cblp and @willbasky)
ff-core/lib/FF/Options.hs, line 66 at r1 (raw file):
Previously, willbasky (Vladislav Sabanov) wrote…
ContactShow
показывает все контакты
Удалять — это тоже показывать?
ff-core/lib/FF/Types.hs, line 57 at r1 (raw file):
Previously, willbasky (Vladislav Sabanov) wrote…
А что значит тут вики?
У типа Status есть значение Wiki. Оно имеет смысл только для заметок, но не для контактов.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @willbasky)
ff-core/lib/FF/Options.hs, line 66 at r3 (raw file):
} newtype Contact = Contact (Maybe ContactCommand)
Бессмысленная обёртка. Можно в CmdContact
класть сразу Maybe ContactCommand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @willbasky)
ff-core/lib/FF/Types.hs, line 41 at r3 (raw file):
import FF.Types.Internal (noteJsonOptions) data StatusNote = Active | Archived | Deleted | Wiki
Как-то некрасивенько. Added и Removed имеют абсолютно такой же смысл, как Active и Deleted. И Archived тоже полезно бы иметь.
Предлагаю такое:
data Status = Active | Archived | Deleted
data Wiki = Wiki
...
, contactStatus :: Status
...
, noteStatus :: Either Wiki Status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @willbasky)
ff-core/lib/FF/Types.hs, line 41 at r3 (raw file):
Previously, cblp (Yuriy Syrovetskiy) wrote…
Как-то некрасивенько. Added и Removed имеют абсолютно такой же смысл, как Active и Deleted. И Archived тоже полезно бы иметь.
Предлагаю такое:
data Status = Active | Archived | Deleted data Wiki = Wiki ... , contactStatus :: Status ... , noteStatus :: Either Wiki Status
всё под LWW, конечно
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r4.
Reviewable status:complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @willbasky)
ff/Main.hs, line 179 at r4 (raw file):
cmdContact :: Maybe Contact -> Storage () cmdContact mCommand = case mCommand of
\case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r5.
Reviewable status:complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r6.
Reviewable status:complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r7.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @willbasky)
ff-core/lib/FF/Types.hs, line 54 at r7 (raw file):
where st = case ns of TaskStatus s -> show s
s/show/toJSON/
ff-core/lib/FF/Types.hs, line 55 at r7 (raw file):
st = case ns of TaskStatus s -> show s _ -> show Wiki
вместо _ лучше явно написать Wiki для устойчивости к будущим изменениям
ff-core/lib/FF/Types.hs, line 59 at r7 (raw file):
instance FromJSON NoteStatus where parseJSON = withText "NoteStatus" $ \x -> do let s = case x of
можно не вводить s, а сразу написать return $ case ...
ff-core/lib/FF/Types.hs, line 64 at r7 (raw file):
"Archived" -> TaskStatus Archived "Deleted" -> TaskStatus Deleted _ -> error "Not NoteStatus type"
s/error/fail/
ff-core/lib/FF/Types.hs, line 65 at r7 (raw file):
"Deleted" -> TaskStatus Deleted _ -> error "Not NoteStatus type" return s
s/return/pure/
ff-test/test/ArbitraryOrphans.hs, line 25 at r7 (raw file):
instance Arbitrary NoteStatus where arbitrary = TaskStatus <$> arbitrary
такой генератор никогда не сгенерит Wiki
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @willbasky)
ff-core/lib/FF/Types.hs, line 63 at r7 (raw file):
"Active" -> TaskStatus Active "Archived" -> TaskStatus Archived "Deleted" -> TaskStatus Deleted
эти 3 строчки можно сократить до TaskStatus <$> parseJSON v
ff-core/lib/FF/Types.hs, line 54 at r7 (raw file): Previously, cblp (Yuriy Syrovetskiy) wrote…
Что означает такой комментарий? |
ff-core/lib/FF/Types.hs, line 63 at r7 (raw file):
Тогда будет ошибка
|
ff-core/lib/FF/Types.hs, line 63 at r7 (raw file):
Ок, даже если заменить, то откуда брать
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 8 of 10 files reviewed, 6 unresolved discussions (waiting on @cblp and @willbasky)
ff-core/lib/FF/Types.hs, line 54 at r7 (raw file):
Previously, willbasky (Vladislav Sabanov) wrote…
Что означает такой комментарий?
заменить одно на другое
ff-core/lib/FF/Types.hs, line 53 at r8 (raw file):
toJSON = \case TaskStatus s -> toJSON s Wiki -> toJSON Wiki
зависнет. вот здесь как раз настоящую реализацию надо написать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 8 of 10 files reviewed, 3 unresolved discussions (waiting on @cblp and @willbasky)
ff-core/lib/FF/Types.hs, line 63 at r7 (raw file):
Previously, willbasky (Vladislav Sabanov) wrote…
v
Ок, даже если заменить, то откуда брать
v
обощенную и именно содержащую нужные строки, а не любые? Я сделал так сейчасinstance FromJSON NoteStatus where parseJSON = withText "NoteStatus" $ \case "Wiki" -> parseJSON "Wiki" "Active" -> TaskStatus <$> parseJSON "Active" "Archived" -> TaskStatus <$> parseJSON "Archived" "Deleted" -> TaskStatus <$> parseJSON "Deleted" _ -> fail "Not NoteStatus type"
попробуй parseJSON v = TaskStatus <$> parseJSON v
и подумай, куда здесь вставить Wiki
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r8.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @willbasky)
ff-test/test/ArbitraryOrphans.hs, line 25 at r8 (raw file):
instance Arbitrary NoteStatus where arbitrary = oneof [TaskStatus <$> arbitrary, arbitrary]
arbitrary @NoteStatus
вызывает arbitrary @Status
, а потом arbitrary @NoteStatus
, то есть себя. зависнет
ff-test/test/ArbitraryOrphans.hs, line 25 at r7 (raw file): Previously, cblp (Yuriy Syrovetskiy) wrote…
А каким образом складывать
|
ff-test/test/ArbitraryOrphans.hs, line 25 at r7 (raw file): Previously, willbasky (Vladislav Sabanov) wrote…
так тоже виснит
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @cblp and @willbasky)
ff-test/test/ArbitraryOrphans.hs, line 25 at r7 (raw file):
Previously, willbasky (Vladislav Sabanov) wrote…
так тоже виснит
arbitrary = oneof [TaskStatus <$> arbitrary, pure Wiki]
Оба варианта правильные, зависает в другом месте.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @willbasky)
ff-core/lib/FF/Types.hs, line 144 at r8 (raw file):
deriving (Eq, Show) type SampleContact = Sample ContactView
ContactSample
ff-core/lib/FF/Types.hs, line 146 at r8 (raw file):
type SampleContact = Sample ContactView type SampleNote = Sample NoteView
NoteSample
ff-core/lib/FF/Types.hs, line 179 at r8 (raw file):
taskMode :: Day -> NoteView -> TaskMode taskMode today NoteView { start, end } = case end of
лишние изменения в форматировании. прогнал brittany?
ff-core/lib/FF/Types.hs, line 181 at r8 (raw file):
taskMode today NoteView { start, end } = case end of Nothing | start <= today -> Actual | otherwise -> starting start today
лишние изменения в форматировании. прогнал brittany?
ff-core/lib/FF/UI.hs, line 116 at r8 (raw file):
, ["| end" <+> pshow @Day e | Just e <- [end]] ] ++ [ "| tracking" <+> strictText trackedUrl
лишние изменения в форматировании. прогнал brittany?
ff-test/test/ArbitraryOrphans.hs, line 4 at r8 (raw file):
module ArbitraryOrphans ()
лишние изменения в форматировании. прогнал brittany?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @cblp and @willbasky)
ff-test/test/ArbitraryOrphans.hs, line 25 at r7 (raw file):
Previously, cblp (Yuriy Syrovetskiy) wrote…
Оба варианта правильные, зависает в другом месте.
я даже написал комментарий о зависании в том месте
ff-core/lib/FF/Types.hs, line 179 at r8 (raw file): Previously, cblp (Yuriy Syrovetskiy) wrote…
нее, это stylish-haskell шалил. |
ff-core/lib/FF/UI.hs, line 116 at r8 (raw file): Previously, cblp (Yuriy Syrovetskiy) wrote…
не вижу, где тут? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @willbasky and @cblp)
ff-core/lib/FF/UI.hs, line 116 at r8 (raw file):
Previously, willbasky (Vladislav Sabanov) wrote…
не вижу, где тут?
ff-core/lib/FF/Types.hs, line 53 at r8 (raw file): Previously, cblp (Yuriy Syrovetskiy) wrote…
По какой причине здесь зависает? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @willbasky and @cblp)
ff-core/lib/FF/Types.hs, line 53 at r8 (raw file):
Previously, willbasky (Vladislav Sabanov) wrote…
По какой причине здесь зависает?
toJSON Wiki
вычисляется через toJSON Wiki
, то есть через себя
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r9.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @willbasky)
ff-core/lib/FF/Types.hs, line 52 at r9 (raw file):
instance ToJSON NoteStatus where toJSON (TaskStatus a) = toJSON a toJSON _ = String "Wiki"
Следует явно указать Wiki в аргументе для определённости и устойчивости к будущим изменениям (future-proof)
ff-core/lib/FF/Types.hs, line 57 at r9 (raw file):
parseJSON v = case v of "Wiki" -> pure Wiki _ -> TaskStatus <$> parseJSON v
Идеально!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @willbasky)
ff-core/lib/FF/Types.hs, line 52 at r9 (raw file):
Previously, cblp (Yuriy Syrovetskiy) wrote…
Следует явно указать Wiki в аргументе для определённости и устойчивости к будущим изменениям (future-proof)
Ещё мне больше нравится \case, но это вкусовщина, можно и так оставить.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r10.
Reviewable status:complete! all files reviewed, all discussions resolved
Resolves #22
This change is