{-# LANGUAGE EmptyDataDecls #-}
module Main (main) where
import Unsafe.Coerce
data Anything
newtype Key x = Key Int deriving Eq
type Dict = [(Key Anything, Anything)]
put :: Key x - x - Dict - Dict
put k' v' = raw (unsafeCoerce k') (unsafeCoerce v')
where
raw k0 v0 [] = [(k0,v0)]
raw
It looks like you may want
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Dynamic.html
. It does more or less what you're talking about behind the scenes,
but probably uses the magical Any type to not encounter issues with
functions, and gives you a Nothing if you attempt to
Maybe you would like the hetero-map package. Its purpose is to do
precisely what you are doing, but in a typesafe way.
On Thu, Oct 15, 2009 at 3:10 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
{-# LANGUAGE EmptyDataDecls #-}
module Main (main) where
import Unsafe.Coerce
data