any workarounds to get polymorphic functions in Data.Dynamics?

248 views Asked by At

The function dynApply from Data.Dynamics looks very nice, but in reality it requires a monomorphic function type. So, you couldn't write

dynApply (toDyn id) (toDyn 3)

I have some code that needs polymorphic return types. They are of a restricted form, e.g. functions

forall t. (a -> t) -> t
forall t. (a -> t) -> b -> t
forall t. (a -> t) -> b -> c -> t
...

(where a, b, c are concrete types). Thanks in advance.

1

There are 1 answers

0
vivian On BEST ANSWER

No, polymorphic functions are incompatible with Data.Dynamic. To do this would require a polymorphic Data.Typeable and the use of the typechecker at run-time.

There is however, a ticket for this feature: Polymorphic Data.Dynamic