From 2e99771458a7c5afe97dfbc08249abad3032049a Mon Sep 17 00:00:00 2001 From: konsumlamm Date: Sat, 1 Nov 2025 14:06:03 +0100 Subject: [PATCH] Change `Read` and `Show` instances to use `fromList` --- CHANGELOG.md | 5 +++++ src/BinomialQueue/Internals.hs | 12 ++++++------ src/Data/PQueue/Internals.hs | 12 ++++++------ src/Data/PQueue/Max.hs | 12 ++++++------ src/Data/PQueue/Prio/Internals.hs | 12 ++++++------ src/Data/PQueue/Prio/Max/Internals.hs | 12 ++++++------ 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7063e4..6d79032 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Revision history for pqueue +## 1.7.0.0 + +* Change `Read` and `Show` instances to use `fromList` + ([#144](https://github.com/lspitzner/pqueue/issues/144)) + ## 1.6.0.0 -- 2025-10-11 * Deprecate `mapU` and replace it by `mapMonotonic` in `Data.PQeueu.Min` and `Data.PQueue.Max` diff --git a/src/BinomialQueue/Internals.hs b/src/BinomialQueue/Internals.hs index e81a7cd..1612c1b 100644 --- a/src/BinomialQueue/Internals.hs +++ b/src/BinomialQueue/Internals.hs @@ -726,21 +726,21 @@ instance NFData a => NFData (MinQueue a) where instance (Ord a, Show a) => Show (MinQueue a) where showsPrec p xs = showParen (p > 10) $ - showString "fromAscList " . shows (toAscList xs) + showString "fromList " . shows (toAscList xs) -instance Read a => Read (MinQueue a) where +instance (Ord a, Read a) => Read (MinQueue a) where #ifdef __GLASGOW_HASKELL__ readPrec = parens $ prec 10 $ do - Ident "fromAscList" <- lexP + Ident "fromList" <- lexP xs <- readPrec - return (fromAscList xs) + return (fromList xs) readListPrec = readListPrecDefault #else readsPrec p = readParen (p > 10) $ \r -> do - ("fromAscList",s) <- lex r + ("fromList",s) <- lex r (xs,t) <- reads s - return (fromAscList xs,t) + return (fromList xs,t) #endif instance Ord a => Semigroup (MinQueue a) where diff --git a/src/Data/PQueue/Internals.hs b/src/Data/PQueue/Internals.hs index bdaa0b3..c7abe7b 100644 --- a/src/Data/PQueue/Internals.hs +++ b/src/Data/PQueue/Internals.hs @@ -357,21 +357,21 @@ instance NFData a => NFData (MinQueue a) where instance (Ord a, Show a) => Show (MinQueue a) where showsPrec p xs = showParen (p > 10) $ - showString "fromAscList " . shows (toAscList xs) + showString "fromList " . shows (toAscList xs) -instance Read a => Read (MinQueue a) where +instance (Ord a, Read a) => Read (MinQueue a) where #ifdef __GLASGOW_HASKELL__ readPrec = parens $ prec 10 $ do - Ident "fromAscList" <- lexP + Ident "fromList" <- lexP xs <- readPrec - return (fromAscList xs) + return (fromList xs) readListPrec = readListPrecDefault #else readsPrec p = readParen (p > 10) $ \r -> do - ("fromAscList",s) <- lex r + ("fromList",s) <- lex r (xs,t) <- reads s - return (fromAscList xs,t) + return (fromList xs,t) #endif instance Ord a => Semigroup (MinQueue a) where diff --git a/src/Data/PQueue/Max.hs b/src/Data/PQueue/Max.hs index da3ef4d..9f60464 100644 --- a/src/Data/PQueue/Max.hs +++ b/src/Data/PQueue/Max.hs @@ -124,21 +124,21 @@ instance NFData a => NFData (MaxQueue a) where instance (Ord a, Show a) => Show (MaxQueue a) where showsPrec p xs = showParen (p > 10) $ - showString "fromDescList " . shows (toDescList xs) + showString "fromList " . shows (toDescList xs) -instance Read a => Read (MaxQueue a) where +instance (Ord a, Read a) => Read (MaxQueue a) where #ifdef __GLASGOW_HASKELL__ readPrec = parens $ prec 10 $ do - Ident "fromDescList" <- lexP + Ident "fromList" <- lexP xs <- readPrec - return (fromDescList xs) + return (fromList xs) readListPrec = readListPrecDefault #else readsPrec p = readParen (p > 10) $ \r -> do - ("fromDescList",s) <- lex r + ("fromList",s) <- lex r (xs,t) <- reads s - return (fromDescList xs,t) + return (fromList xs,t) #endif instance Ord a => Semigroup (MaxQueue a) where diff --git a/src/Data/PQueue/Prio/Internals.hs b/src/Data/PQueue/Prio/Internals.hs index 7db046f..a6ce92c 100644 --- a/src/Data/PQueue/Prio/Internals.hs +++ b/src/Data/PQueue/Prio/Internals.hs @@ -130,21 +130,21 @@ instance Ord k => Monoid (MinPQueue k a) where instance (Ord k, Show k, Show a) => Show (MinPQueue k a) where showsPrec p xs = showParen (p > 10) $ - showString "fromAscList " . shows (toAscList xs) + showString "fromList " . shows (toAscList xs) -instance (Read k, Read a) => Read (MinPQueue k a) where +instance (Ord k, Read k, Read a) => Read (MinPQueue k a) where #ifdef __GLASGOW_HASKELL__ readPrec = parens $ prec 10 $ do - Ident "fromAscList" <- lexP + Ident "fromList" <- lexP xs <- readPrec - return (fromAscList xs) + return (fromList xs) readListPrec = readListPrecDefault #else readsPrec p = readParen (p > 10) $ \r -> do - ("fromAscList",s) <- lex r + ("fromList",s) <- lex r (xs,t) <- reads s - return (fromAscList xs,t) + return (fromList xs,t) #endif -- | The union of a list of queues: (@'unions' == 'List.foldl' 'union' 'empty'@). diff --git a/src/Data/PQueue/Prio/Max/Internals.hs b/src/Data/PQueue/Prio/Max/Internals.hs index 3914645..8d9d994 100644 --- a/src/Data/PQueue/Prio/Max/Internals.hs +++ b/src/Data/PQueue/Prio/Max/Internals.hs @@ -162,21 +162,21 @@ instance Ord k => Monoid (MaxPQueue k a) where instance (Ord k, Show k, Show a) => Show (MaxPQueue k a) where showsPrec p xs = showParen (p > 10) $ - showString "fromDescList " . shows (toDescList xs) + showString "fromList " . shows (toDescList xs) -instance (Read k, Read a) => Read (MaxPQueue k a) where +instance (Ord k, Read k, Read a) => Read (MaxPQueue k a) where #ifdef __GLASGOW_HASKELL__ readPrec = parens $ prec 10 $ do - Ident "fromDescList" <- lexP + Ident "fromList" <- lexP xs <- readPrec - return (fromDescList xs) + return (fromList xs) readListPrec = readListPrecDefault #else readsPrec p = readParen (p > 10) $ \r -> do - ("fromDescList",s) <- lex r + ("fromList",s) <- lex r (xs,t) <- reads s - return (fromDescList xs,t) + return (fromList xs,t) #endif instance Functor (MaxPQueue k) where