Inconsistent layout for pattern matching record types vs construction #223

Open
opened 2019-04-10 19:16:23 +02:00 by mbeidler · 0 comments
mbeidler commented 2019-04-10 19:16:23 +02:00 (Migrated from github.com)

Running brittany on the following program:

data Foo = Foo
  { foo :: Int
  , bar :: String
  , baz :: Bool
  , quux :: Maybe Int
  , a :: Char
  , b :: Bool
  } deriving (Eq, Show)

handleFoo :: Foo -> IO ()
handleFoo foo = case foo of
  Foo { foo = 42
      , bar = "abcdefghijklmnopqrstuvwxyz"
      , baz = True
      , quux = Just 1 } -> putStrLn "bingo!"
  _ -> return ()

buildFoo :: Foo
buildFoo = Foo
  { foo  = 42
  , bar  = "abcdefghijklmnopqrstuvwxyz"
  , baz  = True
  , quux = Just 1
  , a    = 'z'
  , b    = 'b'
  }

produces:

data Foo = Foo
  { foo :: Int
  , bar :: String
  , baz :: Bool
  , quux :: Maybe Int
  , a :: Char
  , b :: Bool
  } deriving (Eq, Show)

handleFoo :: Foo -> IO ()
handleFoo foo = case foo of
  Foo { foo = 42, bar = "abcdefghijklmnopqrstuvwxyz", baz = True, quux = Just 1 }
    -> putStrLn "bingo!"
  _ -> return ()

buildFoo :: Foo
buildFoo = Foo
  { foo  = 42
  , bar  = "abcdefghijklmnopqrstuvwxyz"
  , baz  = True
  , quux = Just 1
  , a    = 'z'
  , b    = 'b'
  }

Notice the inconsistency in layout for pattern match versus record construction. Also, the layout it chose exceeds the maximum characters per line limit.

Running brittany on the following program: ```haskell data Foo = Foo { foo :: Int , bar :: String , baz :: Bool , quux :: Maybe Int , a :: Char , b :: Bool } deriving (Eq, Show) handleFoo :: Foo -> IO () handleFoo foo = case foo of Foo { foo = 42 , bar = "abcdefghijklmnopqrstuvwxyz" , baz = True , quux = Just 1 } -> putStrLn "bingo!" _ -> return () buildFoo :: Foo buildFoo = Foo { foo = 42 , bar = "abcdefghijklmnopqrstuvwxyz" , baz = True , quux = Just 1 , a = 'z' , b = 'b' } ``` produces: ```haskell data Foo = Foo { foo :: Int , bar :: String , baz :: Bool , quux :: Maybe Int , a :: Char , b :: Bool } deriving (Eq, Show) handleFoo :: Foo -> IO () handleFoo foo = case foo of Foo { foo = 42, bar = "abcdefghijklmnopqrstuvwxyz", baz = True, quux = Just 1 } -> putStrLn "bingo!" _ -> return () buildFoo :: Foo buildFoo = Foo { foo = 42 , bar = "abcdefghijklmnopqrstuvwxyz" , baz = True , quux = Just 1 , a = 'z' , b = 'b' } ``` Notice the inconsistency in layout for pattern match versus record construction. Also, the layout it chose exceeds the maximum characters per line limit.
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#223
There is no content yet.