문제

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 polymorphic Data.Typeable and the use of the typechecker at run-time.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top