
14 Jul
2010
14 Jul
'10
7:38 a.m.
2010/7/14 Felipe Lessa
On Wed, Jul 14, 2010 at 8:25 AM, Arnaud Bailly
wrote: Hello, 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 [1]
[1] http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Data-Typeable... [snip]
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). Cheers, Thu