Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 是否手动将SCC附加到整个功能?_Haskell_Ghc - Fatal编程技术网

Haskell 是否手动将SCC附加到整个功能?

Haskell 是否手动将SCC附加到整个功能?,haskell,ghc,Haskell,Ghc,是否可以手动将SCC连接到整个功能?例如,如何将SCC附加到下面的f f x = g x where g x = ... 如果我写 f x = {-# SCC f #-} g x y where g = ... y = ... 那么g和y将不包括在SCC中。相反,我似乎不得不写作 f x = {-# SCC f #-} let g = ... y = ... in g x y 但这可能会很烦人,因为它需要将where重写

是否可以手动将SCC连接到整个功能?例如,如何将SCC附加到下面的
f

f x = g x
  where g x = ...
如果我写

f x = {-# SCC f #-} g x y
  where g = ...
        y = ...
那么
g
y
将不包括在SCC中。相反,我似乎不得不写作

f x = {-# SCC f #-}
      let g = ...
          y = ...
      in  g x y

但这可能会很烦人,因为它需要将
where
重写为
let
并保护到
case
语句中。我怎样才能在不进行所有重写的情况下获得相同的效果-fprof auto似乎能够做到这一点。但我只想手动将SCC添加到少量函数中。

在GHC的下一个主要版本(8.2)中,这似乎是可能的,请参阅此票据(它显示了与您相同的解决方法和问题)

根据GHC主分支的声明,您将能够将注释置于与
f
声明相同的级别。像

f x = g x y
  where g = ...
        y = ...
{-# SCC f #-}

f x = g x y
  where g = ...
        y = ...
{-# SCC f "some_cc_name" #-}