[英]inlining functions within haskell source code
有没有一种方法可以从现有的haskell源文件中生成带有内联定义的haskell源文件? 具体来说,我有兴趣采取以下措施:
class C a where
foo :: a -> a
instance C Bool where
foo = not
bar :: Bool -> Bool
bar x = foo (foo x)
并删除对typeclass的引用以产生此结果:
bar :: Bool -> Bool
bar x = not (not x)
使用-ddump-spec
,GHC将在专门化多态函数后打印Core程序。 Core不太像Haskell。 根据您的操作,可能更容易或更难使用。 此和相关选项记录在GHC手册中
如注释中所述,并非每个类型类的受约束函数在编译期间都是专门的。 一些字典在运行时传递。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.