diff --git a/cabal.project b/cabal.project index c063a3fc3e..5ad04de72b 100644 --- a/cabal.project +++ b/cabal.project @@ -2,6 +2,11 @@ packages: ./ ghcide +source-repository-package + type: git + location: https://github.com/bubba/brittany.git + tag: c59655f10d5ad295c2481537fc8abf0a297d9d1c + tests: true package * @@ -14,4 +19,6 @@ package ghcide write-ghc-environment-files: never -index-state: 2020-07-27T12:40:45Z +index-state: 2020-08-07T11:45:57Z + +allow-newer: data-tree-print:base diff --git a/exe/Main.hs b/exe/Main.hs index a13d4d875f..725a752b95 100644 --- a/exe/Main.hs +++ b/exe/Main.hs @@ -67,10 +67,11 @@ import Ide.Plugin.Example as Example import Ide.Plugin.Example2 as Example2 import Ide.Plugin.GhcIde as GhcIde import Ide.Plugin.Floskell as Floskell +import Ide.Plugin.Fourmolu as Fourmolu import Ide.Plugin.Ormolu as Ormolu import Ide.Plugin.StylishHaskell as StylishHaskell import Ide.Plugin.Retrie as Retrie -#if AGPL && !MIN_VERSION_ghc(8,10,1) +#if AGPL import Ide.Plugin.Brittany as Brittany #endif import Ide.Plugin.Pragmas as Pragmas @@ -102,15 +103,14 @@ idePlugins includeExamples = pluginDescToIdePlugins allPlugins GhcIde.descriptor "ghcide" , Pragmas.descriptor "pragmas" , Floskell.descriptor "floskell" + , Fourmolu.descriptor "fourmolu" -- , genericDescriptor "generic" -- , ghcmodDescriptor "ghcmod" , Ormolu.descriptor "ormolu" , StylishHaskell.descriptor "stylish-haskell" , Retrie.descriptor "retrie" #if AGPL -#if !MIN_VERSION_ghc(8,10,1) , Brittany.descriptor "brittany" -#endif #endif , Eval.descriptor "eval" ] diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 3543db1c7e..488b6b684b 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -45,6 +45,7 @@ library Ide.Plugin.Eval Ide.Plugin.Example Ide.Plugin.Example2 + Ide.Plugin.Fourmolu Ide.Plugin.GhcIde Ide.Plugin.Ormolu Ide.Plugin.Pragmas @@ -72,6 +73,7 @@ library , extra , filepath , floskell == 0.10.* + , fourmolu ^>= 0.1 , ghc , ghc-boot-th , ghcide >= 0.1 @@ -101,11 +103,10 @@ library else build-depends: unix if flag(agpl) - if impl(ghc < 8.10) - build-depends: - brittany - exposed-modules: - Ide.Plugin.Brittany + build-depends: + brittany + exposed-modules: + Ide.Plugin.Brittany ghc-options: -Wall @@ -223,7 +224,7 @@ common hls-test-utils , hslogger , hspec , hspec-core - , lsp-test >= 0.11.0.3 + , lsp-test >= 0.11.0.4 , stm , tasty-hunit , temporary @@ -252,7 +253,7 @@ test-suite func-test , haskell-lsp , haskell-lsp-types , lens - , lsp-test >= 0.11.0.3 + , lsp-test >= 0.11.0.4 , tasty , tasty-ant-xml >= 1.1.6 , tasty-expected-failure diff --git a/shell.nix b/shell.nix index 7f0ffcc9be..076161c96f 100644 --- a/shell.nix +++ b/shell.nix @@ -42,6 +42,7 @@ let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc. data-default-instances-old-locale extra floskell + fourmolu fuzzy generic-deriving ghc-check diff --git a/src/Ide/Plugin/Fourmolu.hs b/src/Ide/Plugin/Fourmolu.hs new file mode 100644 index 0000000000..07d4272b95 --- /dev/null +++ b/src/Ide/Plugin/Fourmolu.hs @@ -0,0 +1,95 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE PackageImports #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} + +module Ide.Plugin.Fourmolu + ( + descriptor + , provider + ) +where + +import Control.Exception +import qualified Data.Text as T +import Development.IDE.Core.Rules +import Development.IDE.Core.RuleTypes (GhcSession (GhcSession)) +import Development.IDE.Core.Shake (use) +import Development.IDE.GHC.Util (hscEnv) +import Development.IDE.Types.Diagnostics as D +import Development.IDE.Types.Location +import qualified DynFlags as D +import qualified EnumSet as S +import GHC +import GHC.LanguageExtensions.Type +import GhcPlugins (HscEnv (hsc_dflags)) +import Ide.Plugin.Formatter +import Ide.PluginUtils +import Ide.Types +import Language.Haskell.LSP.Core (LspFuncs (withIndefiniteProgress), + ProgressCancellable (Cancellable)) +import Language.Haskell.LSP.Types +import "fourmolu" Ormolu +import System.FilePath (takeFileName) +import Text.Regex.TDFA.Text () + +-- --------------------------------------------------------------------- + +descriptor :: PluginId -> PluginDescriptor +descriptor plId = (defaultPluginDescriptor plId) + { pluginFormattingProvider = Just provider + } + +-- --------------------------------------------------------------------- + +provider :: FormattingProvider IO +provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancellable $ do + let + fromDyn :: DynFlags -> IO [DynOption] + fromDyn df = + let + pp = + let p = D.sPgm_F $ D.settings df + in if null p then [] else ["-pgmF=" <> p] + pm = map (("-fplugin=" <>) . moduleNameString) $ D.pluginModNames df + ex = map showExtension $ S.toList $ D.extensionFlags df + in + return $ map DynOption $ pp <> pm <> ex + + ghc <- runAction "Fourmolu" ideState $ use GhcSession fp + let df = hsc_dflags . hscEnv <$> ghc + fileOpts <- case df of + Nothing -> return [] + Just df -> fromDyn df + + let + fullRegion = RegionIndices Nothing Nothing + rangeRegion s e = RegionIndices (Just $ s + 1) (Just $ e + 1) + mkConf o region = do + printerOpts <- loadConfigFile True (Just fp') defaultPrinterOpts + return $ defaultConfig + { cfgDynOptions = o + , cfgRegion = region + , cfgDebug = True + , cfgPrinterOpts = printerOpts + } + fmt :: T.Text -> Config RegionIndices -> IO (Either OrmoluException T.Text) + fmt cont conf = + try @OrmoluException (ormolu conf fp' $ T.unpack cont) + fp' = fromNormalizedFilePath fp + + case typ of + FormatText -> ret <$> (fmt contents =<< mkConf fileOpts fullRegion) + FormatRange (Range (Position sl _) (Position el _)) -> + ret <$> (fmt contents =<< mkConf fileOpts (rangeRegion sl el)) + where + title = T.pack $ "Formatting " <> takeFileName (fromNormalizedFilePath fp) + ret :: Either OrmoluException T.Text -> Either ResponseError (List TextEdit) + ret (Left err) = Left + (responseError (T.pack $ "fourmoluCmd: " ++ show err) ) + ret (Right new) = Right (makeDiffTextEdit contents new) + +showExtension :: Extension -> String +showExtension Cpp = "-XCPP" +showExtension other = "-X" ++ show other diff --git a/src/Ide/Plugin/Ormolu.hs b/src/Ide/Plugin/Ormolu.hs index dcfad0b16a..e5d268232b 100644 --- a/src/Ide/Plugin/Ormolu.hs +++ b/src/Ide/Plugin/Ormolu.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE PackageImports #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -29,7 +30,7 @@ import Ide.Types import Language.Haskell.LSP.Core (LspFuncs (withIndefiniteProgress), ProgressCancellable (Cancellable)) import Language.Haskell.LSP.Types -import Ormolu +import "ormolu" Ormolu import System.FilePath (takeFileName) import Text.Regex.TDFA.Text () diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 8d62e3c008..f1494f4265 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -8,19 +8,25 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - Cabal-3.0.2.0 - hie-bios-0.6.1 - cabal-plan-0.7.0.0 - clock-0.7.2 -- floskell-0.10.3 +- data-tree-print-0.1.0.2 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 - ghc-exactprint-0.6.3 +- HsYAML-aeson-0.2.0.0@rev:2 - lens-4.19.1 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - optics-core-0.3 - ormolu-0.1.2.0 - retrie-0.1.1.1 -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - semigroups-0.18.5 - temporary-1.2.1.1 - these-1.1 @@ -28,14 +34,11 @@ extra-deps: flags: haskell-language-server: pedantic: true - # We want to let agpl be the default value in .cabal (True) - # but brittany is not usable with ghc-8.10.1 - # see https://github.com/lspitzner/brittany/issues/269 - agpl: false retrie: BuildExecutable: false -# allow-newer: true +# for data-tree-print's bounds on base (>=4.8 && <4.14); using base-4.14.0.0. +allow-newer: true nix: packages: [ icu libcxx zlib ] diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 307f1a86b9..896254b08e 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -9,15 +9,18 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - ansi-terminal-0.10.3 -- base-compat-0.11.0 -- brittany-0.12.1.1@rev:2 +- base-compat-0.10.5 +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 - clock-0.7.2 - extra-1.7.3 -- floskell-0.10.3 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 @@ -30,16 +33,17 @@ extra-deps: - haskell-lsp-types-0.22.0.0 - hie-bios-0.6.1 - HsYAML-0.2.1.0@rev:1 -- HsYAML-aeson-0.2.0.0@rev:1 +- HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - opentelemetry-0.4.2 - optics-core-0.2 - optparse-applicative-0.15.1.0 - ormolu-0.1.2.0 - parser-combinators-1.2.1 +- primitive-0.7.1.0 - regex-base-0.94.0.0 - regex-pcre-builtin-0.95.1.1.8.43 - regex-tdfa-1.3.1.0 @@ -47,9 +51,10 @@ extra-deps: - semialign-1.1 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - tasty-rerun-1.1.17 - temporary-1.2.1.1 +- these-1.1.1.1 - type-equality-1 - topograph-1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index fe45cb734a..605591b432 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -8,15 +8,18 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - ansi-terminal-0.10.3 -- base-compat-0.11.0 -- brittany-0.12.1.1@rev:2 +- base-compat-0.10.5 +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 - clock-0.7.2 - extra-1.7.3 -- floskell-0.10.3 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 @@ -29,16 +32,17 @@ extra-deps: - haskell-lsp-types-0.22.0.0 - hie-bios-0.6.1 - HsYAML-0.2.1.0@rev:1 -- HsYAML-aeson-0.2.0.0@rev:1 +- HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - opentelemetry-0.4.2 - optics-core-0.2 - optparse-applicative-0.15.1.0 - ormolu-0.1.2.0 - parser-combinators-1.2.1 +- primitive-0.7.1.0 - regex-base-0.94.0.0 - regex-pcre-builtin-0.95.1.1.8.43 - regex-tdfa-1.3.1.0 @@ -46,9 +50,10 @@ extra-deps: - semialign-1.1 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - tasty-rerun-1.1.17 - temporary-1.2.1.1 +- these-1.1.1.1 - type-equality-1 - topograph-1 diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index 0d3b2d5ca3..131969fa4c 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -8,14 +8,17 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - apply-refact-0.7.0.0 -- brittany-0.12.1.1 +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.2 - bytestring-trie-0.2.5.0 - clock-0.7.2 - constrained-dynamic-0.1.0.0 - extra-1.7.3 -- floskell-0.10.3 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 # - ghcide-0.1.0 - ghc-check-0.5.0.1 - ghc-lib-parser-8.10.1.20200523 @@ -29,9 +32,9 @@ extra-deps: - hoogle-5.0.17.11 - hsimport-0.11.0 - HsYAML-0.2.1.0@rev:1 -- HsYAML-aeson-0.2.0.0@rev:1 +- HsYAML-aeson-0.2.0.0@rev:2 - ilist-0.3.1.0 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - opentelemetry-0.4.2 - ormolu-0.1.2.0 @@ -39,8 +42,9 @@ extra-deps: - semigroups-0.18.5 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - temporary-1.2.1.1 +- these-1.1.1.1 flags: haskell-language-server: diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index 71a81374c1..c52d3afe2a 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -8,26 +8,32 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - apply-refact-0.7.0.0 +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - bytestring-trie-0.2.5.0 - cabal-plan-0.6.2.0 - clock-0.7.2 - constrained-dynamic-0.1.0.0 - extra-1.7.3 -- floskell-0.10.3 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 # - ghcide-0.1.0 - haskell-src-exts-1.21.1 - hie-bios-0.6.1 - hlint-2.2.8 +- HsYAML-aeson-0.2.0.0@rev:2 - hoogle-5.0.17.11 - hsimport-0.11.0 - ilist-0.3.1.0 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - retrie-0.1.1.1 - semigroups-0.18.5 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef +- stylish-haskell-0.11.0.3 - temporary-1.2.1.1 flags: diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index d2f1d8449a..08ce987d48 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -9,25 +9,31 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - apply-refact-0.7.0.0 +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - bytestring-trie-0.2.5.0 - cabal-helper-1.1.0.0 - cabal-plan-0.6.2.0 - clock-0.7.2 - constrained-dynamic-0.1.0.0 - extra-1.7.3 -- floskell-0.10.3 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 # - ghcide-0.1.0 - haskell-src-exts-1.21.1 - hie-bios-0.6.1 - hlint-2.2.8 +- HsYAML-aeson-0.2.0.0@rev:2 - hoogle-5.0.17.11 - hsimport-0.11.0 - ilist-0.3.1.0 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - retrie-0.1.1.1 - semigroups-0.18.5 +- stylish-haskell-0.11.0.3 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef - temporary-1.2.1.1 diff --git a/stack.yaml b/stack.yaml index a3fb790819..2350fff2d5 100644 --- a/stack.yaml +++ b/stack.yaml @@ -8,15 +8,18 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 -- brittany-0.12.1.1@rev:2 +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 - clock-0.7.2 - extra-1.7.3 -- floskell-0.10.3 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 @@ -29,10 +32,10 @@ extra-deps: - haskell-lsp-types-0.22.0.0 - hie-bios-0.6.1 - HsYAML-0.2.1.0@rev:1 -- HsYAML-aeson-0.2.0.0@rev:1 +- HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - opentelemetry-0.4.2 - optics-core-0.2 @@ -44,7 +47,7 @@ extra-deps: - regex-tdfa-1.3.1.0 - retrie-0.1.1.1 - semialign-1.1 -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - tasty-rerun-1.1.17 - temporary-1.2.1.1 - type-equality-1 diff --git a/test/functional/Format.hs b/test/functional/Format.hs index 11fc65123d..0bb2ee4944 100644 --- a/test/functional/Format.hs +++ b/test/functional/Format.hs @@ -12,8 +12,7 @@ import Test.Tasty import Test.Tasty.Golden import Test.Tasty.HUnit -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL import qualified Data.Text.IO as T #endif @@ -30,12 +29,11 @@ tests = testGroup "format document" [ , rangeTests , providerTests , stylishHaskellTests --- There's no Brittany formatter on the 8.10.1 builds (yet) -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL , brittanyTests #endif , ormoluTests + , fourmoluTests ] rangeTests :: TestTree @@ -62,9 +60,7 @@ providerTests = testGroup "formatting provider" [ formatRange doc (FormattingOptions 2 True) (Range (Position 1 0) (Position 3 10)) documentContents doc >>= liftIO . (@?= orig) --- There's no Brittany formatter on the 8.10.1 builds (yet) -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL , testCase "can change on the fly" $ runSession hieCommand fullCaps "test/testdata" $ do formattedBrittany <- liftIO $ T.readFile "test/testdata/Format.brittany.formatted.hs" formattedFloskell <- liftIO $ T.readFile "test/testdata/Format.floskell.formatted.hs" @@ -113,8 +109,7 @@ stylishHaskellTests = testGroup "stylish-haskell" [ BS.fromStrict . T.encodeUtf8 <$> documentContents doc ] -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL brittanyTests :: TestTree brittanyTests = testGroup "brittany" [ goldenVsStringDiff "formats a document with LF endings" goldenGitDiff "test/testdata/BrittanyLF.formatted_document.hs" $ runSession hieCommand fullCaps "test/testdata" $ do @@ -159,11 +154,24 @@ ormoluTests = testGroup "ormolu" BS.fromStrict . T.encodeUtf8 <$> documentContents doc ] +fourmoluTests :: TestTree +fourmoluTests = testGroup "fourmolu" + [ goldenVsStringDiff "formats correctly" goldenGitDiff "test/testdata/Format.fourmolu.formatted.hs" $ runSession hieCommand fullCaps "test/testdata" $ do + sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "fourmolu")) + doc <- openDoc "Format.hs" "haskell" + formatDoc doc (FormattingOptions 4 True) + BS.fromStrict . T.encodeUtf8 <$> documentContents doc + , goldenVsStringDiff "formats imports correctly" goldenGitDiff "test/testdata/Format2.fourmolu.formatted.hs" $ runSession hieCommand fullCaps "test/testdata" $ do + sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "fourmolu")) + doc <- openDoc "Format2.hs" "haskell" + formatDoc doc (FormattingOptions 4 True) + BS.fromStrict . T.encodeUtf8 <$> documentContents doc + ] + formatLspConfig :: Value -> Value formatLspConfig provider = object [ "haskell" .= object ["formattingProvider" .= (provider :: Value)] ] -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL -- | The same as 'formatLspConfig' but using the legacy section name formatLspConfigOld :: Value -> Value formatLspConfigOld provider = object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ] diff --git a/test/testdata/Format.brittany.formatted.hs b/test/testdata/Format.brittany.formatted.hs index d3da590142..9ecc458524 100644 --- a/test/testdata/Format.brittany.formatted.hs +++ b/test/testdata/Format.brittany.formatted.hs @@ -11,5 +11,8 @@ bar s = do x <- return "hello" return "asdf" -data Baz = Baz { a :: Int, b :: String } +data Baz = Baz + { a :: Int + , b :: String + } diff --git a/test/testdata/Format.brittany_post_floskell.formatted.hs b/test/testdata/Format.brittany_post_floskell.formatted.hs index 02de9c673d..9cbb33715c 100644 --- a/test/testdata/Format.brittany_post_floskell.formatted.hs +++ b/test/testdata/Format.brittany_post_floskell.formatted.hs @@ -13,5 +13,8 @@ bar s = do x <- return "hello" return "asdf" -data Baz = Baz { a :: Int, b :: String } +data Baz = Baz + { a :: Int + , b :: String + } diff --git a/test/testdata/Format.fourmolu.formatted.hs b/test/testdata/Format.fourmolu.formatted.hs new file mode 100644 index 0000000000..41dba5b34d --- /dev/null +++ b/test/testdata/Format.fourmolu.formatted.hs @@ -0,0 +1,16 @@ +module Format where + +import Data.Int +import Data.List +import Prelude + +foo :: Int -> Int +foo 3 = 2 +foo x = x + +bar :: String -> IO String +bar s = do + x <- return "hello" + return "asdf" + +data Baz = Baz {a :: Int, b :: String} diff --git a/test/testdata/Format2.fourmolu.formatted.hs b/test/testdata/Format2.fourmolu.formatted.hs new file mode 100644 index 0000000000..b3d867e700 --- /dev/null +++ b/test/testdata/Format2.fourmolu.formatted.hs @@ -0,0 +1,5 @@ +import Data.Bool +import Data.Char +import Data.Data +import Data.Either +import Data.Int