Skip to content

Commit 0378ae1

Browse files
committed
Support GHC 8.10 and 9.6
1 parent 18992c5 commit 0378ae1

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ packages: ./typed-protocols
2323
source-repository-package
2424
type: git
2525
location: https://github.com/input-output-hk/serdoc
26-
tag: 2cd52c768c32c6c61ccc355bc8cfd8e67f25d8ca
26+
tag: c1e6d6ae22d58a402ac359b26be7b922921d2a73
2727
subdir: serdoc-core
2828

2929
test-show-details: direct

typed-protocols-doc/src/Network/TypedProtocol/Documentation/TH.hs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE LambdaCase #-}
23
{-# LANGUAGE TemplateHaskell #-}
34
{-# LANGUAGE QuasiQuotes #-}
@@ -10,7 +11,10 @@ where
1011
import Network.TypedProtocol.Documentation.Types
1112

1213
import Control.Monad
13-
import Data.Maybe
14+
#if MIN_VERSION_template_haskell(2,17,0)
15+
-- This import is only needed when 'getDoc' is available.
16+
import Data.Maybe (maybeToList)
17+
#endif
1418
import Data.Proxy
1519
import Language.Haskell.TH
1620
import Language.Haskell.TH.Datatype
@@ -91,8 +95,9 @@ describeProtocol protoTyCon protoTyArgs codecTyCon codecTyArgs = do
9195
|]
9296

9397
unearthType :: Type -> Type
98+
#if MIN_VERSION_template_haskell(2,17,0)
9499
unearthType (AppT (AppT MulArrowT _) t) = unearthType t
95-
-- unearthType (AppT a _) = unearthType a
100+
#endif
96101
unearthType (SigT a _) = unearthType a
97102
unearthType t = t
98103

@@ -116,7 +121,12 @@ prettyTy = snd . go
116121

117122
getDescription :: Name -> Q [Description]
118123
getDescription name = do
124+
#if MIN_VERSION_template_haskell(2,17,0)
119125
haddock <- maybeToList <$> getDoc (DeclDoc name)
126+
#else
127+
-- 'getDoc' does not exist before template-haskell-2.17.0
128+
let haddock = []
129+
#endif
120130
annotations <- reifyAnnotations (AnnLookupName name)
121131
return $ (Description . (:[]) <$> haddock) ++ annotations
122132

@@ -140,9 +150,15 @@ describeProtocolMessage protoTyCon protoTyArgs codecTyCon codecTyArgs msgName =
140150

141151

142152
let payloads = constructorFields msgInfo
153+
#if MIN_VERSION_template_haskell(2,17,0)
143154
tyVarName :: TyVarBndr a -> Name
144155
tyVarName (PlainTV n _) = n
145156
tyVarName (KindedTV n _ _) = n
157+
#else
158+
tyVarName :: TyVarBndr -> Name
159+
tyVarName (PlainTV n) = n
160+
tyVarName (KindedTV n _) = n
161+
#endif
146162

147163
findType :: Name -> Cxt -> Type
148164
findType n (AppT (AppT EqualityT (VarT vn)) t : _)

typed-protocols-doc/typed-protocols-doc.cabal

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ library
3030
, Network.TypedProtocol.Documentation.DefaultMain
3131
-- other-modules:
3232
-- other-extensions:
33-
build-depends: base >=4.16.0.0 && <5
33+
build-depends: base >=4.14.0.0 && <5
3434

3535
, aeson >=2.0 && <2.3
3636
, base64-bytestring >=1.2.1.0 && <1.3
@@ -41,10 +41,10 @@ library
4141
, filepath >=1.4.2.2 && <1.6
4242
, graphviz >=2999.20.1 && <2999.21.0
4343
, haddock-library >=1.11.0 && <1.12
44-
, knob >=0.2.2 && <0.3
44+
, knob >=0.1 && <0.3
4545
, mtl >=2.3.1 && <2.4
4646
, optparse-applicative >=0.18.1.0 && <0.19
47-
, template-haskell >=2.16.0.0
47+
, template-haskell >=2.13.0.0
4848
, temporary >=1.3 && <1.4
4949
, text >=1.1 && <2.2
5050
, th-abstraction >=0.6.0.0 && <0.7
@@ -62,7 +62,7 @@ executable typed-protocols-doc-demo
6262
main-is: Main.hs
6363
-- other-modules:
6464
-- other-extensions:
65-
build-depends: base >=4.16.0.0 && <5
65+
build-depends: base >=4.14.0.0 && <5
6666
, typed-protocols-doc
6767
, serdoc-core
6868

@@ -76,7 +76,7 @@ test-suite typed-protocols-doc-test
7676
other-modules: Network.TypedProtocol.Tests.Documentation
7777
, Network.TypedProtocol.Tests.ControlProtocol
7878
-- other-extensions:
79-
build-depends: base >=4.16.0.0 && <5
79+
build-depends: base >=4.14.0.0 && <5
8080
, tasty >=1.5 && <1.6
8181
, tasty-quickcheck >=0.10.3 && <0.11
8282
, typed-protocols

0 commit comments

Comments
 (0)