0

It seems that the only way to document function parameters is to use the -- ^ docs here style. Unfortunately, this gets very unwieldy when function parameters are of different lengths. For example:

myFunc :: (Int -> String -> Bool -> IO ())   -- ^ documentation string #1
       -> Int    -- ^ documentation string #2
       -> String    -- ^ documentation string #3                         
       -> Bool   -- ^ documentation string #4
       -> IO ()   -- ^ documentation string #5

Converting the above to the following, takes a lot of manual effort:

myFunc :: (Int -> String -> Bool -> IO ())   -- ^ documentation string #1
       -> Int                                -- ^ documentation string #2
       -> String                             -- ^ documentation string #3                         
       -> Bool                               -- ^ documentation string #4
       -> IO ()                              -- ^ documentation string #5

Is there any automated way of doing this in Emacs? Or is there any other, more manageable way, of writing this documentation?

Drew
  • 29,895
  • 7
  • 74
  • 104
Saurabh Nanda
  • 6,373
  • 5
  • 31
  • 60

2 Answers2

4

It doesn't answer the question on how to automate alignment of comments, but when types become long, I usually rely on a different formatting style:

myFunc
    :: (Int -> String -> Bool -> IO ())
    -- ^ documentation string #1
    -> Int
    -- ^ documentation string #2
    -> String
    -- ^ documentation string #3                         
    -> Bool
    -- ^ documentation string #4
    -> IO ()
    -- ^ documentation string #5
Shersh
  • 9,019
  • 3
  • 33
  • 61
0

A simple way is using M-xalign-regex --. With a little more work, you could add an alignment rule in your haskell hook to align EOL comments (see align.el for examples), and then just align should do the trick.

Rorschach
  • 31,301
  • 5
  • 78
  • 129