From 9236673d66644ebc8f49e897a7b47bf61214c434 Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Fri, 13 Mar 2020 01:23:17 +0100 Subject: [PATCH] Fix newtype indent in associated type family (#207) --- src-literatetests/10-tests.blt | 18 ++++++++++++++++++ .../Brittany/Internal/Layouters/Decl.hs | 1 + 2 files changed, 19 insertions(+) diff --git a/src-literatetests/10-tests.blt b/src-literatetests/10-tests.blt index a3d1138..88f3598 100644 --- a/src-literatetests/10-tests.blt +++ b/src-literatetests/10-tests.blt @@ -1514,6 +1514,24 @@ instance MyClass Int where , intData2 :: Int } +#test instance-with-newtype-family-and-deriving + +{-# LANGUAGE TypeFamilies #-} + +module Lib where + +instance Foo () where + newtype Bar () = Baz () + deriving (Eq, Ord, Show) + bar = Baz + +#test instance-with-newtype-family-and-record + +instance Foo Int where + newtype Bar Int = BarInt + { unBarInt :: Int + } + ############################################################################### ############################################################################### diff --git a/src/Language/Haskell/Brittany/Internal/Layouters/Decl.hs b/src/Language/Haskell/Brittany/Internal/Layouters/Decl.hs index fbbcafd..d457920 100644 --- a/src/Language/Haskell/Brittany/Internal/Layouters/Decl.hs +++ b/src/Language/Haskell/Brittany/Internal/Layouters/Decl.hs @@ -1037,6 +1037,7 @@ layoutClsInst lcid@(L _ cid) = docLines | otherwise -> st : go lineR isTypeOrData t' = (Text.pack "type" `Text.isPrefixOf` t') + || (Text.pack "newtype" `Text.isPrefixOf` t') || (Text.pack "data" `Text.isPrefixOf` t')