on master help sign in
Show reimplemented without generics
commitf86932af29ef1d691e393cc7723e42cfcc439c58 authorAlexander V. Nikolaev <avn@avnik.info> dateMon 18 Apr 2022, 15:05 (4 years ago) parentdff2daf
1 file changed+4−4
src/JRec/Internal.hs+4−4
src/JRec/Internal.hs+4−4
@@ -32,6 +32,7 @@ import qualified Control.Monad.State as S
3232import Data.Aeson
3333import Data.Aeson.Types (Parser)
3434import Data.Constraint
35+import Data.List (intercalate)
3536import Data.Maybe (catMaybes)
3637import Data.Proxy
3738import qualified Data.Text as T
@@ -102,13 +103,12 @@ defaultJSONOptions = JSONOptions {fieldTransform = id}
102103type role Rec representational
103104
104105instance
105− ( RecApply lts lts Show,
106− GShow Proxy (Rep (Rec lts)),
107− Generic (Rec lts)
106+ ( RecApply lts lts Show
108107 ) =>
109108 Show (Rec lts)
110109 where
111− show = (\x -> if null x then "{}" else x) . unwords . drop 1 . words . flip (gshowsPrec 0) ""
110+ show rec = "{" ++ formatted ++ "}"
111+ where formatted = intercalate ", " $ map (\(k, v) -> k ++ " = " ++ v) $ showRec rec
112112
113113instance RecEq lts lts => Eq (Rec lts) where
114114 (==) (a :: Rec lts) (b :: Rec lts) = recEq a b (Proxy :: Proxy lts)