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

Allow template-haskell 2.17, 2.18 #34

Merged
merged 2 commits into from
Jan 7, 2022
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 package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ library:
dependencies:
- natural-transformation >= 0.2
- transformers-base
- template-haskell >= 2.11 && < 2.17
- template-haskell >= 2.11 && < 2.19

executables:
freer-examples:
Expand Down
10 changes: 10 additions & 0 deletions src/Control/Monad/Freer/TH.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}

Expand Down Expand Up @@ -121,7 +122,11 @@ genType (GadtC _ tArgs' (AppT eff tRet)) = do
resultType = ConT ''Eff `AppT` VarT effs `AppT` tRet

return
#if MIN_VERSION_template_haskell(2,17,0)
. ForallT [PlainTV effs SpecifiedSpec] [memberConstraint]
#else
. ForallT [PlainTV effs] [memberConstraint]
#endif
. foldArrows
$ tArgs
++ [resultType]
Expand All @@ -141,8 +146,13 @@ simplifyBndrs t = t

-- | Turn TvVarBndrs of the form (KindedTV tv StarT) into (PlainTV tv)
-- This can prevent the need for KindSignatures
#if MIN_VERSION_template_haskell(2,17,0)
simplifyBndr :: TyVarBndrSpec -> TyVarBndrSpec
simplifyBndr (KindedTV tv f StarT) = PlainTV tv f
#else
simplifyBndr :: TyVarBndr -> TyVarBndr
simplifyBndr (KindedTV tv StarT) = PlainTV tv
#endif
simplifyBndr bndr = bndr

-- | Generates a type signature of the form
Expand Down