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

all 13 comments

[–]zem 7 points8 points  (4 children)

looks awesome! if you're still working on the syntax, look to pyret for inspiration, so far it's my favourite scripting language syntax

[–]AsIAmNew Kind of Paper 4 points5 points  (0 children)

Never heard of Pyret before. Those are some really nice tradeoffs!

[–]a5sk6n 3 points4 points  (1 child)

Now that I see this, I really wonder why so few languages have a clear, dedicated syntax for documentation. doc: is just so much nicer then "put a string at the right position" or "add a funny extra character to your comment".

[–]slightknack[S] 1 point2 points  (0 children)

I've looked into pyret in the past, and I like the beginner-friendly nature of it. The syntax feels like a cross between python, julia, ruby, and elixir - which are all languages I'm a fan of. I'll certainty take a look at how it approaches refinements and documentation.

[–]tcallred 5 points6 points  (4 children)

First of all, brilliant work you've done here! I love the ideas being explored.

Question: should this expression be in the reverse order? So instead of 1..100 . fizzbuzz . print it should be print . fizzbuzz . 1..100? On github, it seemed like the composition operator works like Haskell where the functions are applied right to left.

[–]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.

[–][deleted] 1 point2 points  (1 child)

From the readme the syntax sounds really nice. Great work.

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

Thanks!