diff options
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 10 | ||||
-rw-r--r-- | libraries/template-haskell/changelog.md | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index 0304eb130b..8be340bf93 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -31,6 +31,7 @@ module Language.Haskell.TH.Syntax -- $infix ) where +import qualified Data.Fixed as Fixed import Data.Data hiding (Fixity(..)) import Data.IORef import System.IO.Unsafe ( unsafePerformIO ) @@ -1056,6 +1057,15 @@ instance Lift Natural where liftTyped x = unsafeCodeCoerce (lift x) lift x = return (LitE (IntegerL (fromIntegral x))) +instance Lift (Fixed.Fixed a) where + liftTyped x = unsafeCodeCoerce (lift x) + lift (Fixed.MkFixed x) = do + ex <- lift x + return (ConE mkFixedName `AppE` ex) + where + mkFixedName = + mkNameG DataName "base" "Data.Fixed" "MkFixed" + instance Integral a => Lift (Ratio a) where liftTyped x = unsafeCodeCoerce (lift x) lift x = return (LitE (RationalL (toRational x))) diff --git a/libraries/template-haskell/changelog.md b/libraries/template-haskell/changelog.md index bf63b6e689..8382efd1fc 100644 --- a/libraries/template-haskell/changelog.md +++ b/libraries/template-haskell/changelog.md @@ -7,6 +7,7 @@ * Add `TypeDataD` constructor to the `Dec` type for `type data` declarations (GHC proposal #106). + * Add `instance Lift (Fixed a)` ## 2.19.0.0 |