top | item 39876821

(no title)

CmdSheppard | 1 year ago

Hard disagree. One of the reasons I fell in love with F# was the succint code one can write, specifically due to the compilers ability to infer types.

discuss

order

aerhardt|1 year ago

Don't you at least type function params and returns?

Also, what do you build in F#? I think if I moved out of Python that would be it. OCaml is one of my favorite languages ever, and F# looks rad.

ryanjshaw|1 year ago

Not OP, but that's exactly what I do - type my public functions fully.

I built a basic static program analyzer for Solidity smart contracts over the past 7 months. I'm re-writing it to work off CozoDB now, as I want to be able to express more complex mutually-recursive concepts and I believe Datalog is much better suited for that.

CmdSheppard|1 year ago

Only public APIs - all of my internal logic I mainly let the compiler figure it out.

ryanjshaw|1 year ago

I have run into situations where piping causes a type inference error but the equivalent function call doesn't, which is annoying because I have to use two different conventions in that case. I'm still an F# noob, so it's possible I'm doing something wrong.

I also get nervous that I'll change my function logic and the wrong type will be inferred, and it'll compile because the old and new types just happen to be logically compatible, but I get the wrong behaviour (or maybe this is just trauma from my VB6 days).

I tend to type my public function parameters and return parameters for this reason.

CmdSheppard|1 year ago

F# is rigid enough IMHO to stop you from making mistakes like this. The rule of thumb is that it compiles it's usually a corect program.