5 ms·
That's because your code assumes those convenience functions exist while the parent's code writes out the anonymous functions. The direct translation of yours'
by Scriptor 10y ago
That's because your code assumes those convenience functions exist while the parent's code writes out the anonymous functions.
The direct translation of yours' to Clojure would be:
(filter valid-person? (map init-person names))
Meanwhile, the direct Haskell translation of the parent comment is:
filter (\p -> isValid p) (map (\n -> Person n) names)
- deleted 10y ago[deleted]
- wyager 10y agoHuh? No, anyone who writes it in Haskell would not use those lambda abstractions. You would just use "filter isValid (map Person names)".
- Scriptor 10y agoI'm assuming Person is a record constructor, is isValid here a field in that record or another function?
- prodigal_erik 10y agoHaskell doesn't distinguish the two. If you define Person with named fields including isValid, you automatically get a function named isValid that returns that field, or you can write your own isValid function that examines the whole Person.
- aninhumer 10y agoNo one would ever write the latter, because (\p -> isValid p) is equivalent to isValid. However you're right that the function names would probably be a little longer in practice, and I've edited my example to reflect that. (But they're not convenience functions, they just have longer names due to Haskell's more limited namespacing)
- junke 10y agoNot a Haskell expert, but maybe monomorphism restriction can require you to perform an eta abstraction. Just saying.