Recover role of a type variable in source Haskell

Hi devs, Is it possible to programmatically recover the role of a type variable? Or, possibly, a list of the roles of the type variables from left to right? For example, if i have: data Foo a = Foo (1) newtype Bar a b = Bar (a -> b) (1) Getting the role list of (1) would give me [Phantom], and (2) would give me [Representational, Representational]. I know in compiler/types/TyCon.hs that TyCon has a list of Roles in it, but there doesn't seem to be any machinery available to do this in source haskell. Thanks

Hi chessai, It is indeed not possible in source Haskell at the moment. Cheers, Csongor
On 7 Apr 2019, at 17:41, chessai .
wrote: Hi devs,
Is it possible to programmatically recover the role of a type variable?
Or, possibly, a list of the roles of the type variables from left to right?
For example, if i have:
data Foo a = Foo (1) newtype Bar a b = Bar (a -> b) (1)
Getting the role list of (1) would give me [Phantom], and (2) would give me [Representational, Representational].
I know in compiler/types/TyCon.hs that TyCon has a list of Roles in it, but there doesn't seem to be any machinery available to do this in source haskell.
Thanks
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
participants (2)
-
chessai .
-
Csongor Kiss