unisonweb/unison

unhelpful error message when you forget to delay a function using an ability

Open

#641 opened on Aug 3, 2019

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Haskell (304 forks)batch import
error-messagehelp wanted

Repository metrics

Stars
 (6,624 stars)
PR merge metrics
 (Avg merge 12d 19h) (6 merged PRs in 30d)

Description

Need a better error message for a common error case involving straightforward use of abilities.

Spot my mistake...

ability GetTime where
  systemTime : .base.io.EpochTime

test = GetTime.systemTime

Here's a clue:

  The expression in red needs the {GetTime} ability, but this location does not have access to any abilities.
  
      4 | test = GetTime.systemTime
  

.> 

What do you mean that didn't help?! :-)

My definition should have been:

test _ = GetTime.systemTime

Note the underscore. (Then the type is correctly inferred to be '{GetTime} .base.io.EpochTime.) (Or the definition could be test = 'GetTime.systemTime.)

This is going to be a common error case: it's not very intuitive that test needs to take a unit argument just because it happens to be using an ability. Someone would hit this trying to write function that prints 'hello world' to screen.

(M1a)

Contributor guide