New answers tagged

1

It seems to work well with the provided test cases. The obvious objection when talking about functional programming in F# is to the use of mutable variables and loops. Instead it is common to use higher order functions and recursion. For inspiration, below is toBigInt in a more functional style: let toBigInt (bytes: byte[]) = if bytes.Length = 0 then ...


3

I think, I would change AccountState to the following: type AccountStatus = | Uninitialized | Opened | Closed In this way you have the full life cycle of an account and you then can avoid Some/None for the account status The AccountState could then be changed to: type AccountState = { Id: Guid Status: AccountStatus ...


1

let private WaitForData (client : TcpClient, dataLength : int) : Async<bool>= let mutable loopBreaker : bool = true let isConnectionAlive : bool = IsConnectionEstablished client && client <> null You should only use explicit type declaration when the compiler demands it: let private WaitForData (client : TcpClient) ...


5

The first thing is when you use parenthesis it means that you pass a tuple to a function instead of single parameters. So you can ditch them. The second thing is that bool supports pattern matching The third thing is that you can use recursion instead of mutable variables. Note the usage of rec which enables tail call optimisation. The code would look ...


Top 50 recent answers are included