是否有一种方法可以从现有haskell源文件中生成带有内联定义的haskell源文件?具体来说,我有兴趣采取以下措施:
class C a where
foo :: a -> a
instance C Bool where
foo = not
bar :: Bool -> Bool
bar x = foo (foo x)
并删除对类型类的引用以产生此结果:
bar :: Bool -> Bool
bar x = not (not x)
答案 0 :(得分:0)
使用参数-ddump-spec
,GHC将在专门化多态函数后打印Core程序。 Core不太像Haskell。根据您的操作,可能更容易或更难使用。 the GHC manual
如注释中所述,并非每个类型类受约束的函数在编译期间都是专门的。一些字典是在运行时传递的。