Skip to content

How to re-order data constructors? #133

@negatratoron

Description

@negatratoron

Hey, suppose I've got a data type with multiple constructors and would like to re-order them:

data JSValue = JSNumber Double
             | JSString String
             | JSNull
             | JSObject [(String, JSValue)]
             | JSArray [JSValue]
             | JSIndexInto JSValue JSValue
             | JSLetIn String JSValue JSValue
             | JSIdentifier String
             | JSLambda [String] JSValue
             | JSApplication JSValue [JSValue]

For example, say I want to move JSIdentifier to the top. Normally I would use C-k to kill the line. However it seems the behavior of (shm/kill-line) is to kill all data constructors to the end of the type. Here that would include JSIdentifier, JSLambda, and JSApplication.

Another way to move the data constructor would be to select it, use kill-region, and yank. (Specifically: place your cursor immediately after the |, select, move down one line, kill region, place your cursor after the =, and then yank.) Following this procedure, killing the line works as expected, but upon yanking, the formatting is not correct:

data JSValue =JSIdentifier String
  | JSNumber Double
             | JSString String
             | JSNull
             | JSObject [(String, JSValue)]
             | JSArray [JSValue]
             | JSIndexInto JSValue JSValue
             | JSLetIn String JSValue JSValue
             | JSLambda [String] JSValue
             | JSApplication JSValue [JSValue]

So, how should one actually re-order data constructors?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions