Type annotation adjacency warning doesn't consider operator names
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
In this snippet,
``` fsharp
type Digit<'a> = 'a list
type FingerTree<'a> =
| Empty
| Single of 'a
| Deep of Digit<'a> * FingerTree> * Digit<'a>
let rec (<<)<'a> (a: 'a) (tree: FingerTree<'a>): FingerTree<'a> =
match tree with
| Empty -> Single a
| Single b -> Deep ([a], Empty, [b])
| Deep ([b; c; d; e], m, suffix) -> Deep ([a; b], (Node3 (c, d, e)) << m, suffix)
| Deep (prefix, m, suffix) -> Deep (List.append [a] prefix, m, suffix)
```
the compiler warns that "Type parameters must be placed directly adjacent to the type name". Presumably that's because the method name is surrounded by ()s.
(I need the `<'a>` because the function takes a FingerTree<'a> but the recursion takes a FingerTree>.)
If I make the operator a function, instead --
``` fsharp
let rec addToFront<'a> (a: 'a) (tree: FingerTree<'a>): FingerTree<'a> =
match tree with
| Empty -> Single a
| Single b -> Deep ([a], Empty, [b])
| Deep ([b; c; d; e], m, suffix) -> Deep ([a; b], addToFront (Node3 (c, d, e)) m, suffix)
| Deep (prefix, m, suffix) -> Deep (List.append [a] prefix, m, suffix)
```
-- then everything works.
Contributor guide
Assessment
This issue has not been assessed yet.