Skip to main content
added 85 characters in body
Source Link

What is wrong with the following code? I just wanted to connvert an input intoin the following format in a listfile: n - count of test cases // n numbers integersn1 n2 (read via stdin) into list of strings.integers and display it?

socks :: Int -> Int
socks x = x + 1
strToInt = read :: String -> Int
strLToIntL :: [String] -> [Int]
strLToIntL xs = map (strToInt) xs
main = do
    n <- readLn :: IO Int
    mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'

What is wrong with the following code? I just wanted to connvert an input into a list of integers into list of strings.

socks :: Int -> Int
socks x = x + 1
strToInt = read :: String -> Int
strLToIntL :: [String] -> [Int]
strLToIntL xs = map (strToInt) xs
main = do
    n <- readLn :: IO Int
    mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'

What is wrong with the following code? I just wanted to connvert input in the following format in a file: n - count of test cases // n numbers n1 n2 (read via stdin) into list of integers and display it?

socks :: Int -> Int
socks x = x + 1
strToInt = read :: String -> Int
strLToIntL :: [String] -> [Int]
strLToIntL xs = map (strToInt) xs
main = do
    n <- readLn :: IO Int
    mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'
For more understanding
Source Link
Farid Nouri Neshat
  • 30.5k
  • 6
  • 80
  • 128

What is wrong with the following code? I just wanted to connvert an input into a list of integers into list of strings.

socks :: Int -> Int<br>Int
socks x = x + 1<br>1
strToInt = read :: String -> Int<br>Int
strLToIntL :: [String] -> [Int]<br>[Int]
strLToIntL xs = map (strToInt) xs<br>xs
main = do<br>do
    n <- readLn :: IO Int<br>Int
    mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents<br>getContents

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'

What is wrong with the following code? I just wanted to connvert an input into a list of integers into list of strings.

socks :: Int -> Int<br>
socks x = x + 1<br>
strToInt = read :: String -> Int<br>
strLToIntL :: [String] -> [Int]<br>
strLToIntL xs = map (strToInt) xs<br>
main = do<br>
  n <- readLn :: IO Int<br>
  mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents<br>

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'

What is wrong with the following code? I just wanted to connvert an input into a list of integers into list of strings.

socks :: Int -> Int
socks x = x + 1
strToInt = read :: String -> Int
strLToIntL :: [String] -> [Int]
strLToIntL xs = map (strToInt) xs
main = do
    n <- readLn :: IO Int
    mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'
removed extraneous nbsp from editors update
Source Link
Adam Wenger
  • 17.7k
  • 8
  • 54
  • 65

What is wrong with the following code? I just wanted to connvert an input into a list of integers into list of strings.

socks :: Int -> Int<br>
socks x = x + 1<br>
strToInt = read :: String -> Int<br>
strLToIntL :: [String] -> [Int]<br>
strLToIntL xs = map (strToInt) xs<br>
main = do<br>
&nbsp;&nbsp;  n <- readLn :: IO Int<br>
&nbsp;&nbsp;  mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents<br>

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'

What is wrong with the following code? I just wanted to connvert an input into a list of integers into list of strings.

socks :: Int -> Int<br>
socks x = x + 1<br>
strToInt = read :: String -> Int<br>
strLToIntL :: [String] -> [Int]<br>
strLToIntL xs = map (strToInt) xs<br>
main = do<br>
&nbsp;&nbsp;  n <- readLn :: IO Int<br>
&nbsp;&nbsp;  mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents<br>

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'

What is wrong with the following code? I just wanted to connvert an input into a list of integers into list of strings.

socks :: Int -> Int<br>
socks x = x + 1<br>
strToInt = read :: String -> Int<br>
strLToIntL :: [String] -> [Int]<br>
strLToIntL xs = map (strToInt) xs<br>
main = do<br>
  n <- readLn :: IO Int<br>
  mapM_ putStrLn $ map show $ strLToIntL $ fmap (take n . lines) getContents<br>

I am getting the compile error when i run it:

Couldn't match expected type `Char' with actual type `[Char]'
Expected type: String -> [Char]
  Actual type: String -> [String]
In the second argument of `(.)', namely `lines'
In the first argument of `fmap', namely `(take n . lines)'
Source Link
Loading