Large case pattern should respect line lengths #143

Open
opened 2018-05-16 16:07:25 +02:00 by chreekat · 2 comments
chreekat commented 2018-05-16 16:07:25 +02:00 (Migrated from github.com)

A new corner case for you. :)

With default options, 0.11 produces

test_examples :: [TestTree]
test_examples =
  [ testCase
      "buildParticipantRecordAction-all"
      (  (case buildParticipantRecordAction participantRecordAll Create of
           ParticipantRecordAction Create [Upsert m1 "1", Upsert m2 "infoval", Upsert m3 "descval", Upsert m4 "2011-06-17", Upsert m5 "Male", Upsert m6 "White", Upsert m7 "Hispanic or Latino", Upsert m8 "2.5", Upsert m9 "Preterm", Upsert m10 "10.5", Upsert m11 "normal", Upsert m12 "English", Upsert m13 "USA", Upsert m14 "MA", Upsert m15 "Lab"]
             -> m1
               == participantMetricId
               && m2
               == participantMetricInfo
               && m3
               == participantMetricDescription
               && m4
               == participantMetricBirthdate
               && m5
               == participantMetricGender
               && m6
               == participantMetricRace
               && m7
               == participantMetricEthnicity
               && m8
               == participantMetricGestationalAge
               && m9
               == participantMetricPregnancyTerm
               && m10
               == participantMetricBirthWeight
               && m11
               == participantMetricDisability
               && m12
               == participantMetricLanguage
               && m13
               == participantMetricCountry
               && m14
               == participantMetricState
               && m15
               == participantMetricSetting
           _ -> False
         )
      @? "Expected create with upsert for each metric"
      )
  ]
A new corner case for you. :) With default options, 0.11 produces ```haskell test_examples :: [TestTree] test_examples = [ testCase "buildParticipantRecordAction-all" ( (case buildParticipantRecordAction participantRecordAll Create of ParticipantRecordAction Create [Upsert m1 "1", Upsert m2 "infoval", Upsert m3 "descval", Upsert m4 "2011-06-17", Upsert m5 "Male", Upsert m6 "White", Upsert m7 "Hispanic or Latino", Upsert m8 "2.5", Upsert m9 "Preterm", Upsert m10 "10.5", Upsert m11 "normal", Upsert m12 "English", Upsert m13 "USA", Upsert m14 "MA", Upsert m15 "Lab"] -> m1 == participantMetricId && m2 == participantMetricInfo && m3 == participantMetricDescription && m4 == participantMetricBirthdate && m5 == participantMetricGender && m6 == participantMetricRace && m7 == participantMetricEthnicity && m8 == participantMetricGestationalAge && m9 == participantMetricPregnancyTerm && m10 == participantMetricBirthWeight && m11 == participantMetricDisability && m12 == participantMetricLanguage && m13 == participantMetricCountry && m14 == participantMetricState && m15 == participantMetricSetting _ -> False ) @? "Expected create with upsert for each metric" ) ] ```
lspitzner commented 2018-05-16 21:57:16 +02:00 (Migrated from github.com)

Yeah, i know. Pattern layouting is not complete for any non-single-line cases. And unfortunately this has somewhat low priority for me, as such patterns usually are best avoided. Although I don't see any workaround for your example there.

(If you want to have a go at improving this, the relevant brittany module is Language.Haskell.Brittany.Internal.Layouters.Pattern. Although some other code might be affected as well which currently relies on the "patterns are single-line" assumption.)

At least you now have the option of making use of -- brittany-disable-next-binding and layout this one by hand. Presuming that you only have a few of these cases.

Yeah, i know. Pattern layouting is not complete for any non-single-line cases. And unfortunately this has somewhat low priority for me, as such patterns usually are best avoided. Although I don't see any workaround for your example there. (If you want to have a go at improving this, the relevant brittany module is `Language.Haskell.Brittany.Internal.Layouters.Pattern`. Although some other code might be affected as well which currently relies on the "patterns are single-line" assumption.) At least you now have the option of making use of `-- brittany-disable-next-binding` and layout this one by hand. Presuming that you only have a few of these cases.
chreekat commented 2018-05-19 20:31:26 +02:00 (Migrated from github.com)

Maybe @kanishka-azimi has an opinion on the size of the pattern in this particular case. But anyway, that brittany directive shall certainly come in handy!

Maybe @kanishka-azimi has an opinion on the size of the pattern in this particular case. But anyway, that brittany directive shall certainly come in handy!
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#143
There is no content yet.