Set different indent policy for preamble #349

Open
opened 2021-06-19 14:46:18 +02:00 by yutotakano · 0 comments
yutotakano commented 2021-06-19 14:46:18 +02:00 (Migrated from github.com)

I'd love it if it were possible to use IndentPolicyFree on the module preamble, but IndentPolicyLeft on the body code.

IndentPolicyFree

import           Control.Monad                  ( guard
                                                , unless
                                                , void
                                                )
import           Control.Monad.IO.Class         ( MonadIO )
import           Data.Maybe                     ( catMaybes )

item = Item
    { aField       = "mhm"
    , anotherField = \x ->
                         case
                                 complexFunction
                                     123
                                     (anotherComplexFunction x Nothing)
                             of
                                 Left  e -> Nothing
                                 Right y -> Just [y]
    }

IndentPolicyLeft & IndentPolicyMultiple

import Control.Monad (guard, unless, void)
import Control.Monad.IO.Class (MonadIO)
import Data.Maybe (catMaybes)

item = Item
    { aField       = "mhm"
    , anotherField = \x ->
        case complexFunction 123 (anotherComplexFunction x Nothing) of
            Left  e -> Nothing
            Right y -> Just [y]
    }

My goal is to achieve the import list of the former, with the body formatted as the latter. Specifically, I dislike how in the former result, complexFunction and the Left/Right are indented to (4n + 1) spaces! It looks like a hanging indent from \x, but this is quite ugly.

I'd love it if it were possible to use IndentPolicyFree on the module preamble, but IndentPolicyLeft on the body code. ## IndentPolicyFree ```hs import Control.Monad ( guard , unless , void ) import Control.Monad.IO.Class ( MonadIO ) import Data.Maybe ( catMaybes ) item = Item { aField = "mhm" , anotherField = \x -> case complexFunction 123 (anotherComplexFunction x Nothing) of Left e -> Nothing Right y -> Just [y] } ``` ## IndentPolicyLeft & IndentPolicyMultiple ```hs import Control.Monad (guard, unless, void) import Control.Monad.IO.Class (MonadIO) import Data.Maybe (catMaybes) item = Item { aField = "mhm" , anotherField = \x -> case complexFunction 123 (anotherComplexFunction x Nothing) of Left e -> Nothing Right y -> Just [y] } ``` My goal is to achieve the import list of the former, with the body formatted as the latter. Specifically, I dislike how in the former result, `complexFunction` and the `Left`/`Right` are indented to (4n + 1) spaces! It looks like a hanging indent from `\x`, but this is quite ugly.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#349
There is no content yet.