Skip to content

Code blocks should strip alignment of opening brace #305

Description

@sgraf812

Motivated by #303, I think we should offer a command-line flag such that a code block

         | 'pattern' pattern_synonym_lhs '<-' pat_syn_pat where_decls
             {% do { let (name, args, as) = $2
                   ; mg <- mkPatSynMatchGroup name $51 }

is turned into

 do { let (name, args, as) = $2
    ; mg <- mkPatSynMatchGroup name $51 }

instead of

 do { let (name, args, as) = $2
                   ; mg <- mkPatSynMatchGroup name $51 }

That is, try and trim a whitespace prefix from subsequent lines that corresponds to the alignment of {%.

I think we can make code blocks entirely insensitive to indentation by wrapping them in do{...}. Example:

x :: Int
x = do{ 42 } -- works on pure expressions as well

-- code block: {%do putStrLn "this is the"
--                  putStrLn "code block"}

main =                do
            putStrLn "hi"
            do{
do putStrLn "this is the"
   putStrLn "code block"}
            putStrLn "end"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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