1
1
mirror of https://github.com/tweag/ormolu.git synced 2024-10-04 00:47:24 +03:00

ghc-lib-parser 9.8

This commit is contained in:
Alexander Esgen 2023-07-30 16:05:07 +02:00 committed by Mark Karpov
parent 39db791bf3
commit fc0221cb04
38 changed files with 356 additions and 163 deletions

View File

@ -12,7 +12,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
ghc: [ghc928, ghc945, ghc962] ghc: [ghc947, ghc963, ghc981]
name: Build and test on ${{ matrix.ghc }} name: Build and test on ${{ matrix.ghc }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -133,7 +133,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: haskell/actions/setup@v2 - uses: haskell-actions/setup@v2
with: with:
enable-stack: true enable-stack: true
stack-no-global: true stack-no-global: true

View File

@ -1,3 +1,13 @@
## Unreleased
* Switched to `ghc-lib-parser-9.8`, with the following new syntactic features:
* `ExtendedLiterals`: `123#Int8` is a literal of type `Int8#`. (disabled by
default)
* `TypeAbstractions`: `@k`-binders in data type declarations (enabled by
default)
* GHC proposal [#134](https://github.com/ghc-proposals/ghc-proposals/blob/0b652bd70258e354dfe4a05940182007596f8bf7/proposals/0134-deprecating-exports-proposal.rst): deprecating/warning about exports
* GHC proposal [#541](https://github.com/ghc-proposals/ghc-proposals/blob/0b652bd70258e354dfe4a05940182007596f8bf7/proposals/0541-warning-pragmas-with-categories.rst): warning categories
## Ormolu 0.7.2.0 ## Ormolu 0.7.2.0
* Preserve necessary braces for final function arguments. [Issue * Preserve necessary braces for final function arguments. [Issue

View File

@ -0,0 +1,2 @@
type T :: forall k. k -> forall j. j -> Type
data T @k (a :: k) @(j :: Type) (b :: j)

View File

@ -0,0 +1,2 @@
type T :: forall k. k -> forall j. j -> Type
data T @k (a :: k) @(j :: Type) (b :: j)

View File

@ -1,3 +1,5 @@
infix 0 <?> infix 0 <?>
infix 9 <^-^> infix 9 <^-^>
infix 2 ->

View File

@ -1,2 +1,4 @@
infix 0 <?> infix 0 <?>
infix 9 <^-^> infix 9 <^-^>
infix 2 ->

View File

@ -0,0 +1,10 @@
{-# LANGUAGE ExtendedLiterals #-}
{-# LANGUAGE MagicHash #-}
foo = 1#
bar = 2##
baz = 3#Word32
baz = 0b1010#Int64

View File

@ -0,0 +1,9 @@
{-# LANGUAGE ExtendedLiterals, MagicHash #-}
foo = 1#
bar = 2##
baz = 3#Word32
baz = 0b1010#Int64

View File

@ -11,3 +11,6 @@ baz = 5
data Number = Number Dobule data Number = Number Dobule
{-# DEPRECATED Number "Use Scientific instead." #-} {-# DEPRECATED Number "Use Scientific instead." #-}
head (a : _) = a
{-# WARNING in "x-partial" head "This function is partial..." #-}

View File

@ -13,3 +13,6 @@ baz = 5
data Number = Number Dobule data Number = Number Dobule
{-# DEPRECATED Number "Use Scientific instead." #-} {-# DEPRECATED Number "Use Scientific instead." #-}
head (a:_) = a
{-# WARNING in "x-partial" head "This function is partial..." #-}

View File

@ -0,0 +1,7 @@
module X
( {-# DEPRECATE D(D1) "D1 will not be exposed in a version 0.2 and later" #-}
D (D1, D2),
)
where
data D = D1 | D2

View File

@ -0,0 +1,5 @@
module X
( {-# DEPRECATE D(D1) "D1 will not be exposed in a version 0.2 and later" #-}
D(D1, D2)
) where
data D = D1 | D2

View File

@ -0,0 +1,3 @@
module A ({-# DEPRECATED "blah" #-} x) where
x = True

View File

@ -0,0 +1 @@
module A ( {-# DEPRECATED "blah" #-} x ) where { x = True }

View File

@ -13,8 +13,8 @@ src/Extension.hs
Formatting is not idempotent. Formatting is not idempotent.
Please, consider reporting the bug. Please, consider reporting the bug.
src/Hint/Bracket.hs src/Hint/Bracket.hs
@@ -259,8 +259,11 @@ @@ -258,8 +258,11 @@
let y = noLocA $ HsApp EpAnnNotUsed a1 (noLocA (HsPar EpAnnNotUsed a2)), let y = noLocA $ HsApp EpAnnNotUsed a1 (nlHsPar a2),
let r = Replace Expr (toSSA e) [("a", toSSA a1), ("b", toSSA a2)] "a (b)" let r = Replace Expr (toSSA e) [("a", toSSA a1), ("b", toSSA a2)] "a (b)"
] ]
- ++ [ (suggest "Redundant bracket" (reLoc x) (reLoc y) [r]) {ideaSpan -- Special case of (v1 . v2) <$> v3 - ++ [ (suggest "Redundant bracket" (reLoc x) (reLoc y) [r]) {ideaSpan -- Special case of (v1 . v2) <$> v3
@ -24,7 +24,7 @@ src/Hint/Bracket.hs
+ = + =
+ locA locPar + locA locPar
+ } + }
| L _ (OpApp _ (L locPar (HsPar _ o1@(L locNoPar (OpApp _ _ (isDot -> True) _)))) o2 v3) <- [x], | L _ (OpApp _ (L locPar (HsPar _ _ o1@(L locNoPar (OpApp _ _ (isDot -> True) _)) _)) o2 v3) <- [x],
varToStr o2 == "<$>", varToStr o2 == "<$>",
let y = noLocA (OpApp EpAnnNotUsed o1 o2 v3) :: LHsExpr GhcPs, let y = noLocA (OpApp EpAnnNotUsed o1 o2 v3) :: LHsExpr GhcPs,

View File

@ -1,5 +1,5 @@
src/Text/Pandoc/Readers/Org/Inlines.hs src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -182,7 +182,8 @@ @@ -186,7 +186,8 @@
cs' <- cs cs' <- cs
case cs' of case cs' of
[] -> return [] [] -> return []
@ -13,7 +13,7 @@ src/Text/Pandoc/Readers/Org/Inlines.hs
Formatting is not idempotent. Formatting is not idempotent.
Please, consider reporting the bug. Please, consider reporting the bug.
src/Text/Pandoc/Readers/RST.hs src/Text/Pandoc/Readers/RST.hs
@@ -1124,7 +1124,7 @@ @@ -1125,7 +1125,7 @@
-- if no ":class:" field is given, the default is the role name -- if no ":class:" field is given, the default is the role name
classFieldClasses = maybe [role] T.words (lookup "class" fields) classFieldClasses = maybe [role] T.words (lookup "class" fields)
- -- nub in case role name & language class are the same - -- nub in case role name & language class are the same

View File

@ -15,7 +15,7 @@ executable extract-hackage-info
base >=4.12 && <5.0, base >=4.12 && <5.0,
binary >=0.8 && <0.9, binary >=0.8 && <0.9,
bytestring >=0.10 && <0.13, bytestring >=0.10 && <0.13,
containers >=0.6 && <0.7, containers >=0.6 && <0.8,
directory >=1.0 && <2.0, directory >=1.0 && <2.0,
filepath >=1.2 && <1.5, filepath >=1.2 && <1.5,
optparse-applicative >=0.14 && <0.19, optparse-applicative >=0.14 && <0.19,
@ -23,6 +23,3 @@ executable extract-hackage-info
text >=2.0 && <3.0, text >=2.0 && <3.0,
formatting >=7.1 && <7.3, formatting >=7.1 && <7.3,
megaparsec >=9.0 megaparsec >=9.0
if !impl(ghc >=9.2 && <9.3)
buildable: False

View File

@ -177,11 +177,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1689068808, "lastModified": 1694529238,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -191,17 +191,19 @@
} }
}, },
"flake-utils_2": { "flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": { "locked": {
"lastModified": 1679360468, "lastModified": 1692799911,
"narHash": "sha256-LGnza3cfXF10Biw3ZTg0u9o9t7s680Ww200t5KkHTh8=", "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
"owner": "hamishmack", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "e1ea268ff47ad475443dbabcd54744b4e5b9d4f5", "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "hamishmack", "owner": "numtide",
"ref": "hkm/nested-hydraJobs",
"repo": "flake-utils", "repo": "flake-utils",
"type": "github" "type": "github"
} }
@ -270,16 +272,16 @@
}, },
"ghc-wasm-meta": { "ghc-wasm-meta": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"host": "gitlab.haskell.org", "host": "gitlab.haskell.org",
"lastModified": 1693212235, "lastModified": 1696827923,
"narHash": "sha256-N3zIrWxMV+eE/gCkUw/GzM3RyX8kkxLAwsWLHDip9hA=", "narHash": "sha256-SJYF9+O3n7KIumeSgPsj10tZsVEH4bI4yourZx+aSvs=",
"owner": "ghc", "owner": "ghc",
"repo": "ghc-wasm-meta", "repo": "ghc-wasm-meta",
"rev": "28ee3192f8be23761cfa6f89b2656bfef763c028", "rev": "aeec925988b64371f593eb17660d0a1794ab245d",
"type": "gitlab" "type": "gitlab"
}, },
"original": { "original": {
@ -289,6 +291,43 @@
"type": "gitlab" "type": "gitlab"
} }
}, },
"ghc98X": {
"flake": false,
"locked": {
"lastModified": 1696643148,
"narHash": "sha256-E02DfgISH7EvvNAu0BHiPvl1E5FGMDi0pWdNZtIBC9I=",
"ref": "ghc-9.8",
"rev": "443e870d977b1ab6fc05f47a9a17bc49296adbd6",
"revCount": 61642,
"submodules": true,
"type": "git",
"url": "https://gitlab.haskell.org/ghc/ghc"
},
"original": {
"ref": "ghc-9.8",
"submodules": true,
"type": "git",
"url": "https://gitlab.haskell.org/ghc/ghc"
}
},
"ghc99": {
"flake": false,
"locked": {
"lastModified": 1697054644,
"narHash": "sha256-kKarOuXUaAH3QWv7ASx+gGFMHaHKe0pK5Zu37ky2AL4=",
"ref": "refs/heads/master",
"rev": "f383a242c76f90bcca8a4d7ee001dcb49c172a9a",
"revCount": 62040,
"submodules": true,
"type": "git",
"url": "https://gitlab.haskell.org/ghc/ghc"
},
"original": {
"submodules": true,
"type": "git",
"url": "https://gitlab.haskell.org/ghc/ghc"
}
},
"gitignore": { "gitignore": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -313,11 +352,11 @@
"hackage": { "hackage": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1692231735, "lastModified": 1697329475,
"narHash": "sha256-75jxGw+Mzt/2OzTz9gRb5LPwysq76JyNMBjDzMTAdXE=", "narHash": "sha256-cyp4bvVyDWa27pv6Fc9mIXM7+Kn9dNv2tlGx13A0XsI=",
"owner": "input-output-hk", "owner": "input-output-hk",
"repo": "hackage.nix", "repo": "hackage.nix",
"rev": "7624c4239624ba595c41b81e05aa147c86cd8235", "rev": "c1d90e14c6ea1048275a97cd56546c3db116ad47",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -334,11 +373,15 @@
"cabal-36": "cabal-36", "cabal-36": "cabal-36",
"cardano-shell": "cardano-shell", "cardano-shell": "cardano-shell",
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils_2",
"ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "ghc-8.6.5-iohk": "ghc-8.6.5-iohk",
"ghc98X": "ghc98X",
"ghc99": "ghc99",
"hackage": "hackage", "hackage": "hackage",
"hls-1.10": "hls-1.10", "hls-1.10": "hls-1.10",
"hls-2.0": "hls-2.0", "hls-2.0": "hls-2.0",
"hls-2.2": "hls-2.2",
"hls-2.3": "hls-2.3",
"hls-2.4": "hls-2.4",
"hpc-coveralls": "hpc-coveralls", "hpc-coveralls": "hpc-coveralls",
"hydra": "hydra", "hydra": "hydra",
"iserv-proxy": "iserv-proxy", "iserv-proxy": "iserv-proxy",
@ -357,11 +400,11 @@
"stackage": "stackage" "stackage": "stackage"
}, },
"locked": { "locked": {
"lastModified": 1692254824, "lastModified": 1697331007,
"narHash": "sha256-U18N6WYvVidlKBZjt61QsIK/PLccmM2Gv6BSJgr3uqE=", "narHash": "sha256-QlYAA297LBDka7S6llYzVD4ZVjoWxEIQA5i/0y6gRdE=",
"owner": "input-output-hk", "owner": "input-output-hk",
"repo": "haskell.nix", "repo": "haskell.nix",
"rev": "0ad4dcb7286ec71fbf3b90626758bf67772a408c", "rev": "928f59ac2f6d6c371b7564d82a39de77b51c5d23",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -404,6 +447,57 @@
"type": "github" "type": "github"
} }
}, },
"hls-2.2": {
"flake": false,
"locked": {
"lastModified": 1693064058,
"narHash": "sha256-8DGIyz5GjuCFmohY6Fa79hHA/p1iIqubfJUTGQElbNk=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "b30f4b6cf5822f3112c35d14a0cba51f3fe23b85",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.2.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.3": {
"flake": false,
"locked": {
"lastModified": 1695910642,
"narHash": "sha256-tR58doOs3DncFehHwCLczJgntyG/zlsSd7DgDgMPOkI=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "458ccdb55c9ea22cd5d13ec3051aaefb295321be",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.3.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hls-2.4": {
"flake": false,
"locked": {
"lastModified": 1696939266,
"narHash": "sha256-VOMf5+kyOeOmfXTHlv4LNFJuDGa7G3pDnOxtzYR40IU=",
"owner": "haskell",
"repo": "haskell-language-server",
"rev": "362fdd1293efb4b82410b676ab1273479f6d17ee",
"type": "github"
},
"original": {
"owner": "haskell",
"ref": "2.4.0.0",
"repo": "haskell-language-server",
"type": "github"
}
},
"hpc-coveralls": { "hpc-coveralls": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -446,11 +540,11 @@
"iserv-proxy": { "iserv-proxy": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1688517130, "lastModified": 1691634696,
"narHash": "sha256-hUqfxSlo+ffqVdkSZ1EDoB7/ILCL25eYkcCXW9/P3Wc=", "narHash": "sha256-MZH2NznKC/gbgBu8NgIibtSUZeJ00HTLJ0PlWKCBHb0=",
"ref": "hkm/remote-iserv", "ref": "hkm/remote-iserv",
"rev": "9151db2a9a61d7f5fe52ff8836f18bbd0fd8933c", "rev": "43a979272d9addc29fbffc2e8542c5d96e993d73",
"revCount": 13, "revCount": 14,
"type": "git", "type": "git",
"url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git"
}, },
@ -549,11 +643,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1691371061, "lastModified": 1694343207,
"narHash": "sha256-BxPbPVlBIoneaXIBiHd0LVzA+L4nmvFCNBU6TmQAiMM=", "narHash": "sha256-jWi7OwFxU5Owi4k2JmiL1sa/OuBCQtpaAesuj5LXC8w=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5068bc8fe943bde3c446326da8d0ca9c93d5a682", "rev": "78058d810644f5ed276804ce7ea9e82d92bee293",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -645,11 +739,11 @@
}, },
"nixpkgs-2305": { "nixpkgs-2305": {
"locked": { "locked": {
"lastModified": 1690680713, "lastModified": 1695416179,
"narHash": "sha256-NXCWA8N+GfSQyoN7ZNiOgq/nDJKOp5/BHEpiZP8sUZw=", "narHash": "sha256-610o1+pwbSu+QuF3GE0NU5xQdTHM3t9wyYhB9l94Cd8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b81af66deb21f73a70c67e5ea189568af53b1e8c", "rev": "715d72e967ec1dd5ecc71290ee072bcaf5181ed6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -677,27 +771,27 @@
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1673800717, "lastModified": 1685801374,
"narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=", "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f", "rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-22.11", "ref": "nixos-23.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1690720142, "lastModified": 1695318763,
"narHash": "sha256-GywuiZjBKfFkntQwpNQfL+Ksa2iGjPprBGL0/psgRZM=", "narHash": "sha256-FHVPDRP2AfvsxAdc+AsgFJevMz5VBmnZglFUMlxBkcY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3acb5c4264c490e7714d503c7166a3fde0c51324", "rev": "e12483116b3b51a185a33a272bf351e357ba9a99",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -844,11 +938,11 @@
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1678376203, "lastModified": 1696846637,
"narHash": "sha256-3tyYGyC8h7fBwncLZy5nCUjTJPrHbmNwp47LlNLOHSM=", "narHash": "sha256-0hv4kbXxci2+pxhuXlVgftj/Jq79VSmtAyvfabCCtYk=",
"owner": "cachix", "owner": "cachix",
"repo": "pre-commit-hooks.nix", "repo": "pre-commit-hooks.nix",
"rev": "1a20b9708962096ec2481eeb2ddca29ed747770a", "rev": "42e1b6095ef80a51f79595d9951eb38e91c4e6ca",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -865,11 +959,11 @@
"utils": "utils_2" "utils": "utils_2"
}, },
"locked": { "locked": {
"lastModified": 1675987041, "lastModified": 1691537451,
"narHash": "sha256-0aHIrngBLXO95SH+PjyTWJ7LWoFdJtx8y6oSln0l5Ak=", "narHash": "sha256-9dnX6E7eWVm8xhHDeA3AmkvhqcWRo6RJ4z6Vrn65cFs=",
"owner": "purs-nix", "owner": "purs-nix",
"repo": "purescript-tools", "repo": "purescript-tools",
"rev": "7929148939325f1fed916884c53cad3c0dfa4be7", "rev": "675cd35bc9255f9c2b1f6f6784ef41b9773202e8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -891,11 +985,11 @@
"utils": "utils_3" "utils": "utils_3"
}, },
"locked": { "locked": {
"lastModified": 1677820987, "lastModified": 1691603627,
"narHash": "sha256-5lrWnpC39a0M9VL7GzP88K+bTzAZP9AjLNQpbtsfuUw=", "narHash": "sha256-bsJh6PCDF9+hSuk/dbTtSXdma0VvjFejN6weHPt7cyU=",
"owner": "purs-nix", "owner": "purs-nix",
"repo": "purs-nix", "repo": "purs-nix",
"rev": "e5af208563a8e66f8a78f3b5aeaacea9074bcd27", "rev": "8729b7fbb02822df3fb3988bae94b276e50ca6fc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -907,10 +1001,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": [ "flake-utils": "flake-utils",
"haskellNix",
"flake-utils"
],
"ghc-wasm-meta": "ghc-wasm-meta", "ghc-wasm-meta": "ghc-wasm-meta",
"haskellNix": "haskellNix", "haskellNix": "haskellNix",
"nixpkgs": [ "nixpkgs": [
@ -946,11 +1037,11 @@
"stackage": { "stackage": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1692230916, "lastModified": 1630400035,
"narHash": "sha256-Mm1nPNVgZl8Rdcs/A1cliBQTlzqx1Wv1tMjr9zEwlCE=", "narHash": "sha256-MWaVOCzuFwp09wZIW9iHq5wWen5C69I940N1swZLEQ0=",
"owner": "input-output-hk", "owner": "input-output-hk",
"repo": "stackage.nix", "repo": "empty-flake",
"rev": "cfbafab66ac72fd00d69122d95491fdb78c57b78", "rev": "2040a05b67bf9a669ce17eca56beb14b4206a99a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -974,6 +1065,21 @@
"type": "github" "type": "github"
} }
}, },
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": { "utils": {
"locked": { "locked": {
"lastModified": 1653893745, "lastModified": 1653893745,

View File

@ -1,8 +1,12 @@
{ {
inputs = { inputs = {
haskellNix.url = "github:input-output-hk/haskell.nix"; haskellNix = {
url = "github:input-output-hk/haskell.nix";
# prevent nix-direnv from fetching stackage
inputs.stackage.url = "github:input-output-hk/empty-flake";
};
nixpkgs.follows = "haskellNix/nixpkgs-unstable"; nixpkgs.follows = "haskellNix/nixpkgs-unstable";
flake-utils.follows = "haskellNix/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks = { pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix"; url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -32,7 +36,7 @@
inherit (pkgs) lib haskell-nix; inherit (pkgs) lib haskell-nix;
inherit (haskell-nix) haskellLib; inherit (haskell-nix) haskellLib;
ghcVersions = [ "ghc928" "ghc945" "ghc962" ]; ghcVersions = [ "ghc963" "ghc947" "ghc981" ];
defaultGHCVersion = builtins.head ghcVersions; defaultGHCVersion = builtins.head ghcVersions;
perGHC = lib.genAttrs ghcVersions (ghcVersion: perGHC = lib.genAttrs ghcVersions (ghcVersion:
let let
@ -50,6 +54,10 @@
hackageTests = import ./expected-failures { inherit pkgs ormolu; }; hackageTests = import ./expected-failures { inherit pkgs ormolu; };
regionTests = import ./region-tests { inherit pkgs ormolu; }; regionTests = import ./region-tests { inherit pkgs ormolu; };
fixityTests = import ./fixity-tests { inherit pkgs ormolu; }; fixityTests = import ./fixity-tests { inherit pkgs ormolu; };
weeder = hsPkgs.tool "weeder" {
version = "2.6.0";
modules = [{ reinstallableLibGhc = false; }];
};
packages = lib.recurseIntoAttrs ({ packages = lib.recurseIntoAttrs ({
inherit ormolu; inherit ormolu;
ormoluTests = haskellLib.collectChecks' hsPkgs; ormoluTests = haskellLib.collectChecks' hsPkgs;
@ -57,14 +65,9 @@
} // hackageTests // regionTests // fixityTests } // hackageTests // regionTests // fixityTests
// lib.optionalAttrs (ghcVersion == defaultGHCVersion) { // lib.optionalAttrs (ghcVersion == defaultGHCVersion) {
inherit (hsPkgs.extract-hackage-info.components.exes) extract-hackage-info; inherit (hsPkgs.extract-hackage-info.components.exes) extract-hackage-info;
weeder = pkgs.runCommand weeder = pkgs.runCommand "ormolu-weeder" { buildInputs = [ weeder ]; } ''
"ormolu-weeder"
{
buildInputs = [ (hsPkgs.tool "weeder" "2.4.0") ];
} ''
mkdir -p $out mkdir -p $out
export XDG_CACHE_HOME=$TMPDIR/cache weeder --config ${./weeder.toml} \
weeder --config ${./weeder.dhall} \
--hie-directory ${hsPkgs.ormolu.components.library.hie} \ --hie-directory ${hsPkgs.ormolu.components.library.hie} \
--hie-directory ${hsPkgs.ormolu.components.exes.ormolu.hie} \ --hie-directory ${hsPkgs.ormolu.components.exes.ormolu.hie} \
--hie-directory ${hsPkgs.ormolu.components.tests.tests.hie} \ --hie-directory ${hsPkgs.ormolu.components.tests.tests.hie} \
@ -154,7 +157,7 @@
tools = { tools = {
cabal = "latest"; cabal = "latest";
haskell-language-server = { haskell-language-server = {
src = inputs.haskellNix.inputs."hls-2.0"; src = inputs.haskellNix.inputs."hls-2.4";
configureArgs = "--disable-benchmarks --disable-tests"; configureArgs = "--disable-benchmarks --disable-tests";
}; };
}; };

View File

@ -1,8 +1,6 @@
packages: . .. packages: . ..
index-state: 2023-09-01T14:51:04Z index-state: 2023-10-15T12:29:38Z
allow-newer: all
constraints: text >=2.0 && <2.0.2
package ormolu package ormolu
-- The WASM backend does not support TH. -- The WASM backend does not support TH.

View File

@ -4,7 +4,7 @@ version: 0.7.2.0
license: BSD-3-Clause license: BSD-3-Clause
license-file: LICENSE.md license-file: LICENSE.md
maintainer: Mark Karpov <mark.karpov@tweag.io> maintainer: Mark Karpov <mark.karpov@tweag.io>
tested-with: ghc ==9.2.8 ghc ==9.4.5 ghc ==9.6.2 tested-with: ghc ==9.4.7 ghc ==9.6.3 ghc ==9.8.1
homepage: https://github.com/tweag/ormolu homepage: https://github.com/tweag/ormolu
bug-reports: https://github.com/tweag/ormolu/issues bug-reports: https://github.com/tweag/ormolu/issues
synopsis: A formatter for Haskell source code synopsis: A formatter for Haskell source code
@ -105,12 +105,12 @@ library
base >=4.14 && <5.0, base >=4.14 && <5.0,
binary >=0.8 && <0.9, binary >=0.8 && <0.9,
bytestring >=0.2 && <0.13, bytestring >=0.2 && <0.13,
containers >=0.5 && <0.7, containers >=0.5 && <0.8,
deepseq >=1.4 && <1.6, deepseq >=1.4 && <1.6,
directory ^>=1.3, directory ^>=1.3,
file-embed >=0.0.15 && <0.1, file-embed >=0.0.15 && <0.1,
filepath >=1.2 && <1.5, filepath >=1.2 && <1.5,
ghc-lib-parser >=9.6 && <9.7, ghc-lib-parser >=9.8 && <9.9,
megaparsec >=9.0, megaparsec >=9.0,
mtl >=2.0 && <3.0, mtl >=2.0 && <3.0,
syb >=0.7 && <0.8, syb >=0.7 && <0.8,
@ -139,7 +139,7 @@ executable ormolu
containers >=0.5 && <0.7, containers >=0.5 && <0.7,
directory ^>=1.3, directory ^>=1.3,
filepath >=1.2 && <1.5, filepath >=1.2 && <1.5,
ghc-lib-parser >=9.6 && <9.7, ghc-lib-parser >=9.8 && <9.9,
optparse-applicative >=0.14 && <0.19, optparse-applicative >=0.14 && <0.19,
ormolu, ormolu,
text >=2.0 && <3.0, text >=2.0 && <3.0,
@ -178,7 +178,7 @@ test-suite tests
containers >=0.5 && <0.7, containers >=0.5 && <0.7,
directory ^>=1.3, directory ^>=1.3,
filepath >=1.2 && <1.5, filepath >=1.2 && <1.5,
ghc-lib-parser >=9.6 && <9.7, ghc-lib-parser >=9.8 && <9.9,
hspec >=2.0 && <3.0, hspec >=2.0 && <3.0,
hspec-megaparsec >=2.2, hspec-megaparsec >=2.2,
megaparsec >=9.0, megaparsec >=9.0,

View File

@ -46,8 +46,10 @@ import Data.Set qualified as Set
import Data.Text (Text) import Data.Text (Text)
import Data.Text qualified as T import Data.Text qualified as T
import Debug.Trace import Debug.Trace
import GHC.Driver.CmdLine qualified as GHC import GHC.Driver.Errors.Types
import GHC.Types.Error
import GHC.Types.SrcLoc import GHC.Types.SrcLoc
import GHC.Utils.Error
import Ormolu.Config import Ormolu.Config
import Ormolu.Diff.ParseResult import Ormolu.Diff.ParseResult
import Ormolu.Diff.Text import Ormolu.Diff.Text
@ -96,8 +98,9 @@ ormolu cfgWithIndices path originalInput = do
(warnings, result0) <- (warnings, result0) <-
parseModule' cfg fixityMap OrmoluParsingFailed path originalInput parseModule' cfg fixityMap OrmoluParsingFailed path originalInput
when (cfgDebug cfg) $ do when (cfgDebug cfg) $ do
forM_ warnings $ \(GHC.Warn reason (L loc msg)) -> forM_ warnings $ \driverMsg -> do
traceM $ unwords ["*** WARNING ***", showOutputable loc, msg, showOutputable reason] let driverMsgSDoc = formatBulleted $ diagnosticMessage defaultOpts driverMsg
traceM $ unwords ["*** WARNING ***", showOutputable driverMsgSDoc]
forM_ result0 $ \case forM_ result0 $ \case
ParsedSnippet r -> do ParsedSnippet r -> do
let CommentStream comments = prCommentStream r let CommentStream comments = prCommentStream r
@ -244,7 +247,7 @@ parseModule' ::
FilePath -> FilePath ->
-- | Actual input for the parser -- | Actual input for the parser
Text -> Text ->
m ([GHC.Warn], [SourceSnippet]) m (DriverMessages, [SourceSnippet])
parseModule' cfg fixityMap mkException path str = do parseModule' cfg fixityMap mkException path str = do
(warnings, r) <- parseModule cfg fixityMap path str (warnings, r) <- parseModule cfg fixityMap path str
case r of case r of

View File

@ -16,7 +16,7 @@ import Data.Map.Strict qualified as Map
import Distribution.ModuleName (ModuleName) import Distribution.ModuleName (ModuleName)
import Distribution.Types.PackageName import Distribution.Types.PackageName
import GHC.Data.FastString qualified as GHC import GHC.Data.FastString qualified as GHC
import GHC.Hs hiding (ModuleName) import GHC.Hs hiding (ModuleName, OpName)
import GHC.Types.Name.Occurrence import GHC.Types.Name.Occurrence
import GHC.Types.PkgQual (RawPkgQual (..)) import GHC.Types.PkgQual (RawPkgQual (..))
import GHC.Types.SourceText (StringLiteral (..)) import GHC.Types.SourceText (StringLiteral (..))

View File

@ -123,7 +123,7 @@ importId (L _ ImportDecl {..}) =
isPrelude = moduleNameString moduleName == "Prelude" isPrelude = moduleNameString moduleName == "Prelude"
moduleName = unLoc ideclName moduleName = unLoc ideclName
-- | Normalize a collection of import\/export items. -- | Normalize a collection of import items.
normalizeLies :: [LIE GhcPs] -> [LIE GhcPs] normalizeLies :: [LIE GhcPs] -> [LIE GhcPs]
normalizeLies = sortOn (getIewn . unLoc) . M.elems . foldl' combine M.empty normalizeLies = sortOn (getIewn . unLoc) . M.elems . foldl' combine M.empty
where where
@ -139,21 +139,21 @@ normalizeLies = sortOn (getIewn . unLoc) . M.elems . foldl' combine M.empty
Nothing -> Just . L new_l $ Nothing -> Just . L new_l $
case new of case new of
IEThingWith _ n wildcard g -> IEThingWith _ n wildcard g ->
IEThingWith EpAnnNotUsed n wildcard (normalizeWNames g) IEThingWith (Nothing, EpAnnNotUsed) n wildcard (normalizeWNames g)
other -> other other -> other
Just old -> Just old ->
let f = \case let f = \case
IEVar _ n -> IEVar NoExtField n IEVar _ n -> IEVar Nothing n
IEThingAbs _ _ -> new IEThingAbs _ _ -> new
IEThingAll _ n -> IEThingAll EpAnnNotUsed n IEThingAll _ n -> IEThingAll (Nothing, EpAnnNotUsed) n
IEThingWith _ n wildcard g -> IEThingWith _ n wildcard g ->
case new of case new of
IEVar NoExtField _ -> IEVar _ _ ->
error "Ormolu.Imports broken presupposition" error "Ormolu.Imports broken presupposition"
IEThingAbs _ _ -> IEThingAbs _ _ ->
IEThingWith EpAnnNotUsed n wildcard g IEThingWith (Nothing, EpAnnNotUsed) n wildcard g
IEThingAll _ n' -> IEThingAll _ n' ->
IEThingAll EpAnnNotUsed n' IEThingAll (Nothing, EpAnnNotUsed) n'
IEThingWith _ n' wildcard' g' -> IEThingWith _ n' wildcard' g' ->
let combinedWildcard = let combinedWildcard =
case (wildcard, wildcard') of case (wildcard, wildcard') of
@ -161,7 +161,7 @@ normalizeLies = sortOn (getIewn . unLoc) . M.elems . foldl' combine M.empty
(_, IEWildcard _) -> IEWildcard 0 (_, IEWildcard _) -> IEWildcard 0
_ -> NoIEWildcard _ -> NoIEWildcard
in IEThingWith in IEThingWith
EpAnnNotUsed (Nothing, EpAnnNotUsed)
n' n'
combinedWildcard combinedWildcard
(normalizeWNames (g <> g')) (normalizeWNames (g <> g'))
@ -187,7 +187,7 @@ instance Ord IEWrappedNameOrd where
-- | Project @'IEWrappedName' 'GhcPs'@ from @'IE' 'GhcPs'@. -- | Project @'IEWrappedName' 'GhcPs'@ from @'IE' 'GhcPs'@.
getIewn :: IE GhcPs -> IEWrappedNameOrd getIewn :: IE GhcPs -> IEWrappedNameOrd
getIewn = \case getIewn = \case
IEVar NoExtField x -> IEWrappedNameOrd (unLoc x) IEVar _ x -> IEWrappedNameOrd (unLoc x)
IEThingAbs _ x -> IEWrappedNameOrd (unLoc x) IEThingAbs _ x -> IEWrappedNameOrd (unLoc x)
IEThingAll _ x -> IEWrappedNameOrd (unLoc x) IEThingAll _ x -> IEWrappedNameOrd (unLoc x)
IEThingWith _ x _ _ -> IEWrappedNameOrd (unLoc x) IEThingWith _ x _ _ -> IEWrappedNameOrd (unLoc x)

View File

@ -28,7 +28,6 @@ import GHC.Data.EnumSet qualified as EnumSet
import GHC.Data.FastString qualified as GHC import GHC.Data.FastString qualified as GHC
import GHC.Data.Maybe (orElse) import GHC.Data.Maybe (orElse)
import GHC.Data.StringBuffer (StringBuffer) import GHC.Data.StringBuffer (StringBuffer)
import GHC.Driver.CmdLine qualified as GHC
import GHC.Driver.Config.Parser (initParserOpts) import GHC.Driver.Config.Parser (initParserOpts)
import GHC.Driver.Errors.Types qualified as GHC import GHC.Driver.Errors.Types qualified as GHC
import GHC.Driver.Session as GHC import GHC.Driver.Session as GHC
@ -44,7 +43,6 @@ import GHC.Types.SourceError qualified as GHC
import GHC.Types.SrcLoc import GHC.Types.SrcLoc
import GHC.Utils.Error import GHC.Utils.Error
import GHC.Utils.Exception (ExceptionMonad) import GHC.Utils.Exception (ExceptionMonad)
import GHC.Utils.Outputable (defaultSDocContext)
import GHC.Utils.Panic qualified as GHC import GHC.Utils.Panic qualified as GHC
import Ormolu.Config import Ormolu.Config
import Ormolu.Exception import Ormolu.Exception
@ -70,7 +68,7 @@ parseModule ::
-- | Input for parser -- | Input for parser
Text -> Text ->
m m
( [GHC.Warn], ( GHC.DriverMessages,
Either (SrcSpan, String) [SourceSnippet] Either (SrcSpan, String) [SourceSnippet]
) )
parseModule config@Config {..} packageFixityMap path rawInput = liftIO $ do parseModule config@Config {..} packageFixityMap path rawInput = liftIO $ do
@ -134,7 +132,7 @@ parseModuleSnippet Config {..} modFixityMap dynFlags path rawInput = liftIO $ do
Nothing -> "" Nothing -> ""
msg = msg =
showOutputable showOutputable
. formatBulleted defaultSDocContext . formatBulleted
. diagnosticMessage GHC.NoDiagnosticOpts . diagnosticMessage GHC.NoDiagnosticOpts
$ err $ err
in case L.sortOn (rateSeverity . errMsgSeverity) errs of in case L.sortOn (rateSeverity . errMsgSeverity) errs of
@ -254,7 +252,8 @@ manualExts =
LinearTypes, -- steals the (%) type operator in some cases LinearTypes, -- steals the (%) type operator in some cases
OverloadedRecordDot, -- f.g parses differently OverloadedRecordDot, -- f.g parses differently
OverloadedRecordUpdate, -- qualified fields are not supported OverloadedRecordUpdate, -- qualified fields are not supported
OverloadedLabels -- a#b is parsed differently OverloadedLabels, -- a#b is parsed differently
ExtendedLiterals -- 1#Word32 is parsed differently
] ]
-- | Run a 'GHC.P' computation. -- | Run a 'GHC.P' computation.
@ -289,7 +288,7 @@ parsePragmasIntoDynFlags ::
FilePath -> FilePath ->
-- | Input for parser -- | Input for parser
StringBuffer -> StringBuffer ->
IO (Either String ([GHC.Warn], DynFlags)) IO (Either String (GHC.DriverMessages, DynFlags))
parsePragmasIntoDynFlags flags extraOpts filepath input = parsePragmasIntoDynFlags flags extraOpts filepath input =
catchGhcErrors $ do catchGhcErrors $ do
let (_warnings, fileOpts) = let (_warnings, fileOpts) =

View File

@ -18,6 +18,7 @@ where
import Control.Monad import Control.Monad
import Data.Text qualified as T import Data.Text qualified as T
import GHC.Data.FastString
import GHC.Hs.Doc import GHC.Hs.Doc
import GHC.Hs.Extension (GhcPs) import GHC.Hs.Extension (GhcPs)
import GHC.Hs.ImpExp import GHC.Hs.ImpExp
@ -71,6 +72,8 @@ p_rdrName l = located l $ \x -> do
NameAnn {nann_adornment = NameParens} -> NameAnn {nann_adornment = NameParens} ->
parens N . handleUnboxedSumsAndHashInteraction parens N . handleUnboxedSumsAndHashInteraction
NameAnn {nann_adornment = NameBackquotes} -> backticks NameAnn {nann_adornment = NameBackquotes} -> backticks
-- whether the `->` identifier is parenthesized
NameAnnRArrow {nann_mopen = Just _} -> parens N
-- special case for unboxed unit tuples -- special case for unboxed unit tuples
NameAnnOnly {nann_adornment = NameParensHash} -> const $ txt "(# #)" NameAnnOnly {nann_adornment = NameParensHash} -> const $ txt "(# #)"
_ -> id _ -> id
@ -188,4 +191,4 @@ p_hsDocName name = txt ("-- $" <> T.pack name)
p_sourceText :: SourceText -> R () p_sourceText :: SourceText -> R ()
p_sourceText = \case p_sourceText = \case
NoSourceText -> pure () NoSourceText -> pure ()
SourceText s -> txt (T.pack s) SourceText s -> atom @FastString s

View File

@ -139,7 +139,9 @@ p_tyClDecl style = \case
p_dataDecl p_dataDecl
Associated Associated
tcdLName tcdLName
(tyVarsToTyPats tcdTyVars) (hsq_explicit tcdTyVars)
getLocA
(located' p_hsTyVarBndr)
tcdFixity tcdFixity
tcdDataDefn tcdDataDefn
ClassDecl {..} -> ClassDecl {..} ->

View File

@ -24,21 +24,25 @@ import GHC.Types.SrcLoc
import Ormolu.Printer.Combinators import Ormolu.Printer.Combinators
import Ormolu.Printer.Meat.Common import Ormolu.Printer.Meat.Common
import Ormolu.Printer.Meat.Type import Ormolu.Printer.Meat.Type
import Ormolu.Utils (matchAddEpAnn) import Ormolu.Utils
p_dataDecl :: p_dataDecl ::
-- | Whether to format as data family -- | Whether to format as data family
FamilyStyle -> FamilyStyle ->
-- | Type constructor -- | Type constructor
LocatedN RdrName -> LocatedN RdrName ->
-- | Type patterns -- | Type variables
HsTyPats GhcPs -> [tyVar] ->
-- | Get location information for type variables
(tyVar -> SrcSpan) ->
-- | How to print type variables
(tyVar -> R ()) ->
-- | Lexical fixity -- | Lexical fixity
LexicalFixity -> LexicalFixity ->
-- | Data definition -- | Data definition
HsDataDefn GhcPs -> HsDataDefn GhcPs ->
R () R ()
p_dataDecl style name tpats fixity HsDataDefn {..} = do p_dataDecl style name tyVars getTyVarLoc p_tyVar fixity HsDataDefn {..} = do
txt $ case dd_cons of txt $ case dd_cons of
NewTypeCon _ -> "newtype" NewTypeCon _ -> "newtype"
DataTypeCons False _ -> "data" DataTypeCons False _ -> "data"
@ -57,7 +61,7 @@ p_dataDecl style name tpats fixity HsDataDefn {..} = do
space space
p_sourceText type_ p_sourceText type_
txt " #-}" txt " #-}"
let constructorSpans = getLocA name : fmap lhsTypeArgSrcSpan tpats let constructorSpans = getLocA name : fmap getTyVarLoc tyVars
sigSpans = maybeToList . fmap getLocA $ dd_kindSig sigSpans = maybeToList . fmap getLocA $ dd_kindSig
declHeaderSpans = declHeaderSpans =
maybeToList (getLocA <$> dd_ctxt) ++ constructorSpans ++ sigSpans maybeToList (getLocA <$> dd_ctxt) ++ constructorSpans ++ sigSpans
@ -76,7 +80,7 @@ p_dataDecl style name tpats fixity HsDataDefn {..} = do
(isInfix fixity) (isInfix fixity)
True True
(p_rdrName name) (p_rdrName name)
(p_lhsTypeArg <$> tpats) (p_tyVar <$> tyVars)
forM_ dd_kindSig $ \k -> do forM_ dd_kindSig $ \k -> do
space space
txt "::" txt "::"

View File

@ -97,7 +97,14 @@ p_tyFamInstDecl style TyFamInstDecl {..} = do
p_dataFamInstDecl :: FamilyStyle -> DataFamInstDecl GhcPs -> R () p_dataFamInstDecl :: FamilyStyle -> DataFamInstDecl GhcPs -> R ()
p_dataFamInstDecl style (DataFamInstDecl {dfid_eqn = FamEqn {..}}) = p_dataFamInstDecl style (DataFamInstDecl {dfid_eqn = FamEqn {..}}) =
p_dataDecl style feqn_tycon feqn_pats feqn_fixity feqn_rhs p_dataDecl
style
feqn_tycon
feqn_pats
lhsTypeArgSrcSpan
p_lhsTypeArg
feqn_fixity
feqn_rhs
match_overlap_mode :: Maybe (LocatedP OverlapMode) -> R () -> R () match_overlap_mode :: Maybe (LocatedP OverlapMode) -> R () -> R ()
match_overlap_mode overlap_mode layoutStrategy = match_overlap_mode overlap_mode layoutStrategy =

View File

@ -33,6 +33,7 @@ import Data.Text (Text)
import Data.Text qualified as Text import Data.Text qualified as Text
import Data.Void import Data.Void
import GHC.Data.Bag (bagToList) import GHC.Data.Bag (bagToList)
import GHC.Data.FastString
import GHC.Data.Strict qualified as Strict import GHC.Data.Strict qualified as Strict
import GHC.Hs import GHC.Hs
import GHC.LanguageExtensions.Type (Extension (NegativeLiterals)) import GHC.LanguageExtensions.Type (Extension (NegativeLiterals))
@ -791,11 +792,11 @@ p_hsExpr' isApp s = \case
Ambiguous NoExtField n -> n Ambiguous NoExtField n -> n
p_recFields p_lbl = p_recFields p_lbl =
sep commaDel (sitcc . located' (p_hsFieldBind p_lbl)) sep commaDel (sitcc . located' (p_hsFieldBind p_lbl))
inci . braces N $ inci . braces N $ case rupd_flds of
either RegularRecUpdFields {..} ->
(p_recFields p_updLbl) p_recFields p_updLbl recUpdFields
(p_recFields $ located' $ coerce p_ldotFieldOccs) OverloadedRecUpdFields {..} ->
rupd_flds p_recFields (located' (coerce p_ldotFieldOccs)) olRecUpdFields
HsGetField {..} -> do HsGetField {..} -> do
located gf_expr p_hsExpr located gf_expr p_hsExpr
txt "." txt "."
@ -1184,9 +1185,9 @@ p_hsQuote epAnn = \case
_ -> False _ -> False
-- | Print the source text of a string literal while indenting gaps correctly. -- | Print the source text of a string literal while indenting gaps correctly.
p_stringLit :: String -> R () p_stringLit :: FastString -> R ()
p_stringLit src = p_stringLit src =
let s = splitGaps src let s = splitGaps (unpackFS src)
singleLine = singleLine =
txt $ Text.pack (mconcat s) txt $ Text.pack (mconcat s)
multiLine = multiLine =

View File

@ -11,6 +11,7 @@ module Ormolu.Printer.Meat.Declaration.Value
) )
where where
import GHC.Data.FastString
import GHC.Hs import GHC.Hs
import Ormolu.Printer.Combinators import Ormolu.Printer.Combinators
@ -18,7 +19,7 @@ p_valDecl :: HsBindLR GhcPs GhcPs -> R ()
p_pat :: Pat GhcPs -> R () p_pat :: Pat GhcPs -> R ()
p_hsExpr :: HsExpr GhcPs -> R () p_hsExpr :: HsExpr GhcPs -> R ()
p_hsUntypedSplice :: SpliceDecoration -> HsUntypedSplice GhcPs -> R () p_hsUntypedSplice :: SpliceDecoration -> HsUntypedSplice GhcPs -> R ()
p_stringLit :: String -> R () p_stringLit :: FastString -> R ()
data IsApplicand data IsApplicand

View File

@ -1,14 +1,16 @@
{-# LANGUAGE LambdaCase #-} {-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Ormolu.Printer.Meat.Declaration.Warning module Ormolu.Printer.Meat.Declaration.Warning
( p_warnDecls, ( p_warnDecls,
p_moduleWarning, p_warningTxt,
) )
where where
import Data.Foldable import Data.Foldable
import Data.Text (Text) import Data.Text (Text)
import Data.Text qualified as T
import GHC.Hs import GHC.Hs
import GHC.Types.Name.Reader import GHC.Types.Name.Reader
import GHC.Types.SourceText import GHC.Types.SourceText
@ -16,6 +18,7 @@ import GHC.Types.SrcLoc
import GHC.Unit.Module.Warnings import GHC.Unit.Module.Warnings
import Ormolu.Printer.Combinators import Ormolu.Printer.Combinators
import Ormolu.Printer.Meat.Common import Ormolu.Printer.Meat.Common
import Ormolu.Utils
p_warnDecls :: WarnDecls GhcPs -> R () p_warnDecls :: WarnDecls GhcPs -> R ()
p_warnDecls (Warnings _ warnings) = p_warnDecls (Warnings _ warnings) =
@ -25,8 +28,8 @@ p_warnDecl :: WarnDecl GhcPs -> R ()
p_warnDecl (Warning _ functions warningTxt) = p_warnDecl (Warning _ functions warningTxt) =
p_topLevelWarning functions warningTxt p_topLevelWarning functions warningTxt
p_moduleWarning :: WarningTxt GhcPs -> R () p_warningTxt :: WarningTxt GhcPs -> R ()
p_moduleWarning wtxt = do p_warningTxt wtxt = do
let (pragmaText, lits) = warningText wtxt let (pragmaText, lits) = warningText wtxt
inci $ pragma pragmaText $ inci $ p_lits lits inci $ pragma pragmaText $ inci $ p_lits lits
@ -41,7 +44,12 @@ p_topLevelWarning fnames wtxt = do
warningText :: WarningTxt GhcPs -> (Text, [Located StringLiteral]) warningText :: WarningTxt GhcPs -> (Text, [Located StringLiteral])
warningText = \case warningText = \case
WarningTxt _ lits -> ("WARNING", fmap hsDocString <$> lits) WarningTxt mcat _ lits -> ("WARNING" <> T.pack cat, fmap hsDocString <$> lits)
where
cat = case unLoc <$> mcat of
Just InWarningCategory {..} ->
" in " <> show (showOutputable @WarningCategory (unLoc iwc_wc))
Nothing -> ""
DeprecatedTxt _ lits -> ("DEPRECATED", fmap hsDocString <$> lits) DeprecatedTxt _ lits -> ("DEPRECATED", fmap hsDocString <$> lits)
p_lits :: [Located StringLiteral] -> R () p_lits :: [Located StringLiteral] -> R ()

View File

@ -10,12 +10,14 @@ module Ormolu.Printer.Meat.ImportExport
where where
import Control.Monad import Control.Monad
import Data.Foldable (for_)
import GHC.Hs import GHC.Hs
import GHC.LanguageExtensions.Type import GHC.LanguageExtensions.Type
import GHC.Types.PkgQual import GHC.Types.PkgQual
import GHC.Types.SrcLoc import GHC.Types.SrcLoc
import Ormolu.Printer.Combinators import Ormolu.Printer.Combinators
import Ormolu.Printer.Meat.Common import Ormolu.Printer.Meat.Common
import Ormolu.Printer.Meat.Declaration.Warning
import Ormolu.Utils (RelativePos (..), attachRelativePos) import Ormolu.Utils (RelativePos (..), attachRelativePos)
p_hsmodExports :: [LIE GhcPs] -> R () p_hsmodExports :: [LIE GhcPs] -> R ()
@ -74,7 +76,10 @@ p_hsmodImport ImportDecl {..} = do
p_lie :: Layout -> RelativePos -> IE GhcPs -> R () p_lie :: Layout -> RelativePos -> IE GhcPs -> R ()
p_lie encLayout relativePos = \case p_lie encLayout relativePos = \case
IEVar NoExtField l1 -> do IEVar mwarn l1 -> do
for_ mwarn $ \warnTxt -> do
located warnTxt p_warningTxt
breakpoint
located l1 p_ieWrappedName located l1 p_ieWrappedName
p_comma p_comma
IEThingAbs _ l1 -> do IEThingAbs _ l1 -> do

View File

@ -49,7 +49,7 @@ p_hsModule mstackHeader pragmas HsModule {..} = do
p_hsmodName name p_hsmodName name
breakpoint breakpoint
forM_ hsmodDeprecMessage $ \w -> do forM_ hsmodDeprecMessage $ \w -> do
located' p_moduleWarning w located' p_warningTxt w
breakpoint breakpoint
case hsmodExports of case hsmodExports of
Nothing -> return () Nothing -> return ()

View File

@ -14,7 +14,6 @@ module Ormolu.Printer.Meat.Type
p_conDeclFields, p_conDeclFields,
p_lhsTypeArg, p_lhsTypeArg,
p_hsSigType, p_hsSigType,
tyVarsToTyPats,
hsOuterTyVarBndrsToHsType, hsOuterTyVarBndrsToHsType,
lhsTypeToSigType, lhsTypeToSigType,
) )
@ -74,7 +73,7 @@ p_hsType' multilineArgs = \case
breakpoint breakpoint
inci $ inci $
sep breakpoint (located' p_hsType) args sep breakpoint (located' p_hsType) args
HsAppKindTy _ ty kd -> sitcc $ do HsAppKindTy _ ty _ kd -> sitcc $ do
-- The first argument is the location of the "@..." part. Not 100% sure, -- The first argument is the location of the "@..." part. Not 100% sure,
-- but I think we can ignore it as long as we use 'located' on both the -- but I think we can ignore it as long as we use 'located' on both the
-- type and the kind. -- type and the kind.
@ -199,22 +198,33 @@ p_hsContext = \case
[x] -> located x p_hsType [x] -> located x p_hsType
xs -> parens N $ sep commaDel (sitcc . located' p_hsType) xs xs -> parens N $ sep commaDel (sitcc . located' p_hsType) xs
class IsInferredTyVarBndr flag where class IsTyVarBndrFlag flag where
isInferred :: flag -> Bool isInferred :: flag -> Bool
p_tyVarBndrFlag :: flag -> R ()
p_tyVarBndrFlag _ = pure ()
instance IsInferredTyVarBndr () where instance IsTyVarBndrFlag () where
isInferred () = False isInferred () = False
instance IsInferredTyVarBndr Specificity where instance IsTyVarBndrFlag Specificity where
isInferred = \case isInferred = \case
InferredSpec -> True InferredSpec -> True
SpecifiedSpec -> False SpecifiedSpec -> False
p_hsTyVarBndr :: (IsInferredTyVarBndr flag) => HsTyVarBndr flag GhcPs -> R () instance IsTyVarBndrFlag (HsBndrVis GhcPs) where
isInferred _ = False
p_tyVarBndrFlag = \case
HsBndrRequired -> pure ()
HsBndrInvisible _ -> txt "@"
p_hsTyVarBndr :: (IsTyVarBndrFlag flag) => HsTyVarBndr flag GhcPs -> R ()
p_hsTyVarBndr = \case p_hsTyVarBndr = \case
UserTyVar _ flag x -> UserTyVar _ flag x -> do
p_tyVarBndrFlag flag
(if isInferred flag then braces N else id) $ p_rdrName x (if isInferred flag then braces N else id) $ p_rdrName x
KindedTyVar _ flag l k -> (if isInferred flag then braces else parens) N $ do KindedTyVar _ flag l k -> do
p_tyVarBndrFlag flag
(if isInferred flag then braces else parens) N $ do
located l atom located l atom
space space
txt "::" txt "::"
@ -275,21 +285,6 @@ p_hsSigType HsSig {..} =
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Conversion functions -- Conversion functions
tyVarToType :: HsTyVarBndr () GhcPs -> HsType GhcPs
tyVarToType = \case
UserTyVar _ () tvar -> HsTyVar EpAnnNotUsed NotPromoted tvar
KindedTyVar _ () tvar kind ->
-- Note: we always add parentheses because for whatever reason GHC does
-- not use HsParTy for left-hand sides of declarations. Please see
-- <https://gitlab.haskell.org/ghc/ghc/issues/17404>. This is fine as
-- long as 'tyVarToType' does not get applied to right-hand sides of
-- declarations.
HsParTy EpAnnNotUsed . noLocA $
HsKindSig EpAnnNotUsed (noLocA (HsTyVar EpAnnNotUsed NotPromoted tvar)) kind
tyVarsToTyPats :: LHsQTyVars GhcPs -> HsTyPats GhcPs
tyVarsToTyPats HsQTvs {..} = HsValArg . fmap tyVarToType <$> hsq_explicit
-- could be generalized to also handle () instead of Specificity -- could be generalized to also handle () instead of Specificity
hsOuterTyVarBndrsToHsType :: hsOuterTyVarBndrsToHsType ::
HsOuterTyVarBndrs Specificity GhcPs -> HsOuterTyVarBndrs Specificity GhcPs ->

View File

@ -1,9 +1,12 @@
resolver: nightly-2023-06-27 resolver: nightly-2023-10-09
packages: packages:
- '.' - '.'
- extract-hackage-info - extract-hackage-info
extra-deps:
- ghc-lib-parser-9.8.1.20231009
nix: nix:
packages: packages:
- haskellPackages.happy - haskellPackages.happy

View File

@ -1,7 +0,0 @@
{ roots =
[ "^Main.main\$"
, "^Paths_"
, "^Ormolu.Terminal.QualifiedDo.>>\$" -- https://github.com/ocharles/weeder/issues/112
]
, type-class-roots = True
}

6
weeder.toml Normal file
View File

@ -0,0 +1,6 @@
roots = [
"^Main.main$",
"^Paths_",
"^Ormolu.Terminal.QualifiedDo.>>$" # https://github.com/ocharles/weeder/issues/112
]
type-class-roots = true