KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Let's say I have a function which does something pretty complicated and it is implemented with the help of subfunctions. To make things easier, instead of tuples I would like to use some intermediate structures which are private to the implementation of this function. I don't want the declaration of these structures to leak 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 it but of course the compiler doesn't let me do this. I looked at the documentation and I can't see anywhere quickly that the types must be declared at the module level. In LISP for example, it seems that it's all entirely legal, e.g.: (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?
Tags (comma-separated)
Save Edits
Cancel