Monday, May 16, 2016

[szamjfab] Error messages and documentation for FTP

One of the criticisms of the Foldable/Traversable Proposal (FTP) in Haskell is that error messages get more confusing and documentation gets harder to understand.  Both of these problems could be addressed with improvements to tools.

Errors when calling a polymorphic function with a Foldable or Traversable context could have additional text repeating what the error message would be if the function were specialized to lists.

Haddock could generate additional documentation for a polymorphic function with Foldable or Traversable context: generate, as documentation, what the type signature would be if the function were specialized to lists.  Or, the type variable could be named (renamed) "list":

mapM :: (Traversable list, Monad m) => (a -> m b) -> list a -> m (list a)

1 comment :

Francesco said...

I agreed with Neil Mitchell on FTP and with other points raised by Henning Thielemann, such as length (1,2) now type-checking and evaluating to 1 not being a good idea (encourages bad coding style, surprising for a beginner, doesn't catch what's in 100% of cases an error at compile time).

But the ship, alas, has sailed and I see little point in devising crutches now: would the proposed additional documentation be integrated in haddock? How about error where suggesting List is wrong or misleading? How many man-hours to design/debate/flame/vote/implement/maintain this?

In the end, I think as a community we made a decision and we need to embrace it. Haskell has become a little bit more complex and a little bit more quirky; yes this makes the learning curve steeper but that's what it is, better for everyone to get acquainted to read signatures with 'f' and 't'.

I stop here because it would be too long for a comment, but I do believe (regardless of FTP), having worked with beginners, that a 'table-like' error output (like Hugs), would be more palatable than what GHC currently prints.