From 9f172865ffc67a8f0b960ca8bf06ea0679255649 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Fri, 9 May 2008 09:50:42 +0000 Subject: [PATCH] Move DataBox into Utils. AnyDataItem is effectively the same, so we could reuse DataBox for that too in the future. --- common/GenericUtils.hs | 4 +--- common/Utils.hs | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/GenericUtils.hs b/common/GenericUtils.hs index 78fe23d..acca2e4 100644 --- a/common/GenericUtils.hs +++ b/common/GenericUtils.hs @@ -39,6 +39,7 @@ import Data.Typeable import System.IO.Unsafe import qualified AST as A +import Utils -- | A type identifier. type TypeKey = Int @@ -47,9 +48,6 @@ type TypeKey = Int typeKey :: Typeable a => a -> TypeKey typeKey x = unsafePerformIO $ typeRepKey $ typeOf x --- | Container for 'Data' items. -data DataBox = forall a. (Typeable a, Data a) => DataBox a - -- | Given a witness for a type, return witnesses for all the types that its -- constructors take. constrArgTypes :: (Data a, Typeable a) => a -> [DataBox] diff --git a/common/Utils.hs b/common/Utils.hs index e59d313..e64789a 100644 --- a/common/Utils.hs +++ b/common/Utils.hs @@ -23,6 +23,7 @@ module Utils where import Control.Monad.State import Data.Array.IArray import Data.List +import Data.Generics (Data) import qualified Data.Map as Map import Data.Maybe import Data.Ord @@ -296,3 +297,6 @@ makeArraySize size def arr = array size [(i,arrayLookupWithDefault def arr i) | -- This is like '(\/\/)'. replaceAt :: Int -> a -> [a] -> [a] replaceAt n rep es = [if i == n then rep else e | (e, i) <- zip es [0..]] + +-- | A type that can contain any 'Data' item. +data DataBox = forall t. Data t => DataBox t