From fd074a439d7a5ef676d47d950d5d701d04e780fb Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Sun, 19 Jun 2022 23:55:00 +0300 Subject: [PATCH] Change RnfArgs to be data family Then we don't rely that heavily on simplifier to remove the GADT overhead. Even when unoptimized, there isn't additional box over RnfArgs1. I did similar change to hashable in 2019. --- Control/DeepSeq.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs index 84af949..d32b7e8 100644 --- a/Control/DeepSeq.hs +++ b/Control/DeepSeq.hs @@ -3,9 +3,9 @@ {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE EmptyCase #-} @@ -152,9 +152,9 @@ instance GNFData arity V1 where data Zero data One -data RnfArgs arity a where - RnfArgs0 :: RnfArgs Zero a - RnfArgs1 :: (a -> ()) -> RnfArgs One a +data family RnfArgs arity a +data instance RnfArgs Zero a = RnfArgs0 +newtype instance RnfArgs One a = RnfArgs1 (a -> ()) instance GNFData arity U1 where grnf _ U1 = ()