Support (layouting) config inline/pragma-style #30
Labels
No Label
blocked: dependency
blocked: info-needed
bug
duplicate
enhancement
fixed in HEAD
help wanted
hs:arrows
hs:brackets
hs:classes
hs:comments
hs:do-notation
hs:guards
hs:lists
hs:operators
hs:patterns
hs:records
hs:types
invalid
language extension support
layouting
needs confirmation
priority: high
priority: low
question
revisit before next release
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: hexagoxel/brittany#30
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
In some cases I noticed that per-file config is desirable, or even more fine-grained control ("leave this function/block alone" etc.)
This is mildly easy to implement, but I could use feedback regarding the interface design: What kind of pragma to use. I see the following options:
Use real pragma
This pretends to be a real pragma, and ghc will promptly warn about it being unknown.
Can be disabled, but its annoying and I dislike this option.
Note that haddock uses these, due to haddock being wired into ghc, as I understand
it.
Use fake pragma
As I have gathered from the archives Haddock used this option earlier.
Use ANN feature
This is a "proper" approach to annotating the whole module or single functions.
While this option is closer to "standard" syntax for the purpose, it has some annoying
downside: The above pragma can not be placed as freely as one might think (and the
errors you get are rather confusing). For example, you cannot move it above the header
("module Foo where"), below any
LANGUAGE
pragmas.Use something based on raw comments, like
Opinions/Arguments?
This is an awesome idea.
I would prefer the fourth option with normal comments. It matches what I'm used to from other languages. For example, Ruby's RuboCop uses comments for this: http://rubocop.readthedocs.io/en/latest/configuration/#disabling-cops-within-source-code
Yea I think the choices are between options 3 and 4 for me. I'd lean toward option 3, but I'd have to know more about its limitations on placement, and what exactly it would look like in practice
I like option 4. I've used annotations and they are powerful, but they are also very noisy.
I went with 4 for now, mostly due to laziness on my part, and because it is not possible to express everything we may want with ANNs anyway: There is no way to annotate instances, while
-- BRITTANY @ vvv --flag=value
will work for those - even when we don't support instances yet.If you mess up the syntax after a
-- BRITTANY
commentbrittany
will error out. Perhaps a warning is more appropriate.Implementing the per-binding version will require a slightly different implementation or changes to
butcher
to make it parse an arbitrary "command".Btw the exact syntax (i.e. "@" and "vvv") are of course still open for discussion.
@lspitzner So this will enable easier testing via tweaking individual layout options per test?
yes. e.g. we now can add
to
tests.blt
and it succeeds.On the one hand having to specify the config per-testcase might become redundant, but the upside is that all tests remain self-contained.
Should probably add support for more than one
*.blt
file though; 133 cases in one file is becoming unwieldy.Bike shedding syntax for a second: I'm not crazy about
-- BRITTANY @ vvv ...
for annotating the next declaration. ESLint has a lot of ways to control it through comments: https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-commentseslint-disable
/eslint-enable
: Globally disables/enables ESLint. Similar to a block comment. Useful for ignoring entire sections of code.eslint-disable-line
: Disables ESLint on the current line. Useful for ignoring one or two things on short lines.eslint-disable-next-line
: Disables ESLint on the next line. Useful for ignoring lots of stuff on long lines.Each comment also takes a list of options for disabling particular linters, like
eslint-disable foo, bar
.Translating that to Brittany, I would like to see something like:
-- brittany-next-declaration --indent=4
. That way it's crystal clear just from reading the comment what's going on.I am not too keen on implementing the per-region version. It seems to be a bit more "stateful" than the other kinds, and seems to have more special cases. But I wouldn't be opposed if someone did a PR :-)
-- brittany-next-declaration --indent=4
is indeed nicer, and-- brittany-disable-next-declaration
is nice too - I had not really considered the "disabling" part yet.It might also be nice to specify
YAML
paths instead of command line args. That way configuration files and inline declarations remain consistent.make that
and the payload is a valid YAML document, so the existing parser can be used just like I reused the commandline config parser.
That sounds fantastic to me!
see #136
Closed in
caeb42c020
. If anything is not working as expected, please tell.