Is it possible to force F# to behave like a pure functional language like Haskell? Maybe using some compiler directives?
PS: since I come from a C/C++ background, I want to force myself to learn functional programming without learning Haskell :)
You can't force this behavior in F#, but as Brian said discipline is your best friend. E.g. don't use mutable
, for
or while
loops, ref
keywords, etc. Also stick with purely immutable data structures (discriminated union, list, tuple, map, etc). If you need to do IO at some point, architect your program so that they are separated from your purely functional code.
Don't forget functional programming is all about limiting and isolating side-effects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With