In the wonderful FBlazorShop
repo, Onur Gumus is riffing off of Steve Sanderson’s Pizza Workshop with F# flavor. On line 128 of blob/master/FBlazorShop.Web.BlazorClient/Home/Home.fs
[GitHub], Onur is passing an Elmish Message
for the parent, HomeView
, inheriting ElmishComponent<Model, Message>
, to a child, PizzaConfigView
, inheriting ElmishComponent<Model, PizzaConfigMsg>
. By convention, we can see Message
being converted (?) to PizzaConfigMsg
with this:
(PizzaConfigMsg >> dispatch)
where dispatch
is of type Message -> unit
. At the time of this writing, I have no idea how this ‘conversion’ is happening (in part because I refuse to compile this repo by going back to .NET core 3.x). I am not familiar with this usage of the >>
operator. Is this operation actually a conversion or is something else going on?
If you find
>>
confusing, but are comfortable with|>
, then you can easily rewrite that line like this:Since the top-level message type is:
This tells us that the code is converting a value of type
PizzaConfigMsg
(which I've calledpizzaMsg
above) to a top-levelMessage
via theMessage.PizzaConfigMsg
union case, then dispatching the result.This style of coding (where function arguments become implicit, rather than explicit) is called "point-free programming". You can find more information about it here.