ghci无法设置断点

问题描述 投票:0回答:1

我有一个非常简单的Main.hs,可以很好地用作已编译程序:

module Main( main ) where
import System.Environment ( getArgs )

atoi :: String -> Int
atoi s = read s :: Int

main :: IO ()
main = do

(x:y:_) <- getArgs

case compare (atoi x) (atoi y) of
  LT -> putStrLn "x < y"
  GT -> putStrLn "x > y"
  EQ -> putStrLn "x = y"

当我尝试使用以下命令进行调试时:

$ ghci Main.hs
:set args 55 26667
break main

我收到以下错误:

<interactive>:2:7: error:
    • Couldn't match expected type ‘a -> Bool’ with actual type ‘IO ()’
    • In the first argument of ‘break’, namely ‘main’
      In the expression: break main
      In an equation for ‘it’: it = break main
    • Relevant bindings include
        it :: [a] -> ([a], [a]) (bound at <interactive>:2:1)
*Main> 

我在做什么错?

haskell breakpoints ghci
1个回答
0
投票

break是Haskell函数的名称,用于在给定条件下拆分列表。要使用GHCi断点,请改用break

© www.soinside.com 2019 - 2024. All rights reserved.