HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulerebase-1.21.2Haskell2010

Rebase.Data.Dynamic

  • 1 type
  • 1 class
  • 6 values
  • Packagerebase-1.21.2
  • Exports8
  • LanguageHaskell2010
  • LicenceMIT
  • SourceDynamic.hs
datadata Dynamic where
#

A value of type Dynamic is an object encapsulated together with its type.

A Dynamic may only represent a monomorphic value; an attempt to create a value of type Dynamic from a polymorphically-typed expression will result in an ambiguity error (see toDyn).

Showing a value of type Dynamic returns a pretty-printed representation of the object's type; useful for debugging.

Constructors

Instances2Show, Exception
  • Show DynamicDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Dynamic
  • Exception DynamicDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Dynamic
classclass Typeable (a :: k) where
#

The class Typeable allows a concrete representation of a type to be calculated.

valuefromDyn
  1. :: Typeable a
  2. => Dynamic

    the dynamically-typed object

  3. -> a

    a default value

  4. -> a

    returns: the value of the first argument, if it has the correct type, otherwise the value of the second argument.

#

Converts a Dynamic object back into an ordinary Haskell value of the correct type. See also fromDynamic.

valuefromDynamic
  1. :: Typeable a
  2. => Dynamic

    the dynamically-typed object

  3. -> Maybe a

    returns: Just a, if the dynamically-typed object has the correct type (and a is its value), or Nothing otherwise.

#

Converts a Dynamic object back into an ordinary Haskell value of the correct type. See also fromDyn.

valuetoDyn :: Typeable a => a -> Dynamic
#

Converts an arbitrary value into an object of type Dynamic.

The type of the object must be an instance of Typeable, which ensures that only monomorphically-typed objects may be converted to Dynamic. To convert a polymorphic object into Dynamic, give it a monomorphic type signature. For example:

   toDyn (id :: Int -> Int)