fsharp / fslang-suggestions

The place to make suggestions, discuss and vote on F# language and core library features
346 stars 21 forks source link

[: and {: syntax to allow indent-based list/CE scoping #1381

Closed reinux closed 3 months ago

reinux commented 3 months ago

I propose we add syntax to allow indent-based scoping of list expressions and computation expressions, maybe using symbols like [:, seq {:, task {:, [|: etc.:

let view model dispatch =
  Html.html [:
    Html.body [:
      prop.style [:
        style.`foreground-color`.green
        style.`background-color`.yellow
      prop.children [ Html.text "MY EYES!" ]

The existing way of approaching this problem in F# is

let view model dispatch =
  Html.html [
    Html.body [
      prop.style [
        style.`foreground-color`.green
        style.`background-color`.yellow
      prop.children [ Html.text "MY EYES!" ]
    ]
  ]
]

This is a relatively small example, but it's not uncommon to see an explosion of ] ] ] ] not just in view code but also in models of all sorts.

Pros and Cons

The advantages of making this adjustment to F# are

The disadvantages of making this adjustment to F# are ...

Extra information

I've been on a roll lately with ambitious suggestions on various projects, so I acknowledge that this could just be coming from my being in a weird headspace. I promise to take zero offense if the idea is declined outright. Please be ruthless!

Estimated cost (XS, S, M, L, XL, XXL):
L

Affidavit (please submit!)

Please tick these items by placing a cross in the box:

Please tick all that apply:

For Readers

If you would like to see this issue implemented, please click the :+1: emoji on this issue. These counts are used to generally order the suggestions by engagement.

vzarytovskii commented 3 months ago

I don't think we want to pursue it at this point. Are there examples of this feature in other languages?

reinux commented 3 months ago

Yeah, I figured it was kind of a long-shot.

I'm not sure it's in use anywhere else. The closest I can think of is Haskell's do notation.