From 182af1f1956b81b4b9015da9886047d167e09457 Mon Sep 17 00:00:00 2001 From: Torgeir Strand Henriksen Date: Thu, 9 Jul 2026 11:21:20 +0200 Subject: [PATCH] Support Generically and Generically1. --- CHANGELOG.md | 3 +++ src/TextShow.hs | 1 + src/TextShow/Generic.hs | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0f80f77..289155f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 3.11.5 +* Support `Generically` and `Generically1` from `base-4.17` (GHC 9.4) or later in addition to `FromGeneric` and `FromGeneric1`. + ### 3.11.4 [2026.06.19] * Make the test suite report source locations for test failures accurately. diff --git a/src/TextShow.hs b/src/TextShow.hs index e64946de..ddb48bba 100644 --- a/src/TextShow.hs +++ b/src/TextShow.hs @@ -89,5 +89,6 @@ import Prelude () import TextShow.Classes import TextShow.FromStringTextShow +import TextShow.Generic () import TextShow.Instances () import TextShow.Utils (toString, toText, lengthB, unlinesB, unwordsB) diff --git a/src/TextShow/Generic.hs b/src/TextShow/Generic.hs index 6c462769..700559fe 100644 --- a/src/TextShow/Generic.hs +++ b/src/TextShow/Generic.hs @@ -25,9 +25,12 @@ {-# LANGUAGE UndecidableInstances #-} #if __GLASGOW_HASKELL__ >= 806 +{-# LANGUAGE DerivingVia #-} {-# LANGUAGE QuantifiedConstraints #-} #endif +{-# OPTIONS_GHC -Wno-orphans #-} + {-| Module: TextShow.Generic Copyright: (C) 2014-2017 Ryan Scott @@ -219,6 +222,23 @@ instance ( Generic1 f ) => TextShow1 (FromGeneric1 f) where liftShowbPrec sp sl p = genericLiftShowbPrec sp sl p . fromGeneric1 +#if MIN_VERSION_base(4,17,0) +-- | The 'TextShow' instance for 'Generically' behaves exactly like the instance for 'FromGeneric'. +-- +-- /Since: 3.11.5/ +deriving via FromGeneric a instance (Generic a, GTextShowB (Rep a ())) => TextShow (Generically a) + +-- | The 'TextShow' instance for 'Generically1' behaves exactly like the instance for 'FromGeneric1'. +-- +-- /Since: 3.11.5/ +deriving via FromGeneric1 f a instance (Generic1 f, GTextShowB (Rep1 f a)) => TextShow (Generically1 f a) + +-- | The 'TextShow1' instance for 'Generically1' behaves exactly like the instance for 'FromGeneric1'. +-- +-- /Since: 3.11.5/ +deriving via FromGeneric1 (f :: * -> *) instance (Generic1 f, GTextShowB1 (Rep1 f)) => TextShow1 (Generically1 f) +#endif + -- | A 'Generic' implementation of 'showt'. -- -- /Since: 2/