Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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 增加「;宽度“;ghci公司_Haskell_Ghci - Fatal编程技术网

Haskell 增加「;宽度“;ghci公司

Haskell 增加「;宽度“;ghci公司,haskell,ghci,Haskell,Ghci,当GHCI中的输出线过长时,会断开: > :i bar bar :: Lens' (Foo a0) Int -- Defined at NewType_makeLenses.hs:7:1 > :i baz baz :: Lens (Foo a0) (Foo a1) a0 a1 -- Defined at NewType_makeLenses.hs:7:1 有没有办法设置线条的最大长度?有三个选项可以控制 您正在寻找-dppr cols。其默认值为100。您可以在调用GH

当GHCI中的输出线过长时,会断开:

> :i bar
bar :: Lens' (Foo a0) Int   -- Defined at NewType_makeLenses.hs:7:1
> :i baz
baz :: Lens (Foo a0) (Foo a1) a0 a1
    -- Defined at NewType_makeLenses.hs:7:1

有没有办法设置线条的最大长度?

有三个选项可以控制

您正在寻找
-dppr cols
。其默认值为
100
。您可以在调用GHCi或使用
:set
时将其设置为任何其他值

方案比较 不带
-dppr cols
使用
-dppr-cols140
:设置-dppr-cols140
奖金:我是怎么找到这个的? 我没有查看标志,而是查看了GHC的源代码:

$ git clone --depth=1 https://github.com/ghc/ghc.git && cd ghc
接下来,我查找以定义的
开头的字符串:

$ grep -C2 "\"Defined" -r . --exclude-dir=testsuite
./compiler/basicTypes/Name.hs-ppr_z_occ_name occ = ztext (zEncodeFS (occNameFS occ))
./compiler/basicTypes/Name.hs-
./compiler/basicTypes/Name.hs:-- Prints (if mod information is available) "Defined at <loc>" or
./compiler/basicTypes/Name.hs:--  "Defined in <mod>" information for a Name.
./compiler/basicTypes/Name.hs-pprDefinedAt :: Name -> SDoc
./compiler/basicTypes/Name.hs:pprDefinedAt name = text "Defined" <+> pprNameDefnLoc name
./compiler/basicTypes/Name.hs-
./compiler/basicTypes/Name.hs-pprNameDefnLoc :: Name -> SDoc
Outputable.hs
包括
printForUser
,它与
Pretty
中的
printDoc
一起使用
pprcoldflags
,定义为

printDoc :: Mode -> Int -> Handle -> Doc -> IO ()
-- printDoc adds a newline to the end
printDoc mode cols hdl doc = printDoc_ mode cols hdl (doc $$ text "")

pprCol
是在
compiler/main/DynFlags.hs
中定义的,它对应于
-dppr cols
。您只需通过GHC:
grep
即可。

谢谢。我的工具中包含了这个选项:)
$ ghci NewType_makeLenses.hs
[1 of 1] Compiling Main             ( NewType_makeLenses.hs, interpreted )
Ok, modules loaded: Main.
> :set -dppr-cols140
> :i bar
bar :: Lens' (Foo a0) Int       -- Defined at NewType_makeLenses.hs:9:1
> :i baz
baz :: Lens (Foo a0) (Foo a1) a0 a1     -- Defined at NewType_makeLenses.hs:10:1
$ git clone --depth=1 https://github.com/ghc/ghc.git && cd ghc
$ grep -C2 "\"Defined" -r . --exclude-dir=testsuite
./compiler/basicTypes/Name.hs-ppr_z_occ_name occ = ztext (zEncodeFS (occNameFS occ))
./compiler/basicTypes/Name.hs-
./compiler/basicTypes/Name.hs:-- Prints (if mod information is available) "Defined at <loc>" or
./compiler/basicTypes/Name.hs:--  "Defined in <mod>" information for a Name.
./compiler/basicTypes/Name.hs-pprDefinedAt :: Name -> SDoc
./compiler/basicTypes/Name.hs:pprDefinedAt name = text "Defined" <+> pprNameDefnLoc name
./compiler/basicTypes/Name.hs-
./compiler/basicTypes/Name.hs-pprNameDefnLoc :: Name -> SDoc
$ grep "data SDoc" -r . --exclude-dir=testsuite
./compiler/utils/Outputable.hs:data SDocContext = SDC
./compiler/utils/Outputable.hs-boot:data SDoc
printDoc :: Mode -> Int -> Handle -> Doc -> IO ()
-- printDoc adds a newline to the end
printDoc mode cols hdl doc = printDoc_ mode cols hdl (doc $$ text "")