F#Interactive displays the type along with the value.
>1;
value : int = 1
>Some1;
value:intoption=Some1
>printf;
value:(Printf.TextWriterFormat<'a>->'a) =<fun:[email protected]>
Then, is there a way to specify a type and check the declaration of that type?
Simply specifying the type name will display the type of constructor.
>Printf.TextWriterFormat<_>;;;
value: arg00:string->PrintfFormat<'a, System.IO.TextWriter, unit, unit>=
<fun:[email protected]>
>Option<_>;;;
Option<_>;;;
^^^^^^
stdin(7,1): error FS0039: no value or constructor 'Option' defined
Instead, I'd like to see a declaration of the type itself written in a .fsi file.
When you define a type on F#Interactive, you see something similar, so can you apply it to an existing type?
>type Foo=A of int|B with
- member self.Hoge(x) = 1;
type Foo=
| A of int
| B
with
member Hoge:x:'a->int
end
As you can see by typing in F#Interactive when you're curious about the type of function, if you look at the type declaration in the same way, you don't have to open a browser...
f#
I don't know if it's an answer, but if it's an F# project instead of an F# interactive, F12 Go To Definition opens documents in a browser, but if it's an Alt+F12 Peek Definition, it shows the type definition on the editor.
It may be a little different (I think you need to look at the source for definitions),
I think you mean typeof
.
typeof<type>
.
Example: typeof<Option<_>>;;
© 2023 OneMinuteCode. All rights reserved.