Does Haskell's WHNF reduction decrease at compile time?

The AFAIU object file generated Haskell compilermust be machine code. Thus, this object file has a representation of the source ASTand reduces it at runtime, or this reduction occurs at compile time, and only the final values ​​are WHNFconverted to the corresponding machine code.

I understand that the compilation time of the latter would be a function of the time complexity of the program itself, which, in my opinion, is less likely.

Can someone give a clear explanation of what happens at runtime and what happens at compile time in the case Haskell (GHC)?

+4
source share
1 answer

, . () , AST, () / WHNF, AST.

, . . Python , AST . , ( , ).

.

, . , . (, ), . , Haskell, :

. , , WHNF.

Haskell GHC , STG. , , // ..

, . , , , ( ) ( ). - C ++, , .

( Haskell, C, ++ - ) . , , , .

, WHNF . , , -, , , . , ! .

let x = complex computation in x + x
-- vs
complex computation + complex computation

, ! , , x .

+6

Source: https://habr.com/ru/post/1689811/


All Articles