How to organize my functions?

I’m new to F# and functional programming in general. I’ve been doing O-O for many years and I have an instinctive feeling for how to organize my code. With F#, I’m not so sure. I feel like I’m just littering my files with a bunch of functions, organized only such that all the references work out. I’ve done some organizing of functions in to namespaces and modules, but I haven’t developed a good feel for the best way to organize, or even when to organize. Can anyone offer any tips on dealing with code organization? When to use namespaces, modules within namespaces, etc.? Are there some good guidelines?

Thanks!

Firstly, you should remember that F# requires files (and code within a file) to be in dependency order.
And a simple tip that I always do:

namespace A
type B
module B =
// functions with type B

Also there is a post about it on F# for fun and profit

2 Likes

Thanks for the information and the pointer to the blog post on F# for fun and profit. There is so much good information on that site and I must have overlooked this particular post.