Skip to content

Conversation

@ChrisPenner
Copy link
Member

@ChrisPenner ChrisPenner commented Apr 25, 2025

Overview

Uses heuristics to detect function over and under application and provide better information on how to fix it.

Under-applied:

main : 'Nat
main = do
  multiply x y = x Nat.* y
  add x y = x Nat.+ y
  doMath x y = add (multiply x y)
  doMath 3 4

Before:
image

After:
image

And a case where a function is over-applied.

main2 : 'Nat
main2 = do
  multiply x y = x Nat.* y
  add x y = x Nat.+ y
  doMath x y = add (multiply x y) 2 3
  doMath 3 4

Before
image

After
image

Implementation notes

  • Pretty small tweak to the typechecker which checks function arities on mismatched types and specializes the selected error message.
  • New arity function which ignores effects for this purpose
  • New error message formatting
  • new transcripts

Interesting/controversial decisions

There may be cases where this is incorrect, but I think the benefit is worth that risk, we can dogfood it and tweak or roll-back as needed.

Test coverage

See new transcripts

@pchiusano
Copy link
Member

Wow, awesome!!!

@ChrisPenner ChrisPenner force-pushed the cp/function-errors branch from 0afcd23 to d35c9c5 Compare May 2, 2025 17:58
@ChrisPenner ChrisPenner marked this pull request as ready for review October 31, 2025 22:18
@ChrisPenner ChrisPenner requested a review from aryairani October 31, 2025 22:18
@ChrisPenner ChrisPenner changed the base branch from trunk to cp/change-comments-sync November 3, 2025 23:42
@ChrisPenner ChrisPenner changed the base branch from cp/change-comments-sync to trunk November 3, 2025 23:42
@aryairani aryairani merged commit 2ac5899 into trunk Nov 4, 2025
32 checks passed
@aryairani aryairani deleted the cp/function-errors branch November 4, 2025 17:55
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.

4 participants