lspitzner / brittany

haskell source code formatter
GNU Affero General Public License v3.0
690 stars 72 forks source link

Update datadecl branch #161

Closed eborden closed 4 years ago

eborden commented 6 years ago

I have rebased and fixed up the datadecl branch from the latest brittany master.

https://github.com/eborden/brittany/tree/datadecl

The rebase however makes opening a PR for this branch extremely noisy. I'm not sure how you'd like to proceed with merging it.

lspitzner commented 6 years ago

that's fine, i can pull the change without using github. will have a look later.

lspitzner commented 6 years ago

(the github PR interface of course, i still fetch from github..)

lspitzner commented 6 years ago

done. do you have an overview which data-decl aspects are finished? I assume GADTs are missing, and perhaps multiple-constructor records?

might be feasible/sensible to gradually add support. pattern-match/guard any things we don't support and use exactprint for those.

eborden commented 6 years ago

There is very little that is currently supported, just a simple implementation of records with multiple deriving clauses. I haven't had a chance to spend any more time on this, just trying to keep it up to date so I or someone else could possibly come back to it.

Current tests are:

#test single record
data Foo = Bar { foo :: Baz }

#test record multiple names
data Foo = Bar { foo, bar :: Baz }

#test record multiple types
data Foo = Bar
  { foo  :: Baz
  , bars :: Bizzz
  }

#test record multiple types and names
data Foo = Bar
  { foo, biz :: Baz
  , bar      :: Bizzz
  }

#test record multiple types deriving
data Foo = Bar
  { fooz :: Baz
  , bar  :: Bizzz
  }
  deriving Show

#test record multiple types deriving
data Foo = Bar
  { foo  :: Baz
  , bars :: Bizzz
  }
  deriving (Show, Eq, Monad, Functor, Traversable, Foldable)

#test record multiple deriving strategies
data Foo = Bar
  { foo  :: Baz
  , bars :: Bizzz
  }
  deriving Show
  deriving anyclass (Show, Eq, Monad, Functor)
  deriving newtype (Traversable, Foldable)

It is probably worth defining milestones in this project and determining where are seams are for shipping incremental improvements. Otherwise the monolith will never move.

tfausak commented 5 years ago

I would be very happy to get these changes merged into master and released, even if they only represent a subset for formatting data declarations.

https://github.com/lspitzner/brittany/compare/master...lspitzner:datadecl

Edit: Also somehow this issue isn't connected to #47 yet.

expipiplus1 commented 4 years ago

Is it possible to look at getting this merged before it bitrots again (hopefully it's not too late).

lspitzner commented 4 years ago

172866755cc43b49ad82521b6b2917bf08016173..00c6854887f3de22f5e036f652d6f16748a78be4 got merged in 434854f8f365c625a49604f9b1905cbe488acbb0. Those were rebased commits of the previous datadecl branch. Afaik, any existing data-decl work is on master by now.

This does not mean that all datadecls are formatted yet - I think we have not approached the multiple-constructor case. And there might be something unfortunate happening with GADTs atm, but I have not looked into it yet.

I'll close this. Let's use #47 to discuss the remaining items.

expipiplus1 commented 4 years ago

Thanks! I must have been using some ancient version.

andys8 commented 4 years ago

Awesome to see there is progress and the next release might include the feature :)