[Haskell-cafe] Applying a value to a function generically
Vo Minh Thu
noteed at gmail.com
Wed Jul 14 07:38:12 EDT 2010
2010/7/14 Felipe Lessa <felipe.lessa at gmail.com>:
> On Wed, Jul 14, 2010 at 8:25 AM, Arnaud Bailly <arnaud.oqube at gmail.com> wrote:
>> I would like to construct a collection of function-like objects on
>> which I could apply some value, in a typesafe and clean way.
> You could use Data.Typeable.cast 
>  http://haskell.org/ghc/docs/6.12.1/html/libraries/base-184.108.40.206/Data-Typeable.html#v%3Acast
Or maybe Data.Dynamic
with type Callables = Map String Dynamic
You can extract the function with fromDynamic in a type-safe way (it
returns a Maybe).
Probalby you might want 'invoke' to return a Maybe too (just like Felipe did).
More information about the Haskell-Cafe