Pattern synonym that provides `Typeable` constraint

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Pattern synonym that provides `Typeable` constraint

Baldur Blöndal

This is a pattern synonym to construct but more importantly to deconstruct an explicit `TypeRep a` into a `Typeable a` constraint

> asTypeable :: TypeRep a -> Dict (Typeable a) 
> asTypeable rep = 
>   withTypeable rep 
>     Dict 
>
> pattern Typeable :: () => Typeable a => TypeRep a
> pattern Typeable <- (asTypeable -> Dict)
>   where Typeable = typeRep

Similar discussion for SingI [1], same benefits:
+ (Nice) direct alternative to CPS `withTypeable`
+ Reusable in other pattern synonyms


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries