summaryrefslogtreecommitdiff
path: root/compiler/GHC/Utils/Misc.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Utils/Misc.hs')
-rw-r--r--compiler/GHC/Utils/Misc.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/GHC/Utils/Misc.hs b/compiler/GHC/Utils/Misc.hs
index 7436487739..e6decc3b9d 100644
--- a/compiler/GHC/Utils/Misc.hs
+++ b/compiler/GHC/Utils/Misc.hs
@@ -7,6 +7,7 @@
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE DeriveDataTypeable #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
@@ -130,6 +131,9 @@ module GHC.Utils.Misc (
-- * Utils for flags
OverridingBool(..),
overrideWith,
+
+ -- * Box
+ Box(Box, unBox),
) where
#include "HsVersions.h"
@@ -1476,3 +1480,12 @@ overrideWith :: Bool -> OverridingBool -> Bool
overrideWith b Auto = b
overrideWith _ Always = True
overrideWith _ Never = False
+
+-- A wrapper to make a strict field into a lazy one.
+data Box a = Box { unBox :: a }
+ deriving (Eq, Ord, Data)
+
+instance Show a => Show (Box a) where
+ showsPrec n (Box a) = showsPrec n a
+ show (Box a) = show a
+ showList xs = showList (map unBox xs)