jeudi 28 février 2019

How to apply a dynamic polymorphic function to a dynamic value?

I would like to create a dynamic value out of the Just function to be able to apply it to toDyn (1 :: Int).

My first difficulty is that I need to have a Typeable function. However this doesn't work:

createMaybe :: (Typeable a) => a -> Maybe a
createMaybe = Just

toDyn createMaybe

This fails to compile with No instance for (Typeable a0) arising from a use of ‘toDyn’

Is there a way to work around that?





Aucun commentaire:

Enregistrer un commentaire