Let's say I have a function that does something quite complex and is implemented using subfunctions. To simplify the task, instead of tuples, I would like to use some intermediate structures that are private to implement this function.
I do not want the declaration of these structures to flow outside. So I want something like this:
let someComplexFun p = type SomeRecord = {i:int; x:int; y:int;} type SomeOtherRecord = {...} let innerFunctionA (x:SomeRecord) = ... let innerFunctionB (x:SomeOtherRecord) = ... ...
I tried, but of course, the compiler does not allow me to do this. I looked at the documentation and I canβt see that types should be declared at the module level.
In LISP for example, it seems that all this is completely legal, for example:
(defun foo (when) (declare (type (member :now :later) when)) ; Type declaration is illustrative and in this case optional. (ecase when (:now (something)) (:later (something-else))))
So am I missing something? Is this possible if F # at all?
Komrade P.
source share