How to obtain an expression type in a GHC compiler plugin?

Hi all, I'm trying to familiarise myself with writing GHC compiler plugins, but the GHC API is rather overwhelming, hence my question here. During compilation, I'm trying to determine whether a top-level function in my program has a certain type. Initially, if this is the case, I just want to print the function name. For me to do this check, I have to obtain the type for each top-level function. How can I achieve this? I already have a plugin with which I can print the name for a Bind, so I'm mainly interested in knowing how to obtain its type. Cheers, Jurriën

This might be useful: https://github.com/faylang/fay/issues/269
On Fri, Mar 21, 2014 at 11:16 AM, J. Stutterheim
Hi all,
I'm trying to familiarise myself with writing GHC compiler plugins, but the GHC API is rather overwhelming, hence my question here.
During compilation, I'm trying to determine whether a top-level function in my program has a certain type. Initially, if this is the case, I just want to print the function name. For me to do this check, I have to obtain the type for each top-level function. How can I achieve this? I already have a plugin with which I can print the name for a Bind, so I'm mainly interested in knowing how to obtain its type.
Cheers,
Jurriën _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thanks, it contained the hint I needed!
The CoreUtils module contains the exprType :: CoreExpr -> Type function, which is exactly what I was looking for.
On 21 Mar 2014, at 12:15, Adam Bergmark
This might be useful: https://github.com/faylang/fay/issues/269
On Fri, Mar 21, 2014 at 11:16 AM, J. Stutterheim
wrote: Hi all, I'm trying to familiarise myself with writing GHC compiler plugins, but the GHC API is rather overwhelming, hence my question here.
During compilation, I'm trying to determine whether a top-level function in my program has a certain type. Initially, if this is the case, I just want to print the function name. For me to do this check, I have to obtain the type for each top-level function. How can I achieve this? I already have a plugin with which I can print the name for a Bind, so I'm mainly interested in knowing how to obtain its type.
Cheers,
Jurriën _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
Adam Bergmark
-
J. Stutterheim