Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unit return types #1386

Closed
1 of 2 tasks
JorgeCastilloPrz opened this issue Mar 28, 2019 · 4 comments · Fixed by #1500
Closed
1 of 2 tasks

Unit return types #1386

JorgeCastilloPrz opened this issue Mar 28, 2019 · 4 comments · Fixed by #1500
Assignees

Comments

@JorgeCastilloPrz
Copy link
Member

JorgeCastilloPrz commented Mar 28, 2019

When you're writing code in an FP manner, you want to keep all effects under control. Functions that return Unit are effectful by definition, since otherwise they'd do nothing. On their bodies, they always access the external world, as in printing, logging, network queries, database reads / writes, modifying the value of class properties... etc.

Action points

  • The redundant Unit return type is an IntellIJ IDEA Inspection. Unit return types are never redundant from an FP perspective, since they make function "referentially transparent". The function states what's it doing by looking at it's input and output types, so best thing we can do is to give feedback to Arrow users about how to disable it in README and "Quick start" docs section as also suggested for Redundant suspend modifiers #1385. Also include a link to the official intention action docs.

Screenshot 2019-03-28 at 12 07 22

  • Apart from the IntellIJ IDEA Inspection, Ktlint also complaints about Unit return types regardless of where they're used. That's also something we could suggest users how to disable on their ktlint configurations, since from an FP perspective it's always important to declare return types regardless of what they are, so it's explicit that the function has side effects inside.
@JorgeCastilloPrz JorgeCastilloPrz self-assigned this Mar 28, 2019
@pakoito
Copy link
Member

pakoito commented Mar 28, 2019

I'd suggest reaching out to twitter to see if someone is interested in owning this space.

@JorgeCastilloPrz JorgeCastilloPrz changed the title Arrow Linting Unit return types Mar 28, 2019
@JorgeCastilloPrz
Copy link
Member Author

@Tylos will tackle this during next quarter.

@Tylos
Copy link
Contributor

Tylos commented Jul 1, 2019

Opening PR to document how to disable the check for IDEA

Ktlint is still pending until certain rules can be disabled. It is currently in PR - pinterest/ktlint#503

Should it be moved to a separated issue @JorgeCastilloPrz ?

@JorgeCastilloPrz
Copy link
Member Author

JorgeCastilloPrz commented Jul 1, 2019

Yep it'd be nice if we can add an issue for it then create a Marlow goal. As soon as support for disabling global rules is released to ktlint it'll be an easy one to tackle.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants