What's wrong with "func :: String -> [Int]; func = read "[3,5,7]""
You are trying to read your string as a function of type String -> [Int]
, rather than a list [Int]
. However, read
can not convert strings into functions.
Try this instead:
myList :: [Int]
myList = read "[3,5,7]"
Your function type is String -> [Int]
but you didn't specify its argument so the compiler "thinks" that you want to return a function String -> [Int]
instead of [Int]
.
You probably want:
func :: String -> [Int]
func s = read s
and then use it as:
func "[3,5,7]"
or just:
func :: String -> [Int]
func _ = read "[3,5,7]"