Stream: ideas

Topic: F# pipe and elif syntax


view this post on Zulip Matthias Toepp (Oct 10 2022 at 11:40):

1) I love the way fsharp allows you to add an extra pipe to the first variant as below:

type ShoppingCart =
      | EmptyCart
      | ActiveCart
      | PaidCart

2) elif -- I also like how F# (and Python) permits the use of "elif" instead of "else if". (I would permit elif only in Roc, F# allows both elif and else if)

let result =
    if count >= 200 then 1
    elif count <= 100 then 2
    else 3

3) Less important to me, but for the record, I also like Fsharp's leading pipe in match statements:

let cart value =
      match value with
      | EmptyCart -> ...
      | ActiveCart ->...
      | PaidCart -> ...

...but I would prefer to have nothing where the keyword "with" is shown above as in:

let cart value =
      match value
      | EmptyCart -> ...
      | ActiveCart ->...
      | PaidCart -> ...

4) ...and the use of pipes in F# anonymous function branches are nice as well (arguments appear after the pipe and are matched against):

let printTemp = function
       | DegreesC t -> printfn "%f degC" t
       | DegreesF t -> printfn "%f degF" t

..but I would use 'f' instead of 'function' as in:

let printTemp = f
       | DegreesC t -> printfn "%f degC" t
       | DegreesF t -> printfn "%f degF" t

so that concise anonymous functions could be written as:

map [1,2,3] (f x -> x + 1)

add = f x y -> x + y

view this post on Zulip Notification Bot (Oct 10 2022 at 12:53):

Matthias Toepp has marked this topic as resolved.

view this post on Zulip Notification Bot (Oct 10 2022 at 12:56):

Matthias Toepp has marked this topic as unresolved.

view this post on Zulip Brendan Hansknecht (Oct 10 2022 at 14:02):

#4 is extra interesting to me. I know that there has been mention of wanting to define anonymous functions in pipelines directly with a when block. #4 would enable that in a more general sense.

view this post on Zulip Brendan Hansknecht (Oct 10 2022 at 14:02):

I think #1 and #3 don't really apply to roc unless the core syntax for defining tag unions and writing when expressions changes.


Last updated: Jun 16 2026 at 16:19 UTC