[Haskell-cafe] Formatting function types

Henning Thielemann lemming at henning-thielemann.de
Thu Dec 30 15:17:21 CET 2010


On Thu, 30 Dec 2010, Lauri Alanko wrote:

> Even nowadays, Haddock deliberately generates the following layout for
> long function types:
>
> openTempFile
>    :: FilePath
>    -> String
>    -> IO (FilePath, Handle)
>
> The layout draws special attention to the first argument type, whereas
> the other argument types are indistinguishable from the return
> type. The following is much clearer:
>
> openTempFile ::
>    FilePath ->
>    String ->
>    IO (FilePath, Handle)
>
> (Possibly with the arrows aligned.)

+1


GHC also formats type signatures in errors and warnings in the misleading 
way.

In case of Haddock comments I understand that the comment must be close to 
the argument type. That is

openTempFile
    FilePath -- ^ filename, of course  ->
    String ->
    IO (FilePath, Handle)

would not work. But {- ^ filename -} would work.



More information about the Haskell-Cafe mailing list