I have an extremely simple Main.hs
that works fine as a compiled program:
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"
When I try to debug it with:
$ ghci Main.hs
:set args 55 26667
break main
I get the following error:
<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>
What am I doing wrong?
GHCi commands start with a :
to distinguish them from Haskell expressions. break
is the name of a Haskell function to split a list on a given condition. To use GHCi breakpoints, use :break
instead.