这意味着转换为具体的Haskell是什么意思?

问题描述 投票:-1回答:1

我试图从页面https://ocharles.org.uk/guest-posts/2014-12-22-template-haskell.html了解模板haskell。

我们将采用这个例子:

runQ [| 1 + 2 |]
InfixE (Just (LitE (IntegerL 1))) (VarE GHC.Num.+) (Just (LitE (IntegerL 2)))   

如您所见,表达式被评估为AST。与

$( return (InfixE (Just (LitE (IntegerL 1))) (VarE (mkName "+")) (Just (LitE (IntegerL 2)))))
3

它评估AST,对吗?

问题是,在编译之前,Haskell中的每个表达式都会转换为AST吗?

作者在文章中提到:

Ta da, you converted concrete Haskell to AST and then evaluated it.  

与代码有关:

$( return (InfixE (Just (LitE (IntegerL 1))) (VarE (mkName "+")) (Just (LitE (IntegerL 2)))))
3 

作者对具体的Haskell意味着什么?

haskell
1个回答
2
投票

问题是,在编译之前,Haskell中的每个表达式都会转换为AST吗?

转换为某种形式的AST或其他形式通常是编译的一部分,是的。

作者对具体的Haskell意味着什么?

具体部分是指1 + 2,而不是AST。

© www.soinside.com 2019 - 2024. All rights reserved.