Re:Realizing Hackett, a metaprogrammable Haskell
by julian_1 on Sunday May 28, 2017 @07:04PM
(#14436478)
Could you explain what phase is? I understand haskell types, and I suspect Template haskell mostly works as an AST translator. A Google search on macros and phase, just turns up diet and bodybuilding preparation advice!
[ Parent
| on HN ]
Re:Realizing Hackett, a metaprogrammable Haskell
by dbpatterson on Sunday May 28, 2017 @07:23PM
(#14436527)
In the simplest case, a macro system gives rise to two-phase evaluation - first, there is code that runs at macro expansion time, that produces, as its result, new syntax, and second, that resulting code runs. But having just two phases is (needlessly) restrictive, because you might want macros that generate other macros (and so the macro-generating macros would need to run at an earlier phase than the generated ones).
Re:Realizing Hackett, a metaprogrammable Haskell
by chongli on Sunday May 28, 2017 @09:18PM
(#14436884)
Wouldn't the macro-expansion phase be run until it reaches a fixed point? That way all macros could be fully expanded before proceeding to the next phase.
Re:Realizing Hackett, a metaprogrammable Haskell
by wtetzner on Monday May 29, 2017 @10:54AM
(#14439386)
I believe that's how macros in Racket work, but each iteration is considered a separate phase. At least, that's how I understood it.
This page has some useful information about phases: https://docs.racket-lang.org/guide/phases.html