Hacker News new | ask | show | jobs
by ParetoOptimal 1189 days ago
> @ParetoOptimal this is helpful in that haskell/ghc throws these error but how do you read the error message and how do you use it or infer next steps from the messages regarding the typed hole?

Basically it gives you a good starting point at least for what things make sense there. In some contexts though, it can lead you to the right answer when you didn't really have a clear idea provided you've honed some heuristics.

In the example above I:

1. Look at the type from this piece of the error: `Found hole: _ :: Int`. 2. I look at relevant hole fits, user defined functions in scope, and see if any of those belong from the `Relevant bindings` part of the error. 3. If not, I look to `Valid hole fits include` to find valid functions that may fit.

In step 3 however, there's a bit of pattern recognition because very polymorphic functions that never make any sense can sometimes show up there. `minBound` and `maxBound` fit for instance. Other things show up here that you can usually filter out as well such as `forever` when using holes in monad functions.

The above example was for the case where you have a high degree of confidence that there are no other errors. In general, type driven development hinges upon making one small change at a time and having only one type error at a time in your code.

That isn't as restrictive as it seems however, because you can always replace a problematic expression or function full of said expressions with (undefined :: TypeIWishThisExpressionRepresented).