I have the following sample of code:
{-# LANGUAGE ScopedTypeVariables #-}
main = do
putStrLn "Please input a number a: "
a :: Int <- readLn
print a
putStrLn "Please input a number b: "
b :: Int <- readLn
print b
putStrLn ("a+b+b^2:" ++ (show $ a+b+c))
where c = b^2
For some reason I cannot use variable b
in a where
clause, the error I get is the following:
Main3.hs:13:15: error: Variable not in scope: b
|
13 | where c = b^2
| ^
Any ideas how to make b
available in the where
clause?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…