Skip to content

Commit

Permalink
fix for all versions of ghc
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfowler committed Nov 30, 2023
1 parent 4119999 commit 741220e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ stdenv.mkDerivation {

buildInputs = [
ghc
# cabal-install
# haskellPackages.ghcid
cabal-install
haskellPackages.ghcid
haskellPackages.stylish-haskell
];

Expand Down
24 changes: 21 additions & 3 deletions src/CircuitNotation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -755,15 +755,33 @@ tagE a = varE noSrcSpan (tagName ?nms) `appE` a
tagTypeCon :: (p ~ GhcPs, ?nms :: ExternalNames) => LHsType GhcPs
tagTypeCon = noLoc (HsTyVar noExt NotPromoted (noLoc (tagTName ?nms)))

sigPat :: (p ~ GhcPs) => SrcSpan -> LHsType GhcPs -> LPat p -> LPat p
sigPat loc ty a = L loc $
#if __GLASGOW_HASKELL__ < 810
SigPat (HsWC noExt (HsIB noExt ty)) a
#elif __GLASGOW_HASKELL__ < 900
SigPat noExt a (HsWC noExt (HsIB noExt ty))
#else
SigPat noExt a (HsPS noExt ty)
#endif

sigE :: (p ~ GhcPs, ?nms :: ExternalNames) => SrcSpan -> LHsType GhcPs -> LHsExpr p -> LHsExpr p
sigE loc ty a = L loc $
#if __GLASGOW_HASKELL__ < 810
ExprWithTySig (HsWC noExt (HsIB noExt ty)) a
#else
ExprWithTySig noExt a (HsWC noExt (HsIB noExt ty))
#endif

tagTypeP :: (p ~ GhcPs, ?nms :: ExternalNames) => Direction -> LHsType GhcPs -> LPat p -> LPat p
tagTypeP dir ty a
= noLoc (SigPat (HsWC noExt (HsIB noExt (tagTypeCon `appTy` ty `appTy` busType))) a)
tagTypeP dir ty
= sigPat noSrcSpan (tagTypeCon `appTy` ty `appTy` busType)
where
busType = conT noSrcSpan (fwdAndBwdTypes ?nms dir) `appTy` ty

tagTypeE :: (p ~ GhcPs, ?nms :: ExternalNames) => Direction -> LHsType GhcPs -> LHsExpr p -> LHsExpr p
tagTypeE dir ty a
= noLoc (ExprWithTySig (HsWC noExt (HsIB noExt (tagTypeCon `appTy` ty `appTy` busType))) a)
= sigE noSrcSpan (tagTypeCon `appTy` ty `appTy` busType) a
where
busType = conT noSrcSpan (fwdAndBwdTypes ?nms dir) `appTy` ty

Expand Down

0 comments on commit 741220e

Please sign in to comment.