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


-- | TagShare - explicit sharing with tags
--   
--   TagShare supplies a monad for sharing values based on tags and types.
--   Each tag and type is bound to at most one value in a dynamic map.
--   
--   The principal use of this package is to ensure that constant class
--   members or other overloaded values are shared.
@package tagshare
@version 0.0


-- | A monad for binding values to tags to ensure sharing, with the added
--   twist that the value can be polymorphic and each monomorphic instance
--   is bound separately.
module Control.Monad.TagShare

-- | A dynamic map with type safe insertion and lookup.
data DynMap tag
dynEmpty :: DynMap tag
dynInsert :: (Typeable a, Ord tag) => tag -> a -> DynMap tag -> DynMap tag
dynLookup :: (Typeable a, Ord tag) => tag -> DynMap tag -> Maybe a

-- | A sharing monad with a function that binds a tag to a value.
type Sharing tag a = State (DynMap tag) a
runSharing :: Sharing tag a -> a
share :: (Typeable a, Ord tag) => tag -> Sharing tag a -> Sharing tag a
instance GHC.Show.Show tag => GHC.Show.Show (Control.Monad.TagShare.DynMap tag)
