Skip to content

Allow defining new functions with typed holes #2572

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

Closed
bradrn opened this issue Jan 8, 2022 · 4 comments
Closed

Allow defining new functions with typed holes #2572

bradrn opened this issue Jan 8, 2022 · 4 comments
Labels

Comments

@bradrn
Copy link
Contributor

bradrn commented Jan 8, 2022

Is your feature request related to a problem? Please describe.

At the moment, the ‘Define <function>’ code action is hardcoded to produce name <> " = error \"not implemented\"" as the body of the function:

= [ ("Define " <> sig
, [TextEdit (Range nextLineP nextLineP) (T.unlines ["", sig, name <> " = error \"not implemented\""])]
)]

This is mostly satisfactory — but has the disadvantage of not producing a compiler error. If defining several new functions at once, it is easy to forget to go back and fill it in.

Describe the solution you'd like

It would be nice to have the option to define the function as a typed hole — so something like:

 = [ ("Define " <> sig 
     , [TextEdit (Range nextLineP nextLineP) (T.unlines ["", sig, name <> " = error \"not implemented\""])] 
+    )
+  , ("Define " <> sig <> " as typed hole"
+    , [TextEdit (Range nextLineP nextLineP) (T.unlines ["", sig, name <> " = _"])]
     )]

This would provide an easy way to reduce the number of code errors. It also provides a better UX: in my editor (Emacs), for instance, it would let me jump to and from the new function using flycheck-next-error etc.

@jneira
Copy link
Member

jneira commented Jan 8, 2022

thanks for the suggestion, coincidentally there is a pr which aims to implement it: #2465 (comment)

@bradrn
Copy link
Contributor Author

bradrn commented Jan 9, 2022

Thanks @jneira! It’s a pretty minimal PR; any idea when it might be merged?

@jneira
Copy link
Member

jneira commented Jan 10, 2022

Afaics it "only" needs make the CI green 🙂

@michaelpj
Copy link
Collaborator

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants