Question about "strong" where operators

It’s not 100% clear to me why there are two where operators, but maybe I’m just misunderstanding something.

(f >> (x -> x) >> g) 7
. f = | 7 -> "cat" ++ m
        , m = "?"
      | 4 -> "dog" ++ n
        , n = "!"
      | _ -> "shark"
. g = | "cat" -> "kitten"
      | "dog" -> "puppy"
      |   a   -> "baby " ++ a

In this example, why would it not just also be . n = "!" or

      | (4 -> "dog" ++ n
        , n = "!")

or something along those lines? I think having alt precedence rules / “duplicate” operators might make things more confusing than it’s worth. Imo, it’s a lot easier to read / parse code (as a user) when there are fewer unique parsing rules

Yeah, I’m definitely open to exploring other options here. The comma is pretty quirky, so let me show you all of the other options I’ve exhausted:

1. Whitespace Parsing

If we made the language like Elm/Python, these would be two different statements:

. f = | _ -> "cat" ++ m
        . m = "?"
. f = | _ -> "cat" ++ m
. m = "?"

For some reason, I’m attached to making a language that specifically doesn’t do whitespace parsing. I guess one of my unstated goals of scrapscript is that you should be able to write a junky parser for it in a single weekend, and whitespace alignment makes that much more difficult.

2. No Comma Operator

If we simply throw away the comma operator with no other changes, people could still do this:

. f = | 7 -> ( "cat" ++ m ++ x
        . m = "?"
        . x = "!!" )
      | 4 -> ( "dog" ++ n
        . n = "!" )

This just feels super gross to me, especially when you start stacking multiple cases.

But really, all of this only applies with nested assignment. Maybe we could encourage people to declare everything at the top-level? If you need something in “context”, just use a function?

. f = | 7 -> "cat" ++ m ++ x
      | i -> "dog" ++ n i
. m = "?"
. x = "!!"
. n = i -> text/repeat i "!"

That, in addition to the parenthesis, seems like good options.

I quite like the last example you give, I imagine this would work very nicely in an interactive REPL coding session.

Line by line you declare stuff: first you declare f with some placeholders, and when finished there’s a list of unbounded variables to assign, so you then assign m, x and n.

The reason for the operator finally clicked, but with exhaustive pattern matching, would nested assignment actually need its own operator to be parseable? (Not that it’s the only factor)

Would the strong where operator run into the same issue if you wanted another level of nesting?

The top level idea is nice, in practice it works pretty well (writing Svelte reactive stuff is usually similar to that ime), but depending on the size of the scraps, I would guess scoping / “context” would at least sometimes make things more coherent / readable

Yeah, I think I’m convinced.

I want to do a few ergonomics tests to confirm, but I think we can do without the commas.

I’d love to hear other feedback to see if I’m missing anything though.

There are definitely cases of ambiguity that might arise without whitespace parsing.

Yep! But I thought two levels of nesting was sufficient haha