【问题标题】:Show type of each result in GHCi在 GHCi 中显示每个结果的类型
【发布时间】:2017-09-10 15:10:15
【问题描述】:

如何在每个命令后在 GHCi 中显示结果表达式的类型? 例如,而不是

ghci> "hello" ++ " world"
"hello world"

我想看看

ghci> "hello" ++ " world"
"hello world" :: String

至少

ghci> "hello" ++ " world"
"hello world" :: [Char]

其他语言的 REPL 默认提供这种行为。但我找不到proper ghci option 的这种行为。我也可以在执行每个命令后打印it 的类型。但是我没有找到如何在每个 ghci 命令之后调用我的命令的方法。好吧,明智的命令:let ... = ... 没有结果(尽管打印定义变量的类型会很好)。 那么每个命令后自动显示结果类型的方法是什么?

【问题讨论】:

    标签: haskell types ghci


    【解决方案1】:

    :set +t 添加到.ghci

    来自documentation

    +t
        Display the type of each variable bound after a statement is entered at the prompt.
        If the statement is a single expression, then the only variable binding will be for
        the variable ‘it’.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-18
      • 1970-01-01
      • 2022-01-20
      • 2017-04-30
      • 2016-12-05
      相关资源
      最近更新 更多