| Copyright | (c) The University of Glasgow 2001 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | libraries@haskell.org |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Data.Dynamic
Contents
Description
The Dynamic interface provides basic support for dynamic types.
Operations for injecting values of arbitrary type into a dynamically typed value, Dynamic, are provided, together with operations for converting dynamic values into a concrete (monomorphic) type.
Dynamic typeA value of typeDynamic is an object encapsulated together with its type.
ADynamic may only represent a monomorphic value; an attempt to create a value of typeDynamic from a polymorphically-typed expression will result in an ambiguity error (seetoDyn).
Showing a value of typeDynamic returns a pretty-printed representation of the object's type; useful for debugging.
DynamictoDyn ::Typeable a => a ->DynamicSource#
Converts an arbitrary value into an object of typeDynamic.
The type of the object must be an instance ofTypeable, which ensures that only monomorphically-typed objects may be converted toDynamic. To convert a polymorphic object intoDynamic, give it a monomorphic type signature. For example:
toDyn (id :: Int -> Int)
Arguments
| ::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. |
Converts aDynamic object back into an ordinary Haskell value of the correct type. See alsofromDynamic.
Produced byHaddock version 2.20.0