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.
No, polymorphic functions are incompatible with
Data.Dynamic
. To do this would require a polymorphicData.Typeable
and the use of the typechecker at run-time.There is however, a ticket for this feature: Polymorphic Data.Dynamic