Skip to content

Commit

Permalink
0.2.2: support newer GHCs
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickt committed Jan 4, 2023
1 parent 4e23de1 commit 98a7de8
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 75 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ name: Haskell CI

on:
pull_request:
branches:
- "**"
push:
branches:
- master
- "main"

jobs:
build:
name: ghc ${{ matrix.ghc }}
runs-on: ubuntu-16.04
runs-on: ubuntu-latest
strategy:
matrix:
ghc: ["8.6", "8.8", "8.10"]
cabal: ["3.2"]
ghc: ["8.10", "9.2", "9.4"]

steps:
- uses: actions/checkout@v2

- uses: actions/setup-haskell@v1
- uses: haskell/actions/setup@968e175ff94d685b6ce0bb39b02447cca8b4a6bb
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
Expand All @@ -29,16 +30,27 @@ jobs:
with:
path: ~/.cabal/packages
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages

- uses: actions/cache@v2
name: Cache ~/.cabal/store
with:
path: ~/.cabal/store
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store
- uses: actions/cache@v2
name: Cache dist-newstyle
with:
path: dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-fused-effects-dist

- name: Install dependencies
run: |
cabal v2-update
cabal v2-configure --enable-tests
cabal v2-build --only-dependencies all
- name: Build & test
run: |
ls -la
cabal build all
cabal test all
cabal haddock
cabal v2-build all
cabal v2-run twirp-test
cabal v2-haddock --project-file=cabal.project.ci
cabal v2-sdist --project-file=cabal.project.ci
cabal check
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ Use the protoc plugin to generate a twirp service and associated protobuf types

```
protoc -I=. --proto_path=./proto \
--plugin=protoc-gen-haskell=`which proto-lens-protoc` --haskell_out=./app \
--plugin=protoc-gen-haskell=`which proto-lens-protoc`
--haskell_out=./app \
--jsonpb_haskell_out=./app \
--plugin=protoc-gen-twirp_haskell=./script/run-twirp_haskell --twirp_haskell_out=./app/Twirp/Example/Haberdasher \
--plugin=protoc-gen-twirp_haskell=./script/run-twirp_haskell
--twirp_haskell_out=./app/Twirp/Example/Haberdasher \
haberdasher.proto
```

Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages: . example
packages: . example ../proto-lens-jsonpb

jobs: $ncpus
67 changes: 29 additions & 38 deletions example/app/Proto/Haberdasher.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ instance Data.ProtoLens.Message Bill where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.ProtoLens.encodeMessage
_v))
Data.ProtoLens.encodeMessage _v))
((Data.Monoid.<>)
(let
_v = Lens.Family2.view (Data.ProtoLens.Field.field @"status") _x
Expand All @@ -295,8 +294,7 @@ instance Data.ProtoLens.Message Bill where
((Prelude..)
((Prelude..)
Data.ProtoLens.Encoding.Bytes.putVarInt Prelude.fromIntegral)
Prelude.fromEnum
_v))
Prelude.fromEnum _v))
((Data.Monoid.<>)
(case
Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'extra") _x
Expand All @@ -311,8 +309,7 @@ instance Data.ProtoLens.Message Bill where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.Text.Encoding.encodeUtf8
v)
Data.Text.Encoding.encodeUtf8 v)
(Prelude.Just (Bill'ZipCode v))
-> (Data.Monoid.<>)
(Data.ProtoLens.Encoding.Bytes.putVarInt 34)
Expand All @@ -322,8 +319,7 @@ instance Data.ProtoLens.Message Bill where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.Text.Encoding.encodeUtf8
v))
Data.Text.Encoding.encodeUtf8 v))
(Data.ProtoLens.Encoding.Wire.buildFieldSet
(Lens.Family2.view Data.ProtoLens.unknownFields _x))))
instance Control.DeepSeq.NFData Bill where
Expand Down Expand Up @@ -391,8 +387,7 @@ instance Prelude.Enum Bill'BillingStatus where
((Prelude.++)
"toEnum: unknown value for enum BillingStatus: "
(Prelude.show k__)))
Prelude.id
(Data.ProtoLens.maybeToEnum k__)
Prelude.id (Data.ProtoLens.maybeToEnum k__)
fromEnum Bill'UN_PAID = 0
fromEnum Bill'PAID = 1
fromEnum
Expand Down Expand Up @@ -466,13 +461,13 @@ instance Data.ProtoLens.Message EmptyMessage where
Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)
else
do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt
case tag of {
case tag of
wire
-> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire
wire
loop
(Lens.Family2.over
Data.ProtoLens.unknownFields (\ !t -> (:) y t) x) }
Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)
in
(Data.ProtoLens.Encoding.Bytes.<?>)
(do loop Data.ProtoLens.defMessage) "EmptyMessage"
Expand Down Expand Up @@ -771,8 +766,7 @@ instance Data.ProtoLens.Message Hat where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.Text.Encoding.encodeUtf8
_v))
Data.Text.Encoding.encodeUtf8 _v))
((Data.Monoid.<>)
(let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"name") _x
in
Expand All @@ -787,8 +781,7 @@ instance Data.ProtoLens.Message Hat where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.Text.Encoding.encodeUtf8
_v))
Data.Text.Encoding.encodeUtf8 _v))
(Data.ProtoLens.Encoding.Wire.buildFieldSet
(Lens.Family2.view Data.ProtoLens.unknownFields _x))))
instance Control.DeepSeq.NFData Hat where
Expand Down Expand Up @@ -906,8 +899,7 @@ instance Data.ProtoLens.Message Ping where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.Text.Encoding.encodeUtf8
_v))
Data.Text.Encoding.encodeUtf8 _v))
(Data.ProtoLens.Encoding.Wire.buildFieldSet
(Lens.Family2.view Data.ProtoLens.unknownFields _x))
instance Control.DeepSeq.NFData Ping where
Expand Down Expand Up @@ -1135,8 +1127,7 @@ instance Data.ProtoLens.Message Pong where
(Prelude.show (missing :: [Prelude.String]))))
Prelude.return
(Lens.Family2.over
Data.ProtoLens.unknownFields
(\ !t -> Prelude.reverse t)
Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t)
(Lens.Family2.set
(Data.ProtoLens.Field.field @"vec'stuff") frozen'stuff x))
else
Expand Down Expand Up @@ -1242,8 +1233,7 @@ instance Data.ProtoLens.Message Pong where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.Text.Encoding.encodeUtf8
_v))
Data.Text.Encoding.encodeUtf8 _v))
((Data.Monoid.<>)
(Data.ProtoLens.Encoding.Bytes.foldMapBuilder
(\ _v
Expand All @@ -1255,8 +1245,7 @@ instance Data.ProtoLens.Message Pong where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.ProtoLens.encodeMessage
_v))
Data.ProtoLens.encodeMessage _v))
(Lens.Family2.view (Data.ProtoLens.Field.field @"vec'stuff") _x))
((Data.Monoid.<>)
(let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"id") _x
Expand All @@ -1283,8 +1272,7 @@ instance Data.ProtoLens.Message Pong where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.Text.Encoding.encodeUtf8
_v))
Data.Text.Encoding.encodeUtf8 _v))
((Data.Monoid.<>)
(case
Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'extra") _x
Expand All @@ -1294,8 +1282,7 @@ instance Data.ProtoLens.Message Pong where
-> (Data.Monoid.<>)
(Data.ProtoLens.Encoding.Bytes.putVarInt 24)
((Prelude..)
Data.ProtoLens.Encoding.Bytes.putVarInt
Prelude.fromIntegral
Data.ProtoLens.Encoding.Bytes.putVarInt Prelude.fromIntegral
v)
(Prelude.Just (Pong'U v))
-> (Data.Monoid.<>)
Expand All @@ -1306,8 +1293,7 @@ instance Data.ProtoLens.Message Pong where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.Text.Encoding.encodeUtf8
v))
Data.Text.Encoding.encodeUtf8 v))
(Data.ProtoLens.Encoding.Wire.buildFieldSet
(Lens.Family2.view Data.ProtoLens.unknownFields _x))))))
instance Control.DeepSeq.NFData Pong where
Expand Down Expand Up @@ -1702,11 +1688,9 @@ instance Data.ProtoLens.Message Test where
(Prelude.show (missing :: [Prelude.String]))))
Prelude.return
(Lens.Family2.over
Data.ProtoLens.unknownFields
(\ !t -> Prelude.reverse t)
Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t)
(Lens.Family2.set
(Data.ProtoLens.Field.field @"vec'altPrices")
frozen'altPrices
(Data.ProtoLens.Field.field @"vec'altPrices") frozen'altPrices
(Lens.Family2.set
(Data.ProtoLens.Field.field @"vec'items") frozen'items x)))
else
Expand Down Expand Up @@ -1758,8 +1742,7 @@ instance Data.ProtoLens.Message Test where
loop
(Lens.Family2.over
Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)
mutable'altPrices
mutable'items
mutable'altPrices mutable'items
in
(Data.ProtoLens.Encoding.Bytes.<?>)
(do mutable'altPrices <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO
Expand Down Expand Up @@ -1800,8 +1783,7 @@ instance Data.ProtoLens.Message Test where
(Data.ProtoLens.Encoding.Bytes.putVarInt
(Prelude.fromIntegral (Data.ByteString.length bs)))
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.ProtoLens.encodeMessage
_v))
Data.ProtoLens.encodeMessage _v))
(Lens.Family2.view
(Data.ProtoLens.Field.field @"vec'altPrices") _x))
(Data.ProtoLens.Encoding.Wire.buildFieldSet
Expand All @@ -1819,6 +1801,11 @@ instance Data.ProtoLens.Service.Types.Service Haberdasher where
type ServiceName Haberdasher = "Haberdasher"
type ServicePackage Haberdasher = "twirp.example.haberdasher"
type ServiceMethods Haberdasher = '["getBill", "makeHat"]
packedServiceDescriptor _
= "\n\
\\vHaberdasher\DC2J\n\
\\aMakeHat\DC2\US.twirp.example.haberdasher.Size\SUB\RS.twirp.example.haberdasher.Hat\DC2J\n\
\\aGetBill\DC2\RS.twirp.example.haberdasher.Hat\SUB\US.twirp.example.haberdasher.Bill"
instance Data.ProtoLens.Service.Types.HasMethodImpl Haberdasher "makeHat" where
type MethodName Haberdasher "makeHat" = "MakeHat"
type MethodInput Haberdasher "makeHat" = Size
Expand All @@ -1834,6 +1821,10 @@ instance Data.ProtoLens.Service.Types.Service Health where
type ServiceName Health = "Health"
type ServicePackage Health = "twirp.example.haberdasher"
type ServiceMethods Health = '["check"]
packedServiceDescriptor _
= "\n\
\\ACKHealth\DC2I\n\
\\ENQCheck\DC2\US.twirp.example.haberdasher.Ping\SUB\US.twirp.example.haberdasher.Pong"
instance Data.ProtoLens.Service.Types.HasMethodImpl Health "check" where
type MethodName Health "check" = "Check"
type MethodInput Health "check" = Ping
Expand Down
23 changes: 12 additions & 11 deletions example/example.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ build-type: Simple
tested-with: GHC == 8.6.5
, GHC == 8.8.1
, GHC == 8.10.1
, GHC == 9.2.2

-- GHC extensions shared between targets
common haskell
Expand All @@ -37,17 +38,17 @@ common haskell

common dependencies
build-depends:
base >=4.7 && <5
, aeson >= 1.4 && <1.6
, bytestring >= 0.10.8
, http-media >= 0.8.0.0
, http-types >= 0.12.3
, proto-lens >= 0.5.0.0
, proto-lens-jsonpb >= 0.2.0.2
, proto-lens-runtime >= 0.5 && <0.8
, servant >= 0.16.2 && <0.19
, text >= 1.2.3.2 && <1.3
, wai >= 3.2.2.1
base
, aeson
, bytestring
, http-media
, http-types
, proto-lens >= 0.6
, proto-lens-jsonpb
, proto-lens-runtime
, servant
, text
, wai

executable twirp-example
import: haskell, dependencies
Expand Down
25 changes: 12 additions & 13 deletions twirp.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.4

name: twirp
version: 0.2.1.0
version: 0.2.2.0
synopsis: Haskell twirp foundations
description: Please see the README on GitHub at <https://github.com/tclem/twirp-haskell#readme>
homepage: https://github.com/tclem/twirp-haskell#readme
Expand All @@ -15,9 +15,8 @@ category: Web
build-type: Simple
extra-source-files: README.md

tested-with: GHC == 8.6.5
, GHC == 8.8.1
, GHC == 8.10.1
tested-with: GHC == 8.10.7
GHC == 9.2.2

-- GHC extensions shared between targets
common haskell
Expand All @@ -39,16 +38,16 @@ common haskell

common dependencies
build-depends:
base >=4.7 && <5
, aeson >= 1.4 && <1.6
, bytestring >= 0.10.8
, http-media >= 0.8.0.0
base >= 4.13 && <5
, aeson >= 1.4 && < 3
, bytestring >= 0.10.8 && < 12
, http-media >= 0.8
, http-types >= 0.12.3
, proto-lens >= 0.5.0.0
, proto-lens-jsonpb >= 0.2.0.2
, proto-lens-runtime >= 0.5 && <0.8
, servant >= 0.16.2 && <0.19
, text >= 1.2.3.2 && <1.3
, proto-lens >= 0.5 && < 0.8
, proto-lens-jsonpb == 0.2.2
, proto-lens-runtime
, servant >= 0.16 && <0.20
, text >= 1.2.3.2 && < 3
, wai >= 3.2.2.1

library
Expand Down

0 comments on commit 98a7de8

Please sign in to comment.