any workarounds to get polymorphic functions in Data.Dynamics?
-
16-04-2021 - |
Domanda
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.
Soluzione
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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow