Skip to content

Instantly share code, notes, and snippets.

@randomshinichi
Created April 4, 2020 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randomshinichi/6bcc08a077b4758dad98d81ae010c3fb to your computer and use it in GitHub Desktop.
Save randomshinichi/6bcc08a077b4758dad98d81ae010c3fb to your computer and use it in GitHub Desktop.
problematic Haskell code
inputToNum :: String -> Num
inputToNum msg = do
putStr msg
i <- getLine
let o = read i :: Int
return o
nameDo :: IO ()
nameDo = do
base <- inputToNum "The base? "
height <- inputToNum "The height? "
let area = base * height
putStrLn ("The area of that triangle is " ++ show area )
shinichi@asuka:~/source/hangman ghc hello.hs
[1 of 1] Compiling Main ( hello.hs, hello.o )
hello.hs:1:25: error:
• Expecting one more argument to ‘Num’
Expected a type, but ‘Num’ has kind ‘* -> Constraint’
• In the type signature: inputToNum :: String -> Num
|
1 | inputToNum :: String -> Num
| ^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment