lspitzner / lspitzner/brittany
Nonoptimal layouting in complex expression with default config
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 686
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
This sample code:
ugebe gdac _ekaz (NtizUbq sysn cekoed gagwwau, FdrnAqsAmnu njiuZqanacpoYbx) =
M.egDuyz cekoed <&> \(xaldzIyaj, lfebbBopu) -> imy $ \hkhtf -> Ewzgn
{ qoahe_rb = xaldzIyaj
, aeroj_uxifct = Qafa.vnij "NtizUbq"
, quzou_tgalzq = BDvkjte.dabpv
, hivog_msnmd = \case
MzuhatSujaunf CurlomuVurqofOcraraw{} ->
kmblXilIgisefu xaldzIyaj $ return []
MzuhatSujaunf JovbiegAkujaJawqbufobd{} ->
kmblXilIgisefu xaldzIyaj $ return []
MzuhatSujaunf SmkojhwAkeath -> kmblXilIgisefu xaldzIyaj $ do
pqjfyaturpI <- tubcumXzhogH
=<< fxziqqVirephu (Qafa.vnij "vhincupedamiji")
pure $ M.egDuyz gagwwau <&> \(iungeRyrr, lcotQjs) ->
OJaufn iungeRyrr $ M.egDuyz lcotQjs <&> \(pAumcAweb, vdauyXuf) ->
JItwocAfye pAumcAweb
$ M.egDuyz vdauyXuf
>>= \(pkesuNale, tfevaPykid) ->
tfevaPykid >>= \(hnaqseViof, eyubz, unzRpisupaq) ->
unzRpisupaq <&> \(jfhop, jva, lyi) ->
let
xmbau = cekoed M.! hnaqseViof
kauvx = S.tmolOobf $ case xmbau of
SQBokknXqazk (FUIghuGuodo _ kauvx) ->
[ WIwuv porp nnehajNovin []
| (s, e, _, _) <- kauvx
, let f' = sdfmenaLodi pqjfyaturpI s
, let g' = sdfmenaLodi pqjfyaturpI e
, let uwamm' = sdfmenaLodi pqjfyaturpI jfhop
, let xde' = sdfmenaLodi pqjfyaturpI jva
, let nnehajNovin =
yvpKwgiaQbeyxtmv $ g' `amoOB` f'
, uwamm' <= f'
, f' <= xde'
]
UMOyumoTumoibAsvqp{} -> []
in
PYifebdruthMjob (Fsnu pkesuNale)
eyubz
(QEvavFipiv lyi kauvx)
}
requires config
lconfig_altChooser:
tag: AltChooserBoundedSearch
contents: 5
with the default of 3 (instead of 5) brittany reformats the above to the non-optimal:
ugebe gdac _ekaz (NtizUbq sysn cekoed gagwwau, FdrnAqsAmnu njiuZqanacpoYbx) =
M.egDuyz cekoed <&> \(xaldzIyaj, lfebbBopu) -> imy $ \hkhtf -> Ewzgn
{ qoahe_rb = xaldzIyaj
, aeroj_uxifct = Qafa.vnij "NtizUbq"
, quzou_tgalzq = BDvkjte.dabpv
, hivog_msnmd = \case
MzuhatSujaunf CurlomuVurqofOcraraw{} ->
kmblXilIgisefu xaldzIyaj $ return []
MzuhatSujaunf JovbiegAkujaJawqbufobd{} ->
kmblXilIgisefu xaldzIyaj $ return []
MzuhatSujaunf SmkojhwAkeath -> kmblXilIgisefu xaldzIyaj $ do
pqjfyaturpI <- tubcumXzhogH
=<< fxziqqVirephu (Qafa.vnij "vhincupedamiji")
pure $ M.egDuyz gagwwau <&> \(iungeRyrr, lcotQjs) ->
OJaufn iungeRyrr $ M.egDuyz lcotQjs <&> \(pAumcAweb, vdauyXuf) ->
JItwocAfye pAumcAweb
$ M.egDuyz vdauyXuf
>>= \(pkesuNale, tfevaPykid) ->
tfevaPykid
>>= \(hnaqseViof, eyubz, unzRpisupaq) ->
unzRpisupaq <&> \(jfhop, jva, lyi) ->
let
xmbau = cekoed M.! hnaqseViof
kauvx = S.tmolOobf $ case xmbau of
SQBokknXqazk (FUIghuGuodo _ kauvx) ->
[ WIwuv porp nnehajNovin []
| (s, e, _, _) <- kauvx
, let f' = sdfmenaLodi pqjfyaturpI s
, let g' = sdfmenaLodi pqjfyaturpI e
, let uwamm' =
sdfmenaLodi pqjfyaturpI jfhop
, let xde' = sdfmenaLodi pqjfyaturpI jva
, let nnehajNovin =
yvpKwgiaQbeyxtmv $ g' `amoOB` f'
, uwamm' <= f'
, f' <= xde'
]
UMOyumoTumoibAsvqp{} -> []
in
PYifebdruthMjob (Fsnu pkesuNale)
eyubz
(QEvavFipiv lyi kauvx)
}
I cannot spot any particular bug in the layouting code here and it is certainly possible that pruning to 5 instead of 3 is necessary for examples of certain complexity.
Maybe the default config should be changed? Relevant questions:
- How big is the impact on performance for some average brittany usage when reducing the "pruning-agressiveness" from 3 to 5?
- How often are these non-optimal cases encountered?
Why don't we just use a list-comprehension there? It avoids tons of nesting..(this only applies to this specific case; the general question is not affected really)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's sample and the lconfig_altChooser setting, comparing Brittany's output with pruning values of 3 and 5. Measure the performance impact and determine how often similarly non-optimal layouts occur before deciding whether the default configuration should change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100