Movatterモバイル変換


[0]ホーム

URL:


base-4.12.0.0: Basic libraries

Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

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.

Synopsis

TheDynamic type

dataDynamicwhereSource#

A 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.

Constructors

Dynamic ::forall a.TypeRep a -> a ->Dynamic 
Instances
ShowDynamicSource#

Since: 2.1

Instance details

Defined inData.Dynamic

ExceptionDynamicSource#

Since: 4.0.0.0

Instance details

Defined inData.Dynamic

Converting to and fromDynamic

toDyn ::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)

fromDynSource#

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.

fromDynamicSource#

Arguments

::Typeable a 
=>Dynamic

the dynamically-typed object

->Maybe a

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

Converts aDynamic object back into an ordinary Haskell value of the correct type. See alsofromDyn.

Applying functions of dynamic type

dynApply ::Dynamic ->Dynamic ->MaybeDynamicSource#

dynApp ::Dynamic ->Dynamic ->DynamicSource#

dynTypeRep ::Dynamic ->SomeTypeRepSource#

Convenience re-exports

classTypeable (a :: k)Source#

The classTypeable allows a concrete representation of a type to be calculated.

Minimal complete definition

typeRep#

Produced byHaddock version 2.20.0


[8]ページ先頭

©2009-2025 Movatter.jp