Repository navigation
Show a functor's parameters on hover #9083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Hover on a functor shows its parameters, such as `module MakeSet: (O: Ord) => {...}`, instead of only its body. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| module type Ord = { | ||
| type t | ||
| let compare: (t, t) => int | ||
| } | ||
|
|
||
| module MakeSet = (O: Ord) => { | ||
| // ^hov | ||
| type t = array<O.t> | ||
| let add = (s: t, x: O.t) => s->Array.concat([x]) | ||
| } | ||
|
|
||
| module Pair = (A: Ord, B: Ord) => { | ||
| // ^hov | ||
| type t = (A.t, B.t) | ||
| } | ||
|
|
||
| module Inline = (X: { | ||
| // ^hov | ||
| let x: int | ||
| }) => { | ||
| let y = X.x | ||
| } | ||
|
|
||
| module IntOrd = { | ||
| type t = int | ||
| let compare = (a: int, b) => a - b | ||
| } | ||
|
|
||
| // An applied functor is a plain module | ||
| module IntSet = MakeSet(IntOrd) | ||
| // ^hov | ||
|
|
||
| // A partially applied functor keeps its remaining parameter | ||
| module PairInt = Pair(IntOrd) | ||
| // ^hov | ||
|
|
||
| module Counter = () => { | ||
| // ^hov | ||
| let count = ref(0) | ||
| } | ||
|
|
||
| module type Primitive = { | ||
| type t | ||
| } | ||
|
|
||
| module Gen = (P: Primitive, ()) => { | ||
| // ^hov | ||
| type t = P.t | ||
| } | ||
|
|
||
| module GenFirst = ((), P: Primitive) => { | ||
| // ^hov | ||
| type t = P.t | ||
| } | ||
|
|
||
| module Curried = (A: Ord) => (B: Ord) => { | ||
| // ^hov | ||
| type t = (A.t, B.t) | ||
| } | ||
|
|
||
| module GenCurried = () => (P: Primitive) => { | ||
| // ^hov | ||
| type t = P.t | ||
| } | ||
|
|
||
| module GenApplied = Gen(IntOrd) | ||
| // ^hov |
88 changes: 88 additions & 0 deletions
88
tests/analysis_tests/tests/src/expected/HoverFunctor.res.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| Hover src/HoverFunctor.res 5:9 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule MakeSet: (O: Ord) => {\n type t = array<O.t>\n let add: (t, O.t) => array<O.t>\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 11:7 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule Pair: (A: Ord, B: Ord) => {\n type t = (A.t, B.t)\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 16:9 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule Inline: (X: {let x: int}) => {\n let y: int\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 29:8 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule IntSet: {\n type t = array<IntOrd.t>\n let add: (t, IntOrd.t) => array<IntOrd.t>\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 33:8 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule PairInt: (B: Ord) => {\n type t = (IntOrd.t, B.t)\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 36:9 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule Counter: () => {\n let count: ref<int>\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 45:7 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule Gen: (P: Primitive, ()) => {\n type t = P.t\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 50:9 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule GenFirst: ((), P: Primitive) => {\n type t = P.t\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 55:9 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule Curried: (A: Ord, B: Ord) => {\n type t = (A.t, B.t)\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 60:9 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule GenCurried: ((), P: Primitive) => {\n type t = P.t\n}\n```" | ||
| } | ||
| } | ||
|
|
||
| Hover src/HoverFunctor.res 65:8 | ||
| { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```rescript\nmodule GenApplied: () => {\n type t = IntOrd.t\n}\n```" | ||
| } | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.