<div dir="ltr"><div dir="auto"><div dir="auto"><a href="https://github.com/ghc/ghc/blob/4bb54a4522d44a81b2c47233f48252bd73c38279/testsuite/tests/polykinds/T14270.hs" target="_blank">https://github.com/ghc/ghc/blo<wbr>b/4bb54a4522d44a81b2c47233f482<wbr>52bd73c38279/testsuite/tests/p<wbr>olykinds/T14270.hs</a></div><div dir="auto"><a href="https://github.com/sweirich/dth/blob/2bb0c9aa9adb514b787ea56295419fae55dc3734/examples/dynamic/DataDynamic.hs" target="_blank">https://github.com/sweirich/dt<wbr>h/blob/2bb0c9aa9adb514b787ea56<wbr>295419fae55dc3734/examples/dyn<wbr>amic/DataDynamic.hs</a><br></div><div dir="auto"><br></div><div dir="auto">This is a pattern synonym to construct but more importantly to deconstruct an explicit `TypeRep a` into a `Typeable a` constraint</div><div dir="auto"><br></div><div dir="auto">> asTypeable :: TypeRep a -> Dict (Typeable a) </div><div dir="auto">> asTypeable rep = </div><div dir="auto">> withTypeable rep </div><div dir="auto">> Dict </div><div dir="auto">><br></div><div dir="auto">> pattern Typeable :: () => Typeable a => TypeRep a</div><div dir="auto">> pattern Typeable <- (asTypeable -> Dict)</div><div dir="auto">> where Typeable = typeRep</div><div dir="auto"><br></div><div dir="auto">Similar discussion for SingI [1], same benefits:</div><div dir="auto">+ (Nice) direct alternative to CPS `withTypeable`</div><div dir="auto">+ Reusable in other pattern synonyms</div><div dir="auto"><br></div><div dir="auto">[1] <a href="https://github.com/goldfirere/singletons/issues/273" target="_blank">https://github.com/goldfir<wbr>ere/singletons/issues/273</a></div></div>
</div>