简体   繁体   中英

Argument placeholder syntax in Haskell, like _ in Scala?

In Scala I could do this:

lines.filter(_.length < 10) // notice the _ acting as the argument

In Haskell the best I can come up with is:

filter ((< 10) . length) . lines // point-free with `.` :(

So basically in Haskell there is no way to do something like

length _ < 10  // short hand for: \x -> length x < 10

?

Yes, Haskell has no placeholder syntax like Scala.

Usually the problem with such syntax is that it either has some arcane rules or it is not really useful in practice. I'm trying to understand Scala's rules now, but I have a feeling it is on the arcane side (what exactly is "syntactic category Expr"?).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM