Re: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]
Matthijs Kooijman wrote: I've been working on parsing core in the past few months. For an example, look here: http://git.stderr.nl/gitweb?p=matthijs/projects/fhdl.git;a=blob;f=Translator.hs;h=8072f85925ad1238 The loadModule and findBind functions are interesting. As for iterating the AST, have a look at Flatten.hs. Thanks, Matthijs! This helps a lot and looks very promising! Only to avoid misunderstandings, you only use the ghc-api to get the AST of a CoreModule which you translate into your own data structure (VHDL). At this point, you don't use type information, right? Martin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]
Hi Martin, Only to avoid misunderstandings, you only use the ghc-api to get the AST of a CoreModule which you translate into your own data structure (VHDL). That's correct. At this point, you don't use type information, right? I use some typing information, but that's mostly hidden away. In particular, when creating Signals using genSignalId I annotate them with the type of the expression the signal models. Later on, I translate this type to a VHDL type. To get at the type of an expression, I use the CoreUtils.exprType function, which gives you the type of any CoreExpr. Gr. Matthijs signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]
Okay, many thanks. That's exactly I need (I hope :-) ). Cheers, Martin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]
Brandon S. Allbery KF8NH wrote: I'm pretty sure you can pull a typed AST out of ghc-api and query the type of any node. Thanks. I am relieved to hear that. Could anybody tell me, where to start in the ghc-api? It's pretty hard, when you don't know where to look. Hoogle doesn't know anything about it. I found following DT describing the core language, but as far as I see, there are no type in there either. http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/CoreSyn.html#t %3AExpr Thanks a lot, Martin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]
Hi Martin, Could anybody tell me, where to start in the ghc-api? It's pretty hard, when you don't know where to look. Hoogle doesn't know anything about it. I found following DT describing the core language, but as far as I see, there are no type in there either. I've been working on parsing core in the past few months. For an example, look here: http://git.stderr.nl/gitweb?p=matthijs/projects/fhdl.git;a=blob;f=Translator.hs;h=8072f85925ad1238 The loadModule and findBind functions are interesting. As for iterating the AST, have a look at Flatten.hs. Good luck, any questions are welcome! Gr. Matthijs signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe