Skip to content

Commit

Permalink
Use "ghc" library in place of "haskell-src".
Browse files Browse the repository at this point in the history
The "ghc" library is now used to parse and print Haskell source code.
Switching to "ghc" adds support for language features beyond Haskell 98
and improves diagnostic messages for sources specified with
"--extraInstanceFile".  Breakage should be limited to users of:

* Proto3.Suite.DotProto.Generate
* Proto3.Suite.DotProto.Generate.LargeRecord
* Proto3.Suite.DotProto.Generate.Syntax

To reflect the potential for breakage
we increase the library version to 0.8.0.

This change also replaces testing of
GHC 8.10.7 with testing of 9.6.4,
and indicates in CHANGELOG.md that
we are dropping support for GHC 8.10
and adding support for GHC 9.6.

This change also fixes some build failures that
occurred when Swagger support is disabled.
  • Loading branch information
j6carey committed May 2, 2024
1 parent 30599c1 commit c6b3d0e
Show file tree
Hide file tree
Showing 12 changed files with 1,371 additions and 668 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- ubuntu-latest
- macos-latest
compiler:
- ghc8107
- ghc902
- ghc924
- ghc946
- ghc964
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 0.8.0
* [BREAKING CHANGE: Use "ghc" library in place of "haskell-src".]
The "ghc" library is now used to parse and print Haskell source code.
Switching to "ghc" adds support for language features beyond Haskell 98
and should improve diagnostic messages for sources specified with
"--extraInstanceFile". Breakage should be limited to users of:
* Proto3.Suite.DotProto.Generate
* Proto3.Suite.DotProto.Generate.LargeRecord
* Proto3.Suite.DotProto.Generate.Syntax
* Add support for GHC 9.6.
* Drop support for GHC 8.10.

# 0.7.0
* Support GHC 9.2, 9.4.
* Support proto files without a package declaration.
Expand Down
15 changes: 9 additions & 6 deletions proto3-suite.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: proto3-suite
version: 0.7.0
version: 0.8.0
synopsis: A higher-level API to the proto3-wire library
description:
This library provides a higher-level API to <https://github.com/awakesecurity/proto3-wire the `proto3-wire` library>
Expand Down Expand Up @@ -97,7 +97,8 @@ library
Proto3.Suite.DotProto.Internal
Proto3.Suite.JSONPB.Class

other-modules: Turtle.Compat
other-modules: Proto3.Suite.Haskell.Parser
Turtle.Compat

build-depends: aeson >= 1.1.1.0 && < 2.2,
aeson-pretty,
Expand All @@ -112,8 +113,8 @@ library
contravariant >=1.4 && <1.6,
filepath,
foldl,
ghc >= 9.0.1,
hashable,
haskell-src ==1.0.*,
insert-ordered-containers,
lens,
mtl ==2.2.*,
Expand All @@ -138,7 +139,7 @@ library
build-depends: semigroups >= 0.18 && < 0.20
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -O2 -Wall
ghc-options: -O2 -Wall -Werror

test-suite tests
import: common
Expand Down Expand Up @@ -201,6 +202,7 @@ test-suite tests
, deepseq ==1.4.*
, doctest
, generic-arbitrary
, ghc
, hedgehog
, mtl ==2.2.*
, parsec >= 3.1.9 && <3.2.0
Expand Down Expand Up @@ -229,12 +231,13 @@ executable compile-proto-file
hs-source-dirs: tools/compile-proto-file
default-language: Haskell2010
build-depends: base >=4.12 && <5.0
, ghc
, optparse-applicative
, proto3-suite
, system-filepath
, text
, turtle
ghc-options: -O2 -Wall
ghc-options: -O2 -Wall -Werror

executable canonicalize-proto-file
main-is: Main.hs
Expand All @@ -249,4 +252,4 @@ executable canonicalize-proto-file
, range-set-list >=0.1.2 && <0.2
, system-filepath
, turtle
ghc-options: -O2 -Wall
ghc-options: -O2 -Wall -Werror
10 changes: 8 additions & 2 deletions src/Proto3/Suite/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,13 @@ instance (MessageField e, KnownSymbol comments) => MessageField (e // comments)
decodeMessageField = coerce @(Parser RawField e)
@(Parser RawField (Commented comments e))
decodeMessageField
protoType p = (protoType (lowerProxy1 p))
{ dotProtoFieldComment = symbolVal (lowerProxy2 p) }
protoType p = case field of
DotProtoEmptyField -> DotProtoEmptyField
f -> f { dotProtoFieldComment = symbolVal (lowerProxy2 p) }
where
field :: DotProtoField
field = protoType (lowerProxy1 p)

lowerProxy1 :: forall k f (a :: k). Proxy# (f a) -> Proxy# a
lowerProxy1 _ = proxy#

Expand Down Expand Up @@ -1021,6 +1025,7 @@ instance (KnownNat (GenericFieldCount f), GenericMessage f, GenericMessage g)
where
offset = fromIntegral $ natVal (Proxy @(GenericFieldCount f))
adjust = map adjustPart
adjustPart DotProtoEmptyField = DotProtoEmptyField
adjustPart part = part
{ dotProtoFieldNumber = FieldNumber . (offset +)
. getFieldNumber . dotProtoFieldNumber
Expand All @@ -1040,6 +1045,7 @@ instance (Selector s, GenericMessage f) => GenericMessage (M1 S s f) where
genericDotProto _ = map applyName $ genericDotProto (proxy# :: Proxy# f)
where
applyName :: DotProtoField -> DotProtoField
applyName DotProtoEmptyField = DotProtoEmptyField
applyName mp = mp { dotProtoFieldName = fromMaybe Anonymous newName}
-- [issue] this probably doesn't match the intended name generating semantics

Expand Down
Loading

0 comments on commit c6b3d0e

Please sign in to comment.