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

Documentation for the Invariant typeclass #710

Merged
merged 1 commit into from
Dec 3, 2015

Conversation

markus1189
Copy link
Contributor

Adds a tut section about Invariant as discussed in #164. I oriented the explanation according to @ceedubs example, I hope this is okay.

I wasn't able to test the jekyll serve because it fails on my pc due to a missing ruby dependency, so I am not sure if adding the file is enough to make it show up on the typeclasses site? If someone could check that that'd be great :).

If merged this fixes #164.

-- 24pullrequests

@codecov-io
Copy link

Current coverage is 85.06%

Merging #710 into master will increase coverage by +0.05% as of 6174f09

@@            master    #710   diff @@
======================================
  Files          162     162       
  Stmts         2229    2229       
  Branches        74      74       
  Methods          0       0       
======================================
+ Hit           1895    1896     +1
  Partial          0       0       
+ Missed         334     333     -1

Review entire Coverage Diff as of 6174f09

Powered by Codecov. Updated on successful CI builds.

@ceedubs
Copy link
Contributor

ceedubs commented Dec 2, 2015

Thanks! Looks good at a first glance. I'll take a more detailed look.

---
# Invariant

The `Invariant` typeclass is for `Functor`s that define an `imap`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably be careful with wording here. In Cats, Functor means covariant functor. To me, this sentence makes it sound like Invariant is a subtype of Functor, while it's actually the other way around. This may be solved by just changing Functor to a generic "functor". That could potentially also be confusing to people who think that Functor and "functor" would be synonymous. It may be fine though.

@markus1189 markus1189 force-pushed the tut-invariant branch 2 times, most recently from 620b971 to d3bf613 Compare December 2, 2015 20:48
@markus1189
Copy link
Contributor Author

Added a full example at the end ;)

Semigroup[Long].imap(longToDate)(dateToLong)

val today: Date = longToDate(1449088684104l)
val timeLeft: Date = longToDate(1900918893l)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the spirit of the work that has just been done for #709, maybe we should put all but the last line of this into a tut:silent shed, and just use tut (with output) for the today |+| timeLeft. The output for imports, etc is pretty noisy.

@markus1189 markus1189 force-pushed the tut-invariant branch 2 times, most recently from f53d72f to 4425621 Compare December 2, 2015 21:25
@markus1189
Copy link
Contributor Author

I added two versions of the import, the version that imports all the stuff and a commented out version that is more explicit. @mikejcurry good catch for the typo :)

@ceedubs
Copy link
Contributor

ceedubs commented Dec 3, 2015

I ran jekyll serve locally and the Invariant type class auto-populated in the links and looks good. 👍 thanks!

@adelbertc
Copy link
Contributor

👍

adelbertc added a commit that referenced this pull request Dec 3, 2015
Documentation for the `Invariant` typeclass
@adelbertc adelbertc merged commit 51cc5d8 into typelevel:master Dec 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add better documentation for Invariant
5 participants