Skip to content
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

Merged
merged 4 commits into from
Oct 13, 2018
Merged

Create doctests for Colog.Core.Action #61

merged 4 commits into from
Oct 13, 2018

Conversation

cronokirby
Copy link
Collaborator

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 as mempty, so defined the former
via the latter to avoid code duplication.

@chshersh chshersh added package:co-log-core For: co-log-core doc tests Hacktoberfest https://hacktoberfest.digitalocean.com/ log-action Everything related to LogAction data type labels Oct 12, 2018
@chshersh chshersh added this to In progress in #2: Hacktoberfest (October, 2018) via automation Oct 12, 2018
Copy link
Contributor

@chshersh chshersh left a 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

-- | Operator version of 'cmap'.
{- | Operator version of 'cmap'.

>>> logString = LogAction putStrLn
Copy link
Contributor

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

Copy link
Collaborator Author

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?

Copy link
Contributor

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:

https://github.com/kowainik/relude/blob/9e3aa751851b5a4d4301119c9053275e520fb977/src/Relude/String/Conversion.hs#L62-L64

Even if Relude imports Relude.String.Conversion, it's still okay to import Relude in the comments.

Copy link
Collaborator Author

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
Copy link
Contributor

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

Copy link
Collaborator Author

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?

Copy link
Contributor

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 👍

-- | @conquer@ combinator from @Divisible@ type class.
{- | @conquer@ combinator from @Divisible@ type class.

Concretely, this is a logAction that does nothing:
Copy link
Contributor

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.
#2: Hacktoberfest (October, 2018) automation moved this from In progress to Reviewer approved Oct 13, 2018
Copy link
Contributor

@chshersh chshersh left a 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!

@chshersh chshersh merged commit 7696436 into co-log:master Oct 13, 2018
#2: Hacktoberfest (October, 2018) automation moved this from Reviewer approved to Done: PR's Oct 13, 2018
@chshersh chshersh removed this from Done: PR's in #2: Hacktoberfest (October, 2018) Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Hacktoberfest https://hacktoberfest.digitalocean.com/ log-action Everything related to LogAction data type package:co-log-core For: co-log-core tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants