对 GHC 扩展进行分类

发布于 2024-09-06 22:26:06 字数 136 浏览 1 评论 0原文

我想知道 GHC 的扩展是否可以基本上分为两个不同的类别,

  • 一类提供“语法糖”或便利
  • ,另一类引入新的东西,例如新的范例。

现在假设可以将现有扩展分为上述类别,哪个扩展适合哪个类别?

I was wondering if GHC's extensions can be divided into basically two different categories

  • those that provide "syntactic suggar" or convenience
  • and those that introduce something new, a new paradigm for instance.

Now provided one could divide the existing extensions into the above categories which extension would fit into which category?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

も让我眼熟你 2024-09-13 22:26:06

我认为更合适的分类是按编译器管道将其划分:

语法扩展

  • -XMagicHash
  • -XUnicodeSyntax
  • -XNewQualifiedOperators
  • -XViewPatterns
  • -XNPlusKPatterns
  • -XDoRec
  • -XTransformListComp
  • -XNoImplicitPrelude
  • -XPostfixOperators
  • -XTupleSections
  • -XDisambiguateRecordFields
  • -XNamedFieldPuns
  • -XRecordWildCards
  • -XPackageImports
  • -XExplicitForAll
  • -XKindSignatures
  • ...

类型系统扩展

  • -XUnboxedTuples
  • -XLiberalTypeSynonyms
  • -XGADTs
  • -XMultiParamTypeClasses
  • -XFlexibleContexts
  • -XConstrainedClassMethods
  • -XOverlappingInstances 和 -XIncoherentInstances
  • -XTypeFamilies
  • -XImplicitParams

跨领域延伸< /strong>

  • -XTemplateHaskell
  • -XForeignFunctionInterface

优化

  • -fenable-rewrite-rules
  • -fspec-constr
  • -O2

代码生成扩展

  • -fllvm
  • -fasm
  • -fvia-C

运行时扩展

  • -threaded

你觉得怎么样?并非每个标志都可以 (a) 根据现有结构定义,或 (b) 编译器的新部分。这是更微妙的。

还有很多其他的扩展,看看你是否可以按照这种形式对它们进行分类。

I think a more appropriate categorization would be to divide it up by the compiler pipeline:

Syntactic extensions

  • -XMagicHash
  • -XUnicodeSyntax
  • -XNewQualifiedOperators
  • -XViewPatterns
  • -XNPlusKPatterns
  • -XDoRec
  • -XTransformListComp
  • -XNoImplicitPrelude
  • -XPostfixOperators
  • -XTupleSections
  • -XDisambiguateRecordFields
  • -XNamedFieldPuns
  • -XRecordWildCards
  • -XPackageImports
  • -XExplicitForAll
  • -XKindSignatures
  • ...

Type System Extensions

  • -XUnboxedTuples
  • -XLiberalTypeSynonyms
  • -XGADTs
  • -XMultiParamTypeClasses
  • -XFlexibleContexts
  • -XConstrainedClassMethods
  • -XOverlappingInstances and -XIncoherentInstances
  • -XTypeFamilies
  • -XImplicitParams

Cross-cutting extensions

  • -XTemplateHaskell
  • -XForeignFunctionInterface

Optimizatsions

  • -fenable-rewrite-rules
  • -fspec-constr
  • -O2

Code Generation Extensions

  • -fllvm
  • -fasm
  • -fvia-C

Runtime Extensions

  • -threaded

What do you think? Not every flag is either (a) definable in terms of existing constructions, or (b) a new part of the compiler. It's more subtle.

There are many other extensions too, see if you can classify them in this form.

一抹苦笑 2024-09-13 22:26:06

The flags are already categorized in the flag reference in the GHC's users guide, and the language extensions are broken down into various categories in the section on language features.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文