###############################################################################
###############################################################################
###############################################################################
#group regression
###############################################################################
###############################################################################
###############################################################################

#test newlines-comment
func = do
  abc <- foo

--abc
return ()

#test parenthesis-around-unit
func = (())

#test let-defs indentation
func = do
  let foo True = True
      foo _    = False
  return ()

#test record update indentation 1
func = do
  s <- mGet
  mSet $ s { _lstate_indent = _lstate_indent state }

#test record update indentation 2
func = do
  s <- mGet
  mSet $ s { _lstate_indent = _lstate_indent state
           , _lstate_foo    = _lstate_foo state
           }

#test record update indentation 3
func = do
  s <- mGet
  mSet $ s
    { _lstate_indent = _lstate_indent lkasdlkjalsdjlakjsdlkjasldkjalskdjlkajsd
    , _lstate_foo    = _lstate_foo lkasdlkjalsdjlakjsdlkjasldkjalskdjlkajsd
    }

#test record construction 1
func = Foo { _lstate_indent = _lstate_indent state }

#test record construction 2
func = Foo
  { _lstate_indent = _lstate_indent lkasdlkjalsdjlakjsdlkjasldkjalskdjlkajsd
  , _lstate_fooo   = _lstate_foo lkasdlkjalsdjlakjsdlkjasldkjalskdjlkajsd
  }

#test record construction 3
func = do
  Foo { _lstate_indent = _lstate_indent lkasdlkjalsdjlakjsdlkjasldkjalskdjlkajsd
      , _lstate_foo    = _lstate_foo lkasdlkjalsdjlakjsdlkjasldkjalskdjlkajsd
      }

#test post-indent comment
func = do
-- abc
  -- def
  return ()

#test post-unindent comment
func = do
  do
    return ()
    -- abc
  -- def
  return ()

#test CPP empty comment case
#pending CPP parsing needs fixing for roundTripEqual
{-# LANGUAGE CPP #-}
module Test where
func = do
#if FOO
  let x = 13
#endif
  stmt x

## really, the following should be handled by forcing the Alt to multiline
## because there are comments. as long as this is not implemented though,
## we should ensure the trivial solution works.
#test comment inline placement (temporary)
func
  :: Int -- basic indentation amount
  -> Int -- currently used width in current line (after indent)
         -- used to accurately calc placing of the current-line
  -> LayoutDesc
  -> Int

#test some indentation thingy
func =
  ( lkjadljasldjalskdjaldjalsdjkalsdjlaksdjlasjdlajsaldskj
  $ abc
  $ def
  $ ghi
  $ jkl
  )

#test parenthesized operator
buildG bounds0 edges0 = accumArray (flip (:)) [] bounds0 (map reassoc edges0)
  where reassoc (v, e, w) = (v, (e, w))

#test record pattern matching stuff
downloadRepoPackage = case repo of
  RepoLocal {..}    -> return ()
  RepoLocal { abc } -> return ()
  RepoLocal{}       -> return ()

#test do let comment indentation level problem
func = do
  let (primaryPkg, otherPkgs) = selectPrimaryLocalPackage pwd pkgs'
      (bproblems, x) = resolveBuildTargets primaryPkg otherPkgs utargets''
      -- default local dir target if there's no given target
      utargets''              = "foo"
      asd                     = True
  return ()

#test list comprehension comment placement
func =
  [ (thing, take 10 alts) --TODO: select best ones
  | (thing, _got, alts@(_ : _)) <- nosuchFooThing
  , gast                        <- award
  ]

#test if-then-else comment placement
func = if x
  then if y -- y is important
    then foo
    else bar
  else Nothing

#test qualified infix pattern
wrapPatPrepend pat prepElem = do
  patDocs <- layoutPat pat
  case Seq.viewl patDocs of
    Seq.EmptyL   -> return $ Seq.empty
    x1 Seq.:< xR -> do
      x1' <- docSeq [prepElem, return x1]
      return $ x1' Seq.<| xR

#test type signature multiline forcing issue
layoutWriteNewlineBlock
  :: ( MonadMultiWriter Text.Builder.Builder m
     , MonadMultiState LayoutState m
     , MonadMultiWriter (Seq String) m
     )
  => m ()

#test multiwayif proper indentation
{-# LANGUAGE MultiWayIf #-}
readMergePersConfig path shouldCreate conf = do
  exists <- liftIO $ System.Directory.doesFileExist path
  if
    | exists -> do
      contents <- liftIO $ ByteString.readFile path -- no lazy IO, tyvm.
      fileConf <- case Data.Yaml.decodeEither contents of
        Left e -> do
          liftIO
            $ putStrErrLn
            $ "error reading in brittany config from " ++ path ++ ":"
          liftIO $ putStrErrLn e
          mzero
        Right x -> return x
      return $ fileConf Semigroup.<> conf
    | shouldCreate -> do
      liftIO
        $ ByteString.writeFile path
        $ Data.Yaml.encode
        $ cMap (Option . Just . runIdentity) staticDefaultConfig
      return $ conf
    | otherwise -> do
      return conf

#test nested pattern alignment issue"
func = BuildReport
 where
  convertInstallOutcome = case result of
    Left  BR.PlanningFailed      -> PlanningFailed
    Left  (BR.DependentFailed p) -> DependencyFailed p
    Left  (BR.DownloadFailed  _) -> DownloadFailed
    Left  (BR.UnpackFailed    _) -> UnpackFailed
    Left  (BR.ConfigureFailed _) -> ConfigureFailed
    Left  (BR.BuildFailed     _) -> BuildFailed
    Left  (BR.TestsFailed     _) -> TestsFailed
    Left  (BR.InstallFailed   _) -> InstallFailed
    Right (BR.BuildOk _ _ _    ) -> InstallOk

#test nested pattern alignment issue"
func = BuildReport
 where
  convertInstallOutcome = case result of
    Left  BR.PlanningFailed      -> PlanningFailed
    Left  (BR.DependentFailed p) -> DependencyFailed p
    Left  (BR.DownloadFailed  _) -> DownloadFailed
    Left  (BR.UnpackFailed    _) -> UnpackFailed
    Left  (BR.ConfigureFailed _) -> ConfigureFailed
    Left  (BR.BuildFailed     _) -> BuildFailed
    Left  (BR.TestsFailed     _) -> TestsFailed
    Left  (BR.InstallFailed   _) -> InstallFailed
    Right (BR.BuildOk _ _ _    ) -> InstallOk

#test partially overflowing alignment issue"
showPackageDetailedInfo pkginfo =
  renderStyle (style { lineLength = 80, ribbonsPerLine = 1 })
    $   char '*'
    $+$ something
          [ entry "Synopsis" synopsis hideIfNull reflowParagraphs
          , entry "Versions available"
                  sourceVersions
                  (altText null "[ Not available from server ]")
                  (dispTopVersions 9 (preferredVersions pkginfo))
          , entry
              "Versions installed"
              installedVersions
              (altText
                null
                (if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]")
              )
              (dispTopVersions 4 (preferredVersions pkginfo))
          , entry "Homepage"      homepage     orNotSpecified  text
          , entry "Bug reports"   bugReports   orNotSpecified  text
          , entry "Description"   description  hideIfNull      reflowParagraphs
          , entry "Category"      category     hideIfNull      text
          , entry "License"       license      alwaysShow      disp
          , entry "Author"        author       hideIfNull      reflowLines
          , entry "Maintainer"    maintainer   hideIfNull      reflowLines
          , entry "Source repo"   sourceRepo   orNotSpecified  text
          , entry "Executables"   executables  hideIfNull      (commaSep text)
          , entry "Flags" flags hideIfNull (commaSep dispFlag)
          , entry "Dependencies" dependencies hideIfNull (commaSep dispExtDep)
          , entry "Documentation" haddockHtml  showIfInstalled text
          , entry "Cached"        haveTarball  alwaysShow      dispYesNo
          , if not (hasLib pkginfo)
              then empty
              else
                text "Modules:"
                $+$ nest 4 (vcat (map disp . sort . modules $ pkginfo))
          ]

#test issue 7a
isValidPosition position | validX && validY = Just position
                         | otherwise        = Nothing

#test issue-6-pattern-linebreak-validity
## this is ugly, but at least syntactically valid.
foo = Reflex.runSpiderHost $ ReflexHost.hostApp $ do
  (inputEvent :: Reflex.Event Reflex.Spider String, inputFire :: String
    -> IO Bool                                                         ) <-
    ReflexHost.newExternalEvent
  liftIO . forkIO . forever $ getLine >>= inputFire
  ReflexHost.performEvent_ $ fmap (liftIO . putStrLn) inputEvent

#test issue 16
foldrDesc f z = unSwitchQueue $ \q ->
  switch (Min.foldrDesc (f unTaggedF) z q) (Min.foldrAsc (f unTaggedF) z q)

#test issue 18
autocheckCases =
  [ ("Never Deadlocks"  , representative deadlocksNever)
  , ("No Exceptions"    , representative exceptionsNever)
  , ("Consistent Result", alwaysSame) -- already representative
  ]

#test issue 18b
autocheckCases =
  [ ("Never Deadlocks", representative deadlocksNever)
  , ("No Exceptions"  , representative exceptionsNever)
  , ( "Consistent Result"
    , alwaysSame -- already representative
    )
  ]

#test issue 18c
func =
  [ (abc, (1111, 1111))
  , (def, (2, 2))
  , foo -- comment
  ]

#test issue 26
foo a b = g a b -- fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
  where g a b = b + b * a

#test issue 26b
foo a b = g a b where g a b = b + b * a -- fooooooooooooooooooooooooooooooooooo

#test aggressive alignment 1
func = do
  abc                  <- expr
  abcccccccccccccccccc <- expr
  abcccccccccccccccccccccccccccccccccccccccccc <- expr
  abccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc <- expr

#test example alignment 1
func (MyLongFoo abc def) = 1
func (Bar       a   d  ) = 2
func _                   = 3

#test listcomprehension-case-of
parserCompactLocation =
  [ try
    $ [ ParseRelAbs (Text.Read.read digits) _ _
      | digits <- many1 digit
      , rel1 :: Maybe (Either Int (Ratio Int)) <- optionMaybe
        [ case divPart of
            Nothing -> Left $ Text.Read.read digits
            Just ddigits ->
              Right $ Text.Read.read digits % Text.Read.read ddigits
        | digits  <- many1 digit
        , divPart <- optionMaybe (string "/" *> many1 digit)
        ]
      ]
  ]

#test opapp-specialcasing-1
func = fooooooooooooooooooooooooooooooooo
  $ foooooooooooooooooooooooooooooooo foooooooooooooooooooooooooooooooo
                                      foooooooooooooooooooooooooooooooo

#test opapp-specialcasing-2
func =
  fooooooooooooooooooooooooooooooooo
    + foooooooooooooooooooooooooooooooo foooooooooooooooooooooooooooooooo
                                        foooooooooooooooooooooooooooooooo

#test opapp-specialcasing-3
func =
  fooooooooooooooooooooooooooooooooo
    + foooooooooooooooooooooooooooooooo
        [ foooooooooooooooooooooooooooooooo
        , foooooooooooooooooooooooooooooooo
        , foooooooooooooooooooooooooooooooo
        ]

#test opapp-indenting
parserPrim =
  [ r
  | r <-
    [ SGPPrimFloat
      $ bool id (0 -) minus
      $ readGnok "parserPrim" (d1 ++ d2 ++ d3 ++ d4)
    | d2 <- string "."
    , d3 <- many1 (oneOf "0123456789")
    , _  <- string "f"
    ]
    <|> [ SGPPrimFloat $ bool id (0 -) minus $ fromIntegral
            (readGnok "parserPrim" d1 :: Integer)
        | _ <- string "f"
        ]
    <|> [ SGPPrimInt $ bool id (0 -) minus $ fromIntegral
            (readGnok "parserPrim" d1 :: Integer)
        | _ <- string "i"
        ]
  ]

#test another-parspacing-testcase

samples = (SV.unpackaaaaadat) <&> \f ->
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#test recordupd-singleline-bug

runBrittany tabSize text = do
  let config' = staticDefaultConfig
      config  = config'
        { _conf_layout  = (_conf_layout config')
                            { _lconfig_indentAmount = coerce tabSize
                            }
        , _conf_forward = forwardOptionsSyntaxExtsEnabled
        }
  parsePrintModule config text

#test recordupd-singleline-bug-left

-- brittany { lconfig_indentPolicy: IndentPolicyLeft }
runBrittany tabSize text = do
  let
    config' = staticDefaultConfig
    config  = config'
      { _conf_layout  = (_conf_layout config')
        { _lconfig_indentAmount = coerce tabSize
        }
      , _conf_forward = forwardOptionsSyntaxExtsEnabled
      }
  parsePrintModule config text

#test issue 37

foo =
  ( a
  , -- comment1
    b
    -- comment2
  , c
  )

#test issue 38

{-# LANGUAGE TypeApplications #-}
foo = bar @Baz

#test comment-before-BDCols
{-# LANGUAGE TypeApplications #-}
layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
  docAlt
    $  -- one-line solution
       [ docCols
           (ColBindingLine alignmentToken)
           [ docSeq (patPartInline ++ [guardPart])
           , docSeq
               [ appSep $ return binderDoc
               , docForceSingleline $ return body
               , wherePart
               ]
           ]
       | not hasComments
       , [(guards, body, _bodyRaw)] <- [clauseDocs]
       , let guardPart = singleLineGuardsDoc guards
       , wherePart <- case mWhereDocs of
         Nothing  -> return @[] $ docEmpty
         Just [w] -> return @[] $ docSeq
           [ docSeparator
           , appSep $ docLit $ Text.pack "where"
           , docSetIndentLevel $ docForceSingleline $ return w
           ]
         _ -> []
       ]
    ++ -- one-line solution + where in next line(s)
       [ docLines
         $  [ docCols
                (ColBindingLine alignmentToken)
                [ docSeq (patPartInline ++ [guardPart])
                , docSeq
                    [appSep $ return binderDoc, docForceParSpacing $ return body]
                ]
            ]
         ++ wherePartMultiLine
       | [(guards, body, _bodyRaw)] <- [clauseDocs]
       , let guardPart = singleLineGuardsDoc guards
       , Data.Maybe.isJust mWhereDocs
       ]
    ++ -- two-line solution + where in next line(s)
       [ docLines
         $  [ docForceSingleline $ docSeq
                (patPartInline ++ [guardPart, return binderDoc])
            , docEnsureIndent BrIndentRegular
              $ docForceSingleline
              $ return body
            ]
         ++ wherePartMultiLine
       | [(guards, body, _bodyRaw)] <- [clauseDocs]
       , let guardPart = singleLineGuardsDoc guards
       ]

#test comment-testcase-17
{-# LANGUAGE MultiWayIf #-}
func = do
  let foo = if
        | Constuctoooooooooooooooooooooooooooooooooooor `elem` artics -- TODO
        -> max (defLen - 0.2) -- TODO
                              (defLen * 0.8)
        | otherwise
        -> max (defLen - 0.05) (defLen * 0.95) -- TODO
  return True

#test issue 49

foo n = case n of
  1  -> True
  -1 -> False

bar n = case n of
  (-2, -2) -> (-2, -2)

#test issue 48 b

{-# LANGUAGE TypeApplications #-}
foo =
  let a    = b @1
      cccc = ()
  in  foo

#test issue 52 a

{-# LANGUAGE RecordWildCards #-}
v = A { a = 1, .. } where b = 2

#test issue 52 b

{-# LANGUAGE RecordWildCards #-}
v = A { .. } where b = 2

#test issue 52 c

{-# LANGUAGE RecordWildCards #-}
v = A { a = 1, b = 2, c = 3 }

#test issue 63 a
test :: Proxy 'Int

#test issue 63 b
test :: Proxy '[ 'True ]

#test issue 63 c
test :: Proxy '[Bool]

#test issue 64
{-# LANGUAGE RankNTypes, KindSignatures #-}
func
  :: forall m str
   . (Str str, Monad m)
  => Int
  -> Proxy (str :: [*])
  -> m (Tagged str String)

#test issue 65
widgetsDyn =
  [ [ vBox
        [ padTop Max outputLinesWidget
        , padRight Max wid1 <+> flowWidget  -- alignment here is strange/buggy
        , padBottom (Pad 5) help
        ]
    ]
  | wid1              <- promptDyn
  , (flowWidget, _)   <- flowResultD
  , outputLinesWidget <- outputLinesWidgetD
  , help              <- suggestionHelpBox
  , parser            <- cmdParserD
  ]

#test issue 67
fmapuv :: U.Unbox a => (a -> b) -> U.Vector a -> V.Vector b
fmapuv f xs = G.generate (G.length xs) (f . (xs G.!))


#test parallellistcomp-workaround
cs0 = 0 : [ c / Interval n | c <- cs | n <- [1..] ]

#test issue 70
{-# LANGUAGE TemplateHaskell #-}
deriveFromJSON (unPrefix "assignPost") ''AssignmentPost

#test issue 110
main = -- a
  let --b
      x = 1 -- x
      y = 2 -- y
  in  do
        print x
        print y

#test issue 111
alternatives :: Parser (Maybe Text)
alternatives =
  alternativeOne   -- first try this one
    <|> alterantiveTwo   -- then this one
    <|> alternativeThree -- then this one
 where
  alternativeOne   = purer "one"
  alternativeTwo   = purer "two"
  alterantiveThree = purer "three"

#test issue 116
{-# LANGUAGE BangPatterns #-}
func = do
  let !forced = some
  pure ()

#test let-in-hanging
spanKey p q = case minViewWithKey q of
  Just ((k, _), q') | p k ->
    let (kas, q'') = spanKey p q' in ((k, a) : kas, q'')
  _ -> ([], q)

#test issue 125
a :: () ':- ()

#test issue 128
func = do
  createDirectoryIfMissing True path
  openFile fileName AppendMode

#test hspar-comments

alternatives :: Parser (Maybe Text)
alternatives = -- a
  ( -- b
      alternativeOne   -- c
  <|> alterantiveTwo   -- d
  <|> alternativeThree -- e
  ) -- f

#test issue 133
{-# LANGUAGE ScopedTypeVariables #-}
func
  :: forall a
   . ()
  => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  -> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
func
  :: ()
  => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  -> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#test alignment-potential-overflow
go l [] = Right l
go l ((IRType, _a) : eqr) = go l eqr
go l ((_, IRType) : eqr) = go l eqr
go _ ((IRTypeError ps t1 t2, _) : _) = Left $ makeError ps t1 t2
go _ ((_, IRTypeError ps t1 t2) : _) = Left $ makeError ps t1 t2

#test issue 89 - type-family-instance
type instance XPure StageParse = ()
type Pair a = (a, a)

#test issue 144
-- brittany { lconfig_indentAmount: 4, lconfig_indentPolicy: IndentPolicyMultiple }
dsfnjKeekbwwbosbOfakxqRsiyix cnehokzozwbVaguvu migbnaRwutbz =
    let
        eyuAfrarIso'
            :: (RveoexdxunuAafalm -> Axlau (Axlau (a, OinejrdCplle)))
            -> Gbodoy
            -> Axlau (Axlau OinejrdCplle, Gbodoy)
        eyuAfrarIso' = ulcPaaekBst cnehokzozwbVaguvu
        amkgoxEhalazJjxunecCuIfaw
            :: Axlau (Axlau OinejrdCplle, Gbodoy) -> Axlau RqlnrluYqednbCiggxi
        amkgoxEhalazJjxunecCuIfaw uKqviuBisjtn = do
            (sEmo, quc) <- uKqviuBisjtn
            pure (xoheccewfWoeyiagOkfodiq sEmo quc)
        xoheccewfWoeyiagOkfodiq
            :: Axlau OinejrdCplle -> Gbodoy -> RqlnrluYqednbCiggxi
        xoheccewfWoeyiagOkfodiq sEmo quc = case migbnaRwutbz of
            Afogmf -> xgeqe (OfBkkuih quc) (Ciitog quc) sEmo
    in QabqyilexuiNizzhsQuxxac migbnaRwutbz (hwaTihhjt lhowvscIiozgqe)

#test issue 159
spec = do
  it "creates a snapshot at the given level" . withGraph runDB $ do
    lift $ do
      studentDiagnosticReadingLevel updatedStudent `shouldBe` Just 10 -- x
      elaSnapshotReadingLevel snapshot `shouldBe` 12

#test non-bottom-specialcase-altsearch
jaicyhHumzo btrKpeyiFej mava = do
  m :: VtohxeRgpmgsu <- qloxIfiq mava
  case m of
    ZumnaoFujayerIswadabo kkecm chlixxag -> do
      imomue <- ozisduRaqiseSBAob btrKpeyiFej $ \s ->
        case MizA.pigevo kkecm (_tc_gulawulu s) of
          Ebocaba ->
            ( s { _tc_gulawulu = MizA.jxariu kkecm rwuRqxzhjo (_tc_gulawulu s) }
            , Gtzvonm
            )
          Xcde{} -> (s, Pioemav)
      pure imomue

#test issue 214
-- brittany { lconfig_indentPolicy: IndentPolicyMultiple }
foo =
  bar
    arg1 -- this is the first argument
    arg2 -- this is the second argument
    arg3 -- this is the third argument, now I'll skip one comment
    arg4
    arg5 -- this is the fifth argument
    arg6 -- this is the sixth argument

#test issue 234

True `nand` True = False
nand _ _         = True

nor False False = True
_ `nor` _       = False

#test issue 256 prefix operator match

f ((:) a as) = undefined

#test issue 228 lambda plus lazy or bang pattern

{-# LANGUAGE BangPatterns #-}
a = \x -> x
b = \ ~x -> x
c = \ !x -> x
d = \(~x) -> x

#test type signature with forall and constraint
{-# LANGUAGE RankNTypes #-}
func :: forall b . Show b => b -> String

#test issue 267

{-# LANGUAGE TypeFamilies #-}
f :: ((~) a b) => a -> b
f = id

#test large record update
-- brittany { lconfig_indentPolicy: IndentPolicyLeft }
vakjkeSulxudbFokvir = Duotpo
  { _ekku_gcrpbze                   = xgonae (1 :: Int)
  , _oola_louwu                     = FoqsiYcuidx
    { _xxagu_umea_iaztoj                = xgonae False
    , _tuktg_tizo_kfikacygsqf           = xgonae False
    , _ahzbo_xpow_otq_nzeyufq           = xgonae False
    , _uagpi_lzps_luy_xcjn              = xgonae False
    , _dxono_qjef_aqtafq_bes            = xgonae False
    , _yzuaf_nviy_vuhwxe_ihnbo_uhw      = xgonae False
    , _iwcit_fzjs_yerakt_dicox_mtryitko = xgonae False
    , _ehjim_ucfe_dewarp_newrt_gso      = xgonae False
    , _ogtxb_ivoj_amqgai_rttui_xuwhetb  = xgonae False
    , _bhycb_iexz_megaug_qunoa_ohaked   = xgonae False
    , _nnmbe_uqgt_ewsuga_vaiis          = xgonae False
    , _otzil_ucvugaiyj_aosoiatunx_asir  = xgonae False
    }
  , _iwsc_lalojz                    = XqspaiDainqw
    { _uajznac_ugah                          = xgonae (80 :: Int)
    , _qayziku_gazibzDejipj                  = xgonae DewizeCxwgyiKjig
    , _auhebll_fiqjxyArfxia                  = xgonae (2 :: Int)
    , _zubfuhq_dupiwnIoophXameeet            = xgonae True
    , _oavnuqg_opkreyOufuIkifiin             = xgonae True
    , _ufojfwy_fhuzcePeqwfu                  = xgonae (50 :: Int)
    , _mlosikq_zajdxxSeRoelpf                = xgonae (50 :: Int)
    , _heemavf_fjgOfoaikh = xgonae (FyoVfvdygaZuzuvbeWarwuq 3)
    , _ohxmeoq_ogtbfoPtqezVseu = xgonae (EdjotoLcbapUdiuMmytwoig 0.7)
    , _omupuiu_ituamexjuLccwu                = xgonae (30 :: Int)
    , _xoseksf_atvwwdwaoHanofMyUvujjopoz     = xgonae True
    , _umuuuat_nuamezwWeqfUqzrnaxwp          = xgonae False
    , _uuriguz_wixhutbuKecigaFiwosret        = xgonae True
    , _betohxp_scixaLsvcesErtwItxrnaJmuz     = xgonae False
    , _lchxgee_olaetGcqzuqxVujenCzexub       = xgonae True
    , _egeibao_imamkuigqikhZdcbpidokVcixiqew = xgonae False
    }
  , _nloo_cfmrgZcisiugk             = YuwodSavxwnicBekuel
    { _oebew_rrtpvthUzlizjAqIwesly   = xgonae False
    , _blkff_Acxoid                  = xgonae False
    , _datei_YewolAowoqOpunvpgu      = xgonae BeekgUzojaPnixxaruJehyPmnnfu
    , _ejfrj_eheb_justvh_pumcp_ismya = xgonae False
    }
  , _kena_uzeddovosoki              = NyoRvshullezUpauud
    { _mtfuwi_TUVEmoi            = xgonae RZXKoytUtogx
    , _larqam_adaxPehaylZafeqgpc = xgonae False
    }
  , _spob_qipaarx = KaxavsmOtoyeaq { _rusrirw_okx = Tajemkix [] }
  , _vmah_uivucnfka_ikaquebxay_gzcm = xgonae False
  , _qaqb_eykzuyuwi                 = xgonae False
    -- test comment
  }

#test large record wildcard comment

-- brittany { lconfig_indentPolicy: IndentPolicyLeft }
vakjkeSulxudbFokvir = Duotpo
  { _ekku_gcrpbze                   = xgonae (1 :: Int)
  , _spob_qipaarx = KaxavsmOtoyeaq { _rusrirw_okx = Tajemkix [] }
  , _vmah_uivucnfka_ikaquebxay_gzcm = xgonae False
  , _qaqb_eykzuyuwi                 = xgonae False
    -- test comment
  , -- N.B.
    .. -- x
  }

#test issue 263

func = abc + def
  -- a
  -- b

  -- comment

 where
  abc = 13
  def = 1

#test AddBaseY/EnsureIndent float in effect

zItazySunefp twgq nlyo lwojjoBiecao =
  let mhIarjyai =
        ukwAausnfcn
          $ XojlsTOSR.vuwOvuvdAZUOJaa
          $ XojlsTOSR.vkesForanLiufjeDI
          $ XojlsTOSR.vkesForanLiufjeDI
          $ XojlsTOSR.popjAyijoWarueeP
          $ XojlsTOSR.jpwuPmafuDqlbkt nlyo
          $ XojlsTOSR.jpwuPmafuDqlbkt xxneswWhxwng
          $ XojlsTOSR.jpwuPmafuDqlbkt oloCuxeDdow
          $ XojlsTOSR.jpwuPmafuDqlbkt (uwurrvoNnukzefuDjeh lwojjoBiecao nlyo)
          $ etOslnoz lwojjoBiecao
  in  kucotg $ (bbbr, Yoxe.Dwzbuzi.zrLokoTnuy piv)

#test module initial comment
-- test
module MyModule where

#test issue 231

foo =
  [ ("xxx", "xx")
  , --
    ("xx" , "xx")
    --
  , ("xx" , "xxxxx")
  , ("xx" , "xx")
  ]

#test issue 231 not

foo =
  [ ("xx", "xx")
  , ( "xx" --
    , "xx"
    )
  , ("xx", "xxxxx")
  , ("xx", "xx")
  ]

#test issue 281

module Main
  ( DataTypeI
  , DataTypeII(DataConstructor)
    -- * Haddock heading
  , name
  ) where

#test type level list

xeoeqibIaib
  :: ( KqujhIsaus m
     , XivuvIpoboi Droqifim m
     , IgorvOtowtf m
     , RyagaYaqac m
     , QouruDU m
     )
  => MaptAdfuxgu
  -> Zcnxg NsxayqmvIjsezea -- ^ if Lvqucoo, opsip jl reyoyhk lfil qaculxgd
  -> QNOZqwuzg
  -> Eoattuq
       '[ XkatytdWdquraosu -- test comment
        , KyezKijim        -- another test comment
        , DjmioeePuoeg
        , NinrxoiOwezc
        , QATAlrijacpk
        , TrutvotwIwifiqOjdtu
        , CoMmuatjwr
        , BoZckzqyodseZole
        , VagfwoXaeChfqe
        ]
       m
       ()

#test recordupd-overflow-bad-multiline-spacing

createRedirectedProcess processConfig = do
  let redirectedProc = (_processConfig_inner processConfig)
        { std_in  = CreatePipe
        , std_out = CreatePipe
        , std_err = CreatePipe
        }
  foo

#test issue 282

instance HasDependencies SomeDataModel where
  -- N.B. Here is a bunch of explanatory context about the relationship
  -- between these data models or whatever.
  type Dependencies SomeDataModel
    = (SomeOtherDataModelId, SomeOtherOtherDataModelId)

#test stupid-do-operator-combination
#pending

func =
  do
    y
  >>= x

#test nested-arrow-type
#pending
fieldWith
  :: a
  -> a
  -> (  ( GHC.RealSrcLoc
        , a
        , Either
            (Maybe GHC.RealSrcLoc, ToBriDocM BriDocNumbered)
            ( Maybe GHC.RealSrcLoc
            , ToBriDocM BriDocNumbered
            , ToBriDocM BriDocNumbered
            )
        )
     -> ToBriDocM BriDocNumbered
     )
  -> [ToBriDocM BriDocNumbered]

#test comment-before-where
briDocLineLength briDoc = flip StateS.evalState False $ go briDoc
                          -- the state encodes whether a separator was already
                          -- appended at the current position.
 where
  go = \case
    BDEmpty   -> return $ 0
    BDLit t   -> StateS.put False $> Text.length t
    BDSeq bds -> sum <$> go `mapM` bds

#test where-funbind-no-empty-lines
alignColsLines layoutBriDocM bridocs = do -- colInfos `forM_` \colInfo -> do
  -- tellDebugMess ("alignColsLines: at " ++ take 100 (show $ briDocToDoc $ head bridocs))
  case () of
    _ -> do
      -- tellDebugMess ("colInfos:\n" ++ List.unlines [ "> " ++ prettyColInfos "> " x | x <- colInfos])
      -- tellDebugMess ("processedMap: " ++ show processedMap)
      sequence_
        $ List.intersperse layoutWriteEnsureNewlineBlock
        $ colInfos <&> processInfo layoutBriDocM colMax processedMap
     where
      (colInfos, finalState) = StateS.runState
        (mergeBriDocs bridocs)
        (ColBuildState IntMapS.empty 0)
      -- maxZipper :: [Int] -> [Int] -> [Int]
      -- maxZipper [] ys = ys
      -- maxZipper xs [] = xs
      -- maxZipper (x:xr) (y:yr) = max x y : maxZipper xr yr
      colAggregation :: [Int] -> Int
      colAggregation [] = 0 -- this probably cannot happen the way we call
                            -- this function, because _cbs_map only ever
                            -- contains nonempty Seqs.
      colAggregation xs = maximum [ x | x <- xs, x <= minimum xs + alignMax' ]
        where alignMax' = max 0 alignMax

#test type-signature comment-after-context
tzejubuVxairoy
  :: (VwzuyApikd.VwzuyApikd zub, ZxtbaKospaKwqnuw Defg.Xeqpgko.Xeqpgko m)
  -- foo bar
  => CUR.Ozuzcak zub
  -> m ()

#test allow par-spacing for HsApp HsDo
func = other $ meep
  do
    abc
    def
  (some other very long linnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnne)

#test allow par-spacing for HsApp HsDo
func = other $ meep
  [ x | x <- myList ]
  (some other very long linnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnne)

#test allow par-spacing for HsApp HsSpliceE
{-# LANGUAGE QuasiQuotes #-}
func = other $ meep
  [q|hello
     world|]
  (some other very long linnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnne)

#test multiline-lambda-whitespace
func =
  Text.intercalate
    "\n"
    (   (\(abc, def) ->
          abc ++ def ++ "lkajsdljkasdlkjasldjkljkasd" ++ asdasdasdasd
        )
    <$> mylist
    )

#test operator newline behaviour
func =
  fromIntegral aaaaaaaaaaaaaaaaaaa
    / fromIntegral (aaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbb)

#test multi-constructor associated data decl
data POtfuggj
instance BMGuwigoc POtfuggj where
  data KVeeweknc POtfuggj r
    = ILpieakli
    | USilcnhkYaraposqu (WeyOoovf (Nubwlhtjd EculdW.QaeopznkAc r))
    deriving stock (Lirylfj1, Jexr)
    deriving anyclass Qart2.Vrzxuvcf

#test bang-type
data LabeledBool = LabeledBool !Int !Bool

#test block-comment after let
func = do
  let cipInuihz = Vuozczdm.yhEfun tuhiuRasohy
  let {- CAZEB mecwbd "Caa ||" -}
      doeeRbaviceQzymin a b = olivhuwqbaq
      iqnz biwomeJhhujy _ _ | biwomeJhhujy < volpoqAsizmHdwpl = pure 0
  pure True

#test comment-inside-decl
func False = 0
-- comment
func True  = 1

#test nested do-block-with-comment issue
dofunc = do
  do
    some
    code
  do
    -- abc
    more
    code

#test do-block paren non-alignment
catchFunc = do
  (func aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    )
    `catch` catcher

#test comment after lambdacase
func = \case
  -- zzz
  False -> 0
  True  -> 1

#test comment for recordfield
func = myRecord { field      = -- comment
                               if some condition then option one else option two
                , otherfield = "text"
                }

#test multiline guards within parenthesis
duGswidunBlxaq drux = DeeX.Vufcqqafi
  (tiErihambSunxo drux)
  (if
    | geIqzscmBhiwo drux
    -> Bmuh "Hpiioqa a yabufx ynyuq"
    | liWaov drux
    -> Bmuh "Ookhup ubqocf merr ukm ynyuq iitiop"
    | tiErihambSunxo drux && bdp (alJukIkuh drux)
    -> Bmuh "Jpgic dfaz dieb fs wreup hsv of ynyuq dio njr subdet"
    | ukFinwuicUgIcclcep drux
    -> Bmuh "Egwiqae-ka-molenqe codns dif'y ns csjyhth sisoyy"
    | otherwise
    -> Likiotq
  )

#test multiline-block-comment in do-block
func = do
  abc
  {- some long
     block comment -}
  x <- readLine
  print x

#test broken layout on do + operator + paren + do
func = do
  (wrapper $ do
    stmt1
    stmt2
    )
    `shouldReturn` thing

#test wandering comment at end of datadecl
data ReformatParenMode
  = ReformatParenModeKeep  -- don't modify parens at all
  | ReformatParenModeClean -- remove unnecessary parens
  | ReformatParenModeAll   -- add superfluous parens everywhere

#test empty do block error
func = process $ do
  it "some long description to fill this line" $ do
  ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    + bbbbbbbbbbbbbbbbbb
    + cccccccccccccccccccccccccccccccccccccccccccccccccc
    )
    `shouldReturn` thing

#test do-block block-comment comment statement sequence
func = do
  lec <- hrmexs

  {- HLINT ignore "blub" -}
  -- hlint thinks we can bring `qweqwe` outside of the `maybe`,
  -- but that's a type error.
  let jebnaZiegui = UtatUcaOrgmqf
        $ eqazak
            (NO.kaeyuo . NO.FUGOKovsxq)
            (maybe (NO.kaeyuo NO.UvmsoItqOguTOLqtuld)
                   (NO.kaeyuo . NO.XvswJUBeroci)
            )
            nogcVassuVvbFiew
      kyxson = vzahxEooRecOriqdp apneZejuzTfuQkuJosqoa

#test base level for operands
func = do
  pure
    $!! otherFunc
          (SomeLargeRecord { aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1
                           , bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = 2
                           , cccccccccccccccccccccccccccccccccc = 3
                           }
          )
          anotherArgument

#test yet another invalid do-block operator alignment
func = do
  it "some long description does not matter" $ do
    some long function invocation (plus a paren + ed operator expression)
      `shouldReturn` all ((==) True)
      :: IO ()

#test allow operator plus paragraph case-of BlockArgument
func arg = abc ++ def ++ case arg of
  False -> ghi
  True  -> jkl
