X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FDynamic.hs;h=7466897827101f5d3f482e7c4e63aed963adb172;hb=1a2c75698b74fe40e3cd91854c3f6a64e1dac348;hp=abaffe28a1266440a95819262fbb406f89a80d79;hpb=125018bd716dc3a36645886818101c9010abd0a2;p=ghc-base.git diff --git a/Data/Dynamic.hs b/Data/Dynamic.hs index abaffe2..7466897 100644 --- a/Data/Dynamic.hs +++ b/Data/Dynamic.hs @@ -1,4 +1,4 @@ -{-# OPTIONS_GHC -fno-implicit-prelude #-} +{-# OPTIONS_GHC -XNoImplicitPrelude #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Dynamic @@ -21,20 +21,20 @@ module Data.Dynamic ( - -- Module Data.Typeable re-exported for convenience - module Data.Typeable, + -- Module Data.Typeable re-exported for convenience + module Data.Typeable, - -- * The @Dynamic@ type - Dynamic, -- abstract, instance of: Show, Typeable + -- * The @Dynamic@ type + Dynamic, -- abstract, instance of: Show, Typeable - -- * Converting to and from @Dynamic@ - toDyn, -- :: Typeable a => a -> Dynamic - fromDyn, -- :: Typeable a => Dynamic -> a -> a - fromDynamic, -- :: Typeable a => Dynamic -> Maybe a - - -- * Applying functions of dynamic type - dynApply, - dynApp, + -- * Converting to and from @Dynamic@ + toDyn, -- :: Typeable a => a -> Dynamic + fromDyn, -- :: Typeable a => Dynamic -> a -> a + fromDynamic, -- :: Typeable a => Dynamic -> Maybe a + + -- * Applying functions of dynamic type + dynApply, + dynApp, dynTypeRep ) where @@ -66,7 +66,7 @@ import NHC.IOExtras (IORef,newIORef,readIORef,writeIORef,unsafePerformIO) ------------------------------------------------------------- -- --- The type Dynamic +-- The type Dynamic -- ------------------------------------------------------------- @@ -90,8 +90,8 @@ instance Show Dynamic where -- the instance just prints the type representation. showsPrec _ (Dynamic t _) = showString "<<" . - showsPrec 0 t . - showString ">>" + showsPrec 0 t . + showString ">>" #ifdef __GLASGOW_HASKELL__ type Obj = Any @@ -121,11 +121,11 @@ toDyn v = Dynamic (typeOf v) (unsafeCoerce v) -- | Converts a 'Dynamic' object back into an ordinary Haskell value of -- the correct type. See also 'fromDynamic'. fromDyn :: Typeable a - => Dynamic -- ^ the dynamically-typed object - -> a -- ^ a default value - -> a -- ^ returns: the value of the first argument, if - -- it has the correct type, otherwise the value of - -- the second argument. + => Dynamic -- ^ the dynamically-typed object + -> a -- ^ a default value + -> a -- ^ returns: the value of the first argument, if + -- it has the correct type, otherwise the value of + -- the second argument. fromDyn (Dynamic t v) def | typeOf def == t = unsafeCoerce v | otherwise = def @@ -133,11 +133,11 @@ fromDyn (Dynamic t v) def -- | Converts a 'Dynamic' object back into an ordinary Haskell value of -- the correct type. See also 'fromDyn'. fromDynamic - :: Typeable a - => Dynamic -- ^ the dynamically-typed object - -> Maybe a -- ^ returns: @'Just' a@, if the dynamically-typed - -- object has the correct type (and @a@ is its value), - -- or 'Nothing' otherwise. + :: Typeable a + => Dynamic -- ^ the dynamically-typed object + -> Maybe a -- ^ returns: @'Just' a@, if the dynamically-typed + -- object has the correct type (and @a@ is its value), + -- or 'Nothing' otherwise. fromDynamic (Dynamic t v) = case unsafeCoerce v of r | t == typeOf r -> Just r