Support type inference for fold, method and array
See original GitHub issueexample: fold
let a = vec![1, 2, 3];
// the sum of all of the elements of a
let sum = a.iter().fold(0, |acc/*: {int} (should be)*/, &x| acc + x);
assert_eq!(sum, 6);
example: method
let a = vec!["1", "2", "4"];
// the sum of all of the elements of a
let as_strings = a.iter().map(ToString::to_string);
//^ Map<Iter<&str>, ToString::to_string> (should be)
example: array
let a = ["1", "2", "4"];
// the sum of all of the elements of a
let iter = a.iter();
//^ Iter<&str> (should be)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
A type inference pattern · Issue #91 · gcanti/fp-ts - GitHub
The current implementation of foldMap has some type inference issues. import * as option from 'fp-ts/lib/Option' import * as array from ...
Read more >Type Inference by Example, Part 7 | by Joakim Ahnfelt-Rønne
The first thing we need to do is to create an environment recursiveEnvironment that's only for checking the mutually recursive functions. In ...
Read more >Generic type inference in function from lists - dart
This is basically Dart List.fold vs List.reduce type inference, but in your case you could sidestep the problem by making your function an ......
Read more >Documentation - Type Inference - TypeScript
This kind of inference takes place when initializing variables and members, setting parameter default values, and determining function return types.
Read more >Type inference - Swift by Sundell
An introduction to Swift's type inference system, how it makes the syntax of the language so lightweight, and how to work around some...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
“array” issue was fixed by #1664 “method” will be fixed by #1767 “fold” seems to work now, but I don’t completely know what commit fixed it
@farodin91 Uh, now understand. Your example was too ambigous =) Yes,
acc
inference faild. Ok