Skip to content

Commit

Permalink
Require template-haskell-2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Nov 12, 2023
1 parent 78cf851 commit 8948739
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
2 changes: 1 addition & 1 deletion quote-quot.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ library
ghc-options: -Wall -Wcompat
build-depends:
base >=4.15 && < 5,
template-haskell >=2.16
template-haskell >=2.17 && <2.22

test-suite quote-quot-tests
type: exitcode-stdio-1.0
Expand Down
19 changes: 0 additions & 19 deletions src/Numeric/QuoteQuot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
--

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
Expand All @@ -33,8 +32,6 @@ module Numeric.QuoteQuot
, MulHi(..)
) where

#include "MachDeps.h"

import Prelude
import Data.Bits
import Data.Int
Expand Down Expand Up @@ -80,29 +77,17 @@ import Language.Haskell.TH.Syntax
-- than @(`@'quot'@` 10)@.
--
quoteQuot ::
#if MIN_VERSION_template_haskell(2,17,0)
(MulHi a, Lift a, Quote m) => a -> Code m (a -> a)
#else
(MulHi a, Lift a) => a -> Q (TExp (a -> a))
#endif
quoteQuot d = quoteAST (astQuot d)

-- | Similar to 'quoteQuot', but for 'rem'.
quoteRem ::
#if MIN_VERSION_template_haskell(2,17,0)
(MulHi a, Lift a, Quote m) => a -> Code m (a -> a)
#else
(MulHi a, Lift a) => a -> Q (TExp (a -> a))
#endif
quoteRem d = [|| snd . $$(quoteQuotRem d) ||]

-- | Similar to 'quoteQuot', but for 'quotRem'.
quoteQuotRem ::
#if MIN_VERSION_template_haskell(2,17,0)
(MulHi a, Lift a, Quote m) => a -> Code m (a -> (a, a))
#else
(MulHi a, Lift a) => a -> Q (TExp (a -> (a, a)))
#endif
quoteQuotRem d = [|| \w -> let q = $$(quoteQuot d) w in (q, w - d * q) ||]

-- | Types allowing to multiply wide and return the high word of result.
Expand Down Expand Up @@ -205,11 +190,7 @@ defaultMulHi x y = fromInteger $ (toInteger x * toInteger y) `shiftR` finiteBitS

-- | Embed 'AST' into Haskell expression.
quoteAST ::
#if MIN_VERSION_template_haskell(2,17,0)
(MulHi a, Lift a, Quote m) => AST a -> Code m (a -> a)
#else
(MulHi a, Lift a) => AST a -> Q (TExp (a -> a))
#endif
quoteAST = \case
Arg -> [|| id ||]
Shr x k -> [|| (`shiftR` k) . $$(quoteAST x) ||]
Expand Down

0 comments on commit 8948739

Please sign in to comment.