The functions catstr and catstr' defined in Haskell are equivalent, but the Scala code defines two functions (named the same, catstr?) that are not equivalent, despite what the text says. The proposed changes are about code snippets 3, 4, and 5. The first Scala definition should perhaps become
val catstr(s: String)(s1: String): String = s ++ s1
The second definition could become
val catstr2(s: String): String => String = s1 => s + s1
The third snippet is then
val greet: String => String = catstr("hello")
and then indeed the definition of greet can use either catstr or catstr2 interchangeably, just like in the Haskell code.
The functions
catstr
andcatstr'
defined in Haskell are equivalent, but the Scala code defines two functions (named the same,catstr
?) that are not equivalent, despite what the text says. The proposed changes are about code snippets 3, 4, and 5. The first Scala definition should perhaps becomeThe second definition could become
The third snippet is then
and then indeed the definition of
greet
can use eithercatstr
orcatstr2
interchangeably, just like in the Haskell code.