
pl a b = a ++ b pl a = a ++ The second definition cannot be accept by neigher ghci nor ghc. What's the problem? (ghc 6.12.3) -- ---------------- WU XingBo

To use an operator as a function you must use the section notation:
pl a = (a ++)
On 10 December 2010 12:59, 吴兴博
pl a b = a ++ b
pl a = a ++
The second definition cannot be accept by neigher ghci nor ghc. What's the problem?
(ghc 6.12.3)
-- ---------------- WU XingBo
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Fri, Dec 10, 2010 at 1:05 PM, Tobias Brandt
To use an operator as a function you must use the section notation:
pl a = (a ++)
Note that the section notation is slightly more flexible than the above since you can also do :
pl b = (++ b)
So that's not currying per se since operators are not syntactically handled like functions. Of course behind the scene operators are only functions, to use them strictly as normal functions Haskell provide the following syntax :
pl a b = (++) a b
So your first try could be written :
pl a = (++) a
Just like with an ordinary function. The second section notation variant (++ b) is perfectly equivalent to the following :
pl b = flip (++) b
-- Jedaï
participants (3)
-
Chaddaï Fouché
-
Tobias Brandt
-
吴兴博