Я хочу написать код, который будет выводиться:
length [1,2,3] => 3
В Ruby я мог бы сделать это как:
puts "length [1,2,3] => #{[1,2,3].length}"
После попытки Haskell не удалось выполнить...
Prelude Data.List> print "length [1,2,3]"
"length [1,2,3]"
Prelude Data.List> print (length [1,2,3])
3
Prelude Data.List> print "length [1,2,3]" (length [1,2,3])
<interactive>:1:0:
Couldn't match expected type `Int -> t'
against inferred type `IO ()'
In the expression: print "length [1,2,3]" (length [1, 2, 3])
In the definition of `it':
it = print "length [1,2,3]" (length [1, 2, 3])
Prelude Data.List>