How can I write this pattern synonym without ambiguous type errors?
问题 Using ViewPatterns and Data.Typeable , I’ve managed to write a function that allows me to write something resembling case analysis on types. Observe: {-# LANGUAGE GADTs, PatternSynonyms, RankNTypes, ScopedTypeVariables , TypeApplications, TypeOperators, ViewPatterns #-} import Data.Typeable viewEqT :: forall b a. (Typeable a, Typeable b) => a -> Maybe ((a :~: b), b) viewEqT x = case eqT @a @b of Just Refl -> Just (Refl, x) Nothing -> Nothing evilId :: Typeable a => a -> a evilId (viewEqT @Int