#Lightweight syntax

1 messages · Page 1 of 1 (latest)

boreal shard
#

Hi Guys,

I am a newbie and just started to learn F#. Besides struggling to under functional programming using F#, I am also struggling with F# lightweight syntax.

I noticed that complier will throw errors which is not straight forward to tell me that I am not following the lightweight syntax. This could lead me to spend time to debug something which is not a bug in the code?

May I know how you overcome it? I feel overwhelmed that I have to remember lightweight syntax format as well as to remember how to write F# syntax.

I used to code in Java and I don't remember there is such a thing as lightweight syntax for Java...

May I know how to overcome? Is there an IDE which will auto correct my code into lightweight syntax ?

Thanks

wheat dune
#

Hello @boreal shard ,

now days F# don't really have the heavy syntax at least no one is using it because lightweight is the default.

There is no IDE that I am aware which will convert your code to lighweight syntax but most of the code you will find only use that syntax.

It takes a few days to get used to, but in general you always use the same construct in F# (functions, DUs, Record, active pattern) so it is pretty easy to have some muscle memory coming fast.

My best advice, is to take your time and not frustrate yourself too much because you need to learn new syntax.

You will soon regret having to write so many brackets and semi-colon in others languages.

autumn wasp
#

When I learnt F# the main struggles I had were alignment (white space is significant and you need to adhere to the offside rule) and deciphering the type mismatch errors where the compiler expected a type at one place and received another type instead.

For the alignment issues I think I just got used to it over time. Trying to memorize and apply the offside rule wasn't helpful.

For the type mismatch errors I used the ide to trace a value/variable from it's definition to the point where it's error occurs to see what the expected type started as and what it thinks it should be at the error point. Most of the time I can resolve it via a type annotation.

Also I'm a bit confused by what you mean by lightweight syntax. By default the F# compiler uses the lightweight syntax. The heavy syntax which is more OCaml like is generally not used.