hindent icon indicating copy to clipboard operation
hindent copied to clipboard

Consider using `ghc-lib-parser` instead of `haskell-src-exts`

Open toku-sa-n opened this issue 2 years ago • 3 comments

Completed checklist

  • [x] I've checked the issue tracker for similar issues.
  • [x] I am not creating an issue about adding more configuration options for the styling/layout of hindent, because hindent is not about customizing style.

Problem description

haskell-src-exts does not implement some extensions, and unfortunately, it does not seem to be maintained.

For example, we cannot use hindent with the OverloadedRecordDot extension.

hindent app/Lib.hs with this .hindent.yaml cannot convert the following code.

{-# LANGUAGE OverloadedRecordDot #-}
data Rectangle =
  Rectangle
    { width  :: Int
    , height :: Int
    }

area :: Rectangle -> Int
area r = r.width * r.height
extensions:
  - OverloadedRecordDot
% hindent app/Lib.hs
hindent: AesonException "Error in $: Unknown extension: OverloadedRecordDot"
CallStack (from HasCallStack):
  error, called at src/main/Main.hs:88:19 in main:Main

KnownExtension lacks the extension.

Proposed solution

I think that replacing haskell-src-exts with ghc-lib-parser is one of the options to solve the problem. It is maintained, and other projects (e.g., hlint and stylish-haskell) use it. Also, haskell-src-exts' readme suggests the use of it.

Alternatives

Taking over the maintenance of the library is another option.

toku-sa-n avatar Jun 28 '22 02:06 toku-sa-n

Interesting. I was a little bit out of the loop, but I think it is a good idea.

mihaimaruseac avatar Jul 07 '22 02:07 mihaimaruseac

I'm currently rewriting hindent with ghc-lib-parser. Once I complete it, I'll submit a PR.

toku-sa-n avatar Jul 08 '22 02:07 toku-sa-n

Awesome. Please CC me on the PR so it raises to the top of my notifications.

Thank you for working on it!

mihaimaruseac avatar Jul 08 '22 15:07 mihaimaruseac