From 0e95ca1da48808f840b3f3088eb259f07d8e8fcc Mon Sep 17 00:00:00 2001 From: RyanGlScott Date: Thu, 16 Jul 2015 13:00:00 -0500 Subject: [PATCH] Backport PrintfArg Natural instance to GHC 7.8 --- src/Numeric/Natural.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Numeric/Natural.hs b/src/Numeric/Natural.hs index cbc1e0b..5ca64bd 100644 --- a/src/Numeric/Natural.hs +++ b/src/Numeric/Natural.hs @@ -43,6 +43,9 @@ import Data.Data #ifdef MIN_VERSION_hashable import Data.Hashable #endif +#if MIN_VERSION_base(4,7,0) && !(MIN_VERSION_base(4,8,0)) +import Text.Printf (PrintfArg(..), formatInteger) +#endif -- | Type representing arbitrary-precision non-negative integers. -- @@ -206,3 +209,9 @@ instance Integral Natural where {-# INLINE quotRem #-} toInteger = runNatural {-# INLINE toInteger #-} + +#if MIN_VERSION_base(4,7,0) && !(MIN_VERSION_base(4,8,0)) +instance PrintfArg Natural where + formatArg = formatInteger . toInteger + parseFormat _ = parseFormat (undefined :: Integer) +#endif