From 59dfb00584e6d24d82d3f5338c6299bae48e0468 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Wed, 27 Oct 2021 14:19:59 +0100 Subject: Remove record field from Solo Ticket #20562 revealed that Solo, which is a wired-in TyCon, had a record field that wasn't being added to the type env. Why not? Because wired-in TyCons don't have record fields. It's not hard to change that, but it's tiresome for this one use-case, and it seems easier simply to make `getSolo` into a standalone function. On the way I refactored the handling of Solo slightly, to put it into wiredInTyCons (where it belongs) rather than only in knownKeyNames --- libraries/ghc-prim/GHC/Tuple.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libraries/ghc-prim') diff --git a/libraries/ghc-prim/GHC/Tuple.hs b/libraries/ghc-prim/GHC/Tuple.hs index 9254ab72ae..9f4b70e6c1 100644 --- a/libraries/ghc-prim/GHC/Tuple.hs +++ b/libraries/ghc-prim/GHC/Tuple.hs @@ -77,7 +77,15 @@ data () = () -- unary tuples, they can also be useful for fine-grained control of -- strict-spined data structure traversals, and for unifying the -- implementations of lazy and strict mapping functions. -data Solo a = Solo { getSolo :: a } +data Solo a = Solo a + +getSolo :: Solo a -> a +-- getSolo is a standalone function, rather than a record field of Solo, +-- because Solo is a wired-in TyCon, and a wired-in TyCon that has +-- record fields is a bit more inconvenient than if it doesn't. +-- (No other wired-in TyCon has record fields.) So it seems easier +-- to have getSolo as its own separate function (#20562) +getSolo (Solo a) = a data (a,b) = (a,b) data (a,b,c) = (a,b,c) -- cgit v1.2.1