Skip to content

docs: improve Func and AppFunc documentation - #4890

Open
mmustafasenoglu wants to merge 2 commits into
typelevel:mainfrom
mmustafasenoglu:docs/func-documentation
Open

docs: improve Func and AppFunc documentation#4890
mmustafasenoglu wants to merge 2 commits into
typelevel:mainfrom
mmustafasenoglu:docs/func-documentation

Conversation

@mmustafasenoglu

Copy link
Copy Markdown

Summary

Improves the documentation for Func and AppFunc data types, which previously had minimal scaladoc (2 lines linking to a 25-page Haskell paper) and no website documentation.

Motivation

The issue #2650 was opened by @tpolecat in 2018 noting that "Nobody knows what the hell Func does." This PR addresses that by adding comprehensive documentation.

Changes

  • core/src/main/scala/cats/data/Func.scala: Expanded scaladoc for Func, AppFunc, and all public methods with examples
  • docs/datatypes/func.md (new): Website documentation page explaining:
    • Kleisli vs Func (sequential vs parallel composition)
    • Usage examples with product, compose, andThen, traverse
    • Type class instances
    • When to use Func vs Kleisli
  • docs/datatypes/directory.conf: Added func.md to navigation

Testing

  • Documentation compiles with mdoc
  • No code changes (documentation only)

Closes #2650

The existing scaladoc for Func was only 2 lines and linked to a 25-page
Haskell paper. This adds comprehensive documentation explaining:

- What Func is and how it differs from Kleisli
- The distinction between sequential (Kleisli) and parallel (Func) composition
- Usage examples with AppFunc (product, compose, andThen, traverse)
- A new website documentation page (docs/datatypes/func.md)
- Type class instances overview

Closes typelevel#2650
Copilot AI review requested due to automatic review settings August 2, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

* scala> val double: Func[Option, String, Double] = Func.func(s => scala.util.Try(s.toDouble).toOption)
*
* scala> // Compose in parallel: parse and double the same input independently
* scala> val combined: Func[Option, String, (Int, Double)] = parseInt.product(double)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't really parse and double the input, it parses it into both Int and Double simultaneously.

@mmustafasenoglu

Copy link
Copy Markdown
Author

Good catch, fixed the comment wording! Now it says "parse the same input into both Int and Double simultaneously" instead of the misleading "parse and double".

@mmustafasenoglu

Copy link
Copy Markdown
Author

Good catch, thanks! The wording was ambiguous since is both the variable name and a verb. Updated to clarify that it parses the input into both types simultaneously.

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.

Improve doc for Func

3 participants