-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Sharing/memoization of class members
--   
--   Library for ensuring that class members are shared.
@package dictionary-sharing
@version 0.1.0.0

module Data.ClassSharing
data Shared f a
newtype Shareable f a
Shareable :: (Ref -> f a) -> Shareable f a
[run] :: Shareable f a -> Ref -> f a

-- | Share/memoize a class member of type <tt>f a</tt>.
share :: (Typeable a, Typeable f) => Shareable f a -> Shared f a

-- | Should only be used to access class members. A safe wrapper should be
--   defined for every shared class member. Direct access can lead to
--   overriding class member definitions.
unsafeAccess :: Shared f a -> Shareable f a
runShared :: Shared f a -> Ref -> f a
type Ref = IORef DynMap

-- | A dynamic map with type safe insertion and lookup.
data DynMap
newRef :: IO Ref
unsafeNewRef :: () -> Ref

-- | The class <a>Typeable</a> allows a concrete representation of a type
--   to be calculated.
class Typeable (a :: k)
instance GHC.Show.Show Data.ClassSharing.DynMap
instance GHC.Base.Functor f => GHC.Base.Functor (Data.ClassSharing.Shareable f)
instance GHC.Base.Applicative f => GHC.Base.Applicative (Data.ClassSharing.Shareable f)
instance GHC.Base.Alternative f => GHC.Base.Alternative (Data.ClassSharing.Shareable f)
