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/aee1ed25cc8b16d7dc2f00e5b17614d3 to your computer and use it in GitHub Desktop.
Save hgiasac/aee1ed25cc8b16d7dc2f00e5b17614d3 to your computer and use it in GitHub Desktop.
import Data.HashMap.Strict as Map
insert :: Typeable a => a -> TyMap -> TyMap
insert x = Map.insert (SomeTypeRep (typeRep :: TypeRep a)) (toDynamic x)
lookup :: Typeable a => TyMap -> Maybe a
lookup = fromDynamic <=< Map.lookup (SomeTypeRep (typeRep :: TypeRep a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment