Move DataBox into Utils.

AnyDataItem is effectively the same, so we could reuse DataBox for that
too in the future.
This commit is contained in:
Adam Sampson 2008-05-09 09:50:42 +00:00
parent 9c77aed7b3
commit 9f172865ff
2 changed files with 5 additions and 3 deletions

View File

@ -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]

View File

@ -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