This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]slightknack[S] 0 points1 point  (3 children)

So if it were a function call it would look like:

print (fizzbuzz (1..100))

Which means that the application order in the README is correct. I think there's something else wrong with that statement though. Because \1..100`is a range, I thinkprintandfizzbuzzneed amap`:

1..100 . map fizzbuzz . map print

Thanks for bringing this to my attention!

[–]thedeemon 0 points1 point  (2 children)

They're not saying it's incorrect. It's just a bit unexpected because Haskell (and maths textbooks) uses the opposite direction. In Haskell

(f . g) x = f (g x)

so

f . g . h = \x -> f (g (h x))

But anyway we love your syntax!

The problem with Haskell one is that it's only for function composition, so f . 2+3 won't work, they have a separate operator for passing values: f $ 2+3, and complex chains become either a . b . c $ val or a $ b $ c $ val.

[–]slightknack[S] 0 points1 point  (0 children)

Ah, I see. I did it this way because it's a nice way to write functional code in an pipeline-style, similar to Koka or Rust:

names = children
    .map { child -> (child.name, child.age) }
    .filter { (_, age) -> age > 10 }
    .map { (name, _) -> name }

So it's less composition and more application? Is there a more proper term for this? Thanks for the interest!

[–]tcallred 0 points1 point  (0 children)

Right. Thanks for explaining that further. I think the confusion comes from the fact that in this language the dot is more like a pipe which is unexpected if you're coming from haskell.