1

I want to have the following functionality on a save hook.

Given a buffer that has type signatures like this…

add :: Integer -> Integer -> Integer
add x y = x + y

…I want to have them reformatted to the following:

add
  :: Integer
  -> Integer
  -> Integer
add x y = x + y

As far as I can tell stylish-haskell does not have this functionality. What are my options?

5
  • 1
    What's the use case? That Haskell code is highly idiosyncratic. – Tianxiang Xiong Apr 24 '17 at 22:39
  • I agree, but I am collaborating with people who prefer multi-line type signatures, and I keep forgetting to format them manually. – Matthew Piziak Apr 24 '17 at 22:42
  • 1
    @TianxiangXiong What do you think is so idiosyncratic about it? In my experience multi-line type signatures are not that uncommon; if anything they make complicated type signatures much clearer to read and easier to annotate with, say, haddock. The only thing that stands out to me is the :: starting on a new line. Here's a module from a popular Haskell project with several such examples: github.com/xmonad/xmonad/blob/master/src/XMonad/… – Basil May 11 '17 at 18:05
  • You do it to break up a long line, as you would any piece of code. It's not the standard. – Tianxiang Xiong May 11 '17 at 18:08
  • 1
    @TianxiangXiong That short lines do not need splitting does not make splitting long lines non-standard or idiosyncratic. – Basil May 11 '17 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.