Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghc-lib-parser 9.12 #1140

Merged
merged 7 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: [ghc965, ghc982, ghc9101]
ghc: [ghc984, ghc9101, ghc9121]
name: Build and test on ${{ matrix.ghc }}
runs-on: ubuntu-latest
steps:
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
* Correctly format multi-line parentheses in arrow `do` blocks. [Issue
1144](https://github.com/tweag/ormolu/issues/1144).

* Switched to `ghc-lib-parser-9.12`, with the following new syntactic features:
* GHC proposal [#522](https://github.com/ghc-proposals/ghc-proposals/blob/c9401f037cb22d1661931b2ec621925101052997/proposals/0522-or-patterns.rst): `OrPatterns` (enabled by default)
* GHC proposal [#569](https://github.com/ghc-proposals/ghc-proposals/blob/c9401f037cb22d1661931b2ec621925101052997/proposals/0569-multiline-strings.rst): `MultilineStrings` (disabled by default)
* GHC proposal [#409](https://github.com/ghc-proposals/ghc-proposals/blob/f79438cf8dbfcd90187f7af3a380515ffe45dbdc/proposals/0409-exportable-named-default.rst): `NamedDefaults` (enabled by default)
* GHC proposal [#281](https://github.com/ghc-proposals/ghc-proposals/blob/c9401f037cb22d1661931b2ec621925101052997/proposals/0281-visible-forall.rst): accept more types in terms: `forall` quantifications, constraint arrows `=>`, type arrows `->` (enabled by default)
* Part of GHC proposal [#425](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0425-decl-invis-binders.rst): wildcard binders (enabled by default)

* Correctly format non-promoted type-level tuples with `NoListTuplePuns`. [Issue
1146](https://github.com/tweag/ormolu/issues/1146).

* Updated to `Cabal-syntax-3.14`. [Issue
1152](https://github.com/tweag/ormolu/issues/1152).

## Ormolu 0.7.7.0

* Use single-line layout for parens around single-line content. [Issue
Expand Down
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
packages: . extract-hackage-info

tests: True
multi-repl: True

constraints: ormolu +dev
1 change: 1 addition & 0 deletions data/examples/declaration/data/wildcard-binders-out.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data Proxy _ = Proxy
1 change: 1 addition & 0 deletions data/examples/declaration/data/wildcard-binders.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data Proxy _ = Proxy
8 changes: 8 additions & 0 deletions data/examples/declaration/default/default-out.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
module MyModule (default Monoid) where

default (Int, Foo, Bar)

default
( Int,
Foo,
Bar
)

default Num (Int, Float)

default IsList ([], Vector)

default IsString (Text.Text, Foundation.String, String)
7 changes: 7 additions & 0 deletions data/examples/declaration/default/default.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
module MyModule (default Monoid) where

default ( Int , Foo , Bar )

default ( Int
, Foo,
Bar
)

default Num (Int, Float)
default IsList ([], Vector)

default IsString (Text.Text, Foundation.String, String)
5 changes: 5 additions & 0 deletions data/examples/declaration/type/promotion-no-puns-out.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# LANGUAGE NoListTuplePuns #-}

type X = (Int, String)

type Y = [String, Int]
5 changes: 5 additions & 0 deletions data/examples/declaration/type/promotion-no-puns.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# Language NoListTuplePuns #-}

type X = (Int, String)

type Y = [String, Int]
1 change: 1 addition & 0 deletions data/examples/declaration/type/wildcard-binders-out.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Const a _ = a
1 change: 1 addition & 0 deletions data/examples/declaration/type/wildcard-binders.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Const a _ = a
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""Line 1
Line 2
Line 3
"""

s_2 =
"""Line 1
Line 2
Line 3
"""

-- equivalent to
s' = "Line 1\n Line 2\nLine 3"

-- the following are equivalent
s = """hello world"""

s' = "hello world"

s =
""" hello
world
"""

-- equivalent to
s' = " hello\nworld"
31 changes: 31 additions & 0 deletions data/examples/declaration/value/function/multiline-strings-0.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""Line 1
Line 2
Line 3
"""

s_2 =
"""\
\Line 1
Line 2
Line 3
"""

-- equivalent to
s' = "Line 1\n Line 2\nLine 3"


-- the following are equivalent
s = """hello world"""
s' = "hello world"


s =
""" hello
world
"""

-- equivalent to
s' = " hello\nworld"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""
a b c d e
f g
"""

-- equivalent to
s' = "a b c d e\nf g"
11 changes: 11 additions & 0 deletions data/examples/declaration/value/function/multiline-strings-1.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""
a b\
\ c d e
f g
"""

-- equivalent to
s' = "a b c d e\nf g"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""
a
b
c
"""

-- equivalent to
s' = "a\nb\nc"
11 changes: 11 additions & 0 deletions data/examples/declaration/value/function/multiline-strings-2.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""
a
b
c
"""

-- equivalent to
s' = "a\nb\nc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""

a
b
c
"""

-- equivalent to
s' = "\na\nb\nc"

s1 =
""" a
b
c
"""

s2 =
"""
a
b
c
"""

-- In the current proposal, these are equivalent to
-- the below. If leading newline were removed at the
-- beginning, both would result in s1'.
s1' = " a\nb\nc"

s2' = "a\nb\nc"
32 changes: 32 additions & 0 deletions data/examples/declaration/value/function/multiline-strings-3.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""

a
b
c
"""

-- equivalent to
s' = "\na\nb\nc"


s1 =
""" a
b
c
"""

s2 =
"""
a
b
c
"""

-- In the current proposal, these are equivalent to
-- the below. If leading newline were removed at the
-- beginning, both would result in s1'.
s1' = " a\nb\nc"
s2' = "a\nb\nc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""
a
b

"""

-- equivalent to
s' = "a\nb\n"

s1 =
"""
line 1
line 2
"""

s2 = "line 3"

s3 =
"""
line 4
line 5
"""
26 changes: 26 additions & 0 deletions data/examples/declaration/value/function/multiline-strings-4.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE MultilineStrings #-}

s =
"""
a
b

"""

-- equivalent to
s' = "a\nb\n"


s1 =
"""
line 1
line 2
"""

s2 = "line 3"

s3 =
"""
line 4
line 5
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE MultilineStrings #-}

s1 =
"""
a
b
c
"""

s1' = "a\nb\nc"

s2 =
"""
\& a
b
c
"""

s2_2 =
"""
\& a
\& b
\& c
"""

s2' = " a\n b\n c"
26 changes: 26 additions & 0 deletions data/examples/declaration/value/function/multiline-strings-5.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE MultilineStrings #-}

s1 =
"""
a
b
c
"""

s1' = "a\nb\nc"

s2 =
"""
\& a
b
c
"""

s2_2 =
"""
\& a
\& b
\& c
"""

s2' = " a\n b\n c"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE MultilineStrings #-}

x =
"""
This is a literal multiline string:
\"\"\"
Hello
world!
\"""
"""
10 changes: 10 additions & 0 deletions data/examples/declaration/value/function/multiline-strings-6.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE MultilineStrings #-}

x =
"""
This is a literal multiline string:
\"\"\"
Hello
world!
\"""
"""
Loading
Loading