-
Notifications
You must be signed in to change notification settings - Fork 49
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
Create doctests for Colog.Core.Action
#61
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.
Thanks for these useful documentation examples! This really helps the quality of the library. I have couple comments though
co-log-core/src/Colog/Core/Action.hs
Outdated
-- | Operator version of 'cmap'. | ||
{- | Operator version of 'cmap'. | ||
|
||
>>> logString = LogAction putStrLn |
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.
I think it's better to use logStringStdout
from Colog.Core.IO
module
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.
This would require a cyclic dependency, since Core.IO depends on Core.Action. Or are you suggesting to reuse the name from Core.IO for clarity?
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.
@cronokirby cyclic dependency is not a problem, because doctest
has it's own $setup
comment to import other modules. See this module in relude
for example:
Even if Relude
imports Relude.String.Conversion
, it's still okay to import Relude
in the comments.
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.
Good to know!
{- | @divide@ combinator from @Divisible@ type class. | ||
|
||
>>> logString = LogAction putStrLn | ||
>>> logInt = LogAction print |
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.
Btw, LogAction print
looks like a good addition to the Colog.Core.IO
module
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.
Should I go ahead and add this in this pr, or should we open an issue?
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.
@cronokirby I think separate issue is better 👍
co-log-core/src/Colog/Core/Action.hs
Outdated
-- | @conquer@ combinator from @Divisible@ type class. | ||
{- | @conquer@ combinator from @Divisible@ type class. | ||
|
||
Concretely, this is a logAction that does nothing: |
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.
Instead of logAction
it's better to write 'LogAction'
to convert it into link
Allows us to reuse functions we provide instead of handwriting them in each example. Requires adding a few lines at the top of the module to setup the import of Core.IO.
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.
Okay, this looks super useful!
Resolves #58.
Expands the documentation for functions, by adding documentation tests.
There were cases in which a function was heavily documented with an example that wasn't tested, e.g.
using a combinator to log both to files and stdout; in those cases I didn't change them. In the cases
where a combinator / function was just a flipped version or synonym of another, I also didn't document any more, as I felt this was redundant.
I also noticed that
conquer
had the same implementation asmempty
, so defined the formervia the latter to avoid code duplication.