optparse-applicative icon indicating copy to clipboard operation
optparse-applicative copied to clipboard

[feat] allow passing list literals to mod builders

Open MangoIV opened this issue 1 year ago • 5 comments

I have found myself writing things like strOption $ mconcat [... quite often and upon discussion, @Qqwy suggested just using list literals, this PR implements this idea, it works like a charm. the IsList instance even respects its laws!

It allows writings things like

... prefs [shoHelpOnEmpty, showHelpOnError] 
... strOption [long "bla", short 'b']

etc

MangoIV avatar May 24 '24 14:05 MangoIV

That's an interesting approach.

I try to keep optparse-applicative very conservative with regards to its extensions (we're just Haskell 98 + Existential Types at the moment), so I don't think it's very likely this will be merged as is.

But I'll keep this open now so it can be discussed further.

HuwCampbell avatar May 27 '24 03:05 HuwCampbell

well the extension is required to write the instance, it’s not that I’m making excessive use of TypeFamilies, unfortunately there’s no other good place for this to go, orphan instances are sad :(

Alright, let’s see :)

MangoIV avatar May 27 '24 05:05 MangoIV

@HuwCampbell would you be happy to exclude the change from older GHC by the use of CPP or would that be too much of a complexity increase?

MangoIV avatar May 28 '24 14:05 MangoIV

@HuwCampbell what kind of improvements could I do to this PR such that it can be merged?

MangoIV avatar Jun 19 '24 09:06 MangoIV

Look, I'm not sure right now. While it's a minor inconvenience to add mconcat, and I do think that it's probably a better API to accept a list.

But unfortunately I don't think I can't make breaking changes like that in the next release.

HuwCampbell avatar Jul 09 '24 09:07 HuwCampbell