Skip to content

Allow defining new functions with typed holes #2572

Closed
@bradrn

Description

@bradrn

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions