Skip to content

Instantly share code, notes, and snippets.

@hgiasac
Created January 4, 2019 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgiasac/e77186ae9e0011a650dbaedd8819ca1b to your computer and use it in GitHub Desktop.
Save hgiasac/e77186ae9e0011a650dbaedd8819ca1b to your computer and use it in GitHub Desktop.
fromDynamic :: forall d. Typeable d => Dynamic -> Maybe d
fromDynamic (Dyn (ra :: TypeRep a) (x :: a))
= case eqT ra (typeRep :: TypeRep d) of
Nothing -> Nothing
Just HRefl -> Just x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment