lspitzner / lspitzner/brittany

Format class declarations

Open
#236 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement hs:classes
Dominant language
Haskell
Stars
686
Forks
69
PR merge metrics
No merged PRs in 30d

Description

Brittany does not currently format type class declarations. Instead it simply passes them through. That's fine for a lot of cases because defining new type classes is less common than adding instances. Also type classes often aren't very complicated syntactically, so it's not too burdensome to format them by hand. All that being said, it would be great if Brittany could format them. For example, consider this type class declaration:

-- brittany --columns 20
class SomeVeryLongConstraint => SomeVeryLongTypeClass someVeryLongTypeName where
 someVeryLongMethodName :: someVeryLongTypeName -> someVeryLongTypeName
 someVeryLongMethodName someVeryLongVariableName = someVeryLongVariableName

I chose 20 columns arbitrarily in order to force the layout onto multiple lines. Otherwise the result isn't super interesting.

I'm not exactly sure how I'd like that to be formatted, but maybe something like this?

class
  SomeVeryLongConstraint
  => SomeVeryLongTypeClass
     someVeryLongTypeName
 where
  someVeryLongMethodName
    :: someVeryLongTypeName
    -> someVeryLongTypeName
  someVeryLongMethodName someVeryLongVariableName
    = someVeryLongVariableName

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Brittany's handling of type class declarations and its existing layout rules for related declarations. Use the issue's 20-column example as the formatting target; done means type class declarations are formatted rather than passed through, with a consistent constrained layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.