Re:Rust's 2017 roadmap, six months in
by steveklabnik on Wednesday July 05, 2017 @07:48PM
(#14707127)
Well, this code in particular is presented as "hey there's no context." If I were to try to extract this, I would take each of those lets and make them an argument, then see what the compiler says for the return type, done.
[ Parent
| on HN ]
This is one example where having a REPL would help a lot.
That is how I check such types outside IDEs in other ML derived languages.
TBF, you can just do
let _ : () = /* some expr whose type you don't know */
And compile it. It will quickly fail with a type error, giving you the full type of the expression.Yeah, but it feels like a kluge, specially when used to F# on Visual Studio.
How do you find out what the compiler says for the return type? Is that covered in the book somewhere? I feel like this might help me quite a bit in my struggles.
I commonly let the compiler error out by specifying the wrong type or leaving off a type annotation. For instance, https://is.gd/8lLrY8
Re:Rust's 2017 roadmap, six months in
by steveklabnik on Wednesday July 05, 2017 @11:15PM
(#14707922)
one way is to do
return SOME_EXRPRESSION;
and then look at the compiler error. Another way is let () = SOME_EXPRESSION;
which works as long as SOME_EXPRESSION is not of type (), but if it compiles, well, you know the type :)Another way is to use some sort of IDE integration that gives you "show me the type on hover".