Data.Dynamic
Contents
Dynamic
typeDynamic
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.
SynopsisDynamic
type
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
).
Show
ing a value of type Dynamic
returns a pretty-printed representation of the object's type; useful for debugging.
Constructors
Dynamic :: forall a. TypeRep a -> a -> Dynamic Instances Instances details Exception Dynamic Source #Since: base-4.0.0.0
Instance detailsDefined in GHC.Internal.Data.Dynamic
Methods
toException :: Dynamic -> SomeException Source #
fromException :: SomeException -> Maybe Dynamic Source #
displayException :: Dynamic -> String Source #
backtraceDesired :: Dynamic -> Bool Source #
Show Dynamic Source #Since: base-2.1
Instance detailsDefined in GHC.Internal.Data.Dynamic
Methods
showsPrec :: Int -> Dynamic -> ShowS Source #
show :: Dynamic -> String Source #
showList :: [Dynamic] -> ShowS Source #
Converting to and fromDynamic
toDyn :: Typeable a => a -> Dynamic Source #
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)
Arguments
:: Typeable a => Dynamicthe dynamically-typed object
-> aa default value
-> areturns: 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
.
Arguments
:: Typeable a => Dynamicthe dynamically-typed object
-> Maybe areturns:
, if the dynamically-typed object has the correct type (and Just
aa
is its value), or Nothing
otherwise.
Converts a Dynamic
object back into an ordinary Haskell value of the correct type. See also fromDyn
.
dynApply :: Dynamic -> Dynamic -> Maybe Dynamic Source #
dynApp :: Dynamic -> Dynamic -> Dynamic Source #
dynTypeRep :: Dynamic -> SomeTypeRep Source #
Convenience re-exportsclass Typeable (a :: k) Source #
The class Typeable
allows a concrete representation of a type to be calculated.
Minimal complete definition
typeRep#
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4