This is a naive first pass at sum type support. This currently breaks 11
tests, some from comment misplacement, others in more exotic forms that
previously required high levels of context to be correctly laid out. The
solution for comment misplacement is probably trivial, but the highly
contextualized forms may need a bit more alchemy.
```
1) data type declarations record no matching single line layout
expected: Right
{-# LANGUAGE ScopedTypeVariables #-}
-- brittany { lconfig_allowSinglelineRecord: true }
data MyRecord = forall a . Show a => Bar
{ foo :: abittoolongbutnotvery -> abittoolongbutnotvery
}
but got: Right
{-# LANGUAGE ScopedTypeVariables #-}
-- brittany { lconfig_allowSinglelineRecord: true }
data MyRecord = forall a
. Show a =>
Bar
{ foo :: abittoolongbutnotvery -> abittoolongbutnotvery
}
2) data type declarations record forall constraint multiline
expected: Right
{-# LANGUAGE ScopedTypeVariables #-}
data MyRecord
= forall a
. LooooooooooooooooooooongConstraint a =>
LoooooooooooongConstructor
{ foo :: abittoolongbutnotvery -> abittoolongbutnotvery
}
but got: Right
{-# LANGUAGE ScopedTypeVariables #-}
data MyRecord = forall a
. LooooooooooooooooooooongConstraint a =>
LoooooooooooongConstructor
{ foo :: abittoolongbutnotvery -> abittoolongbutnotvery
}
3) data type declarations record forall constraint multiline more
expected: Right
{-# LANGUAGE ScopedTypeVariables #-}
data MyRecord
= forall a b
. ( Loooooooooooooooooooooooooooooooong a
, Loooooooooooooooooooooooooooooooong b
) =>
MyConstructor
{ a :: a
, b :: b
}
but got: Right
{-# LANGUAGE ScopedTypeVariables #-}
data MyRecord = forall a b
. ( Loooooooooooooooooooooooooooooooong a
, Loooooooooooooooooooooooooooooooong b
) =>
MyConstructor
{ a :: a
, b :: b
}
4) data type declarations plain with forall and constraint
expected: Right
{-# LANGUAGE ScopedTypeVariables #-}
data MyStruct
= forall a b
. ( Loooooooooooooooooooooooooooooooong a
, Loooooooooooooooooooooooooooooooong b
) =>
MyConstructor (ToBriDocM BriDocNumbered)
(ToBriDocM BriDocNumbered)
(ToBriDocM BriDocNumbered)
but got: Right
{-# LANGUAGE ScopedTypeVariables #-}
data MyStruct = forall a b
. ( Loooooooooooooooooooooooooooooooong a
, Loooooooooooooooooooooooooooooooong b
) =>
MyConstructor (ToBriDocM BriDocNumbered)
(ToBriDocM BriDocNumbered)
(ToBriDocM BriDocNumbered)
5) data type declarations record with many features
expected: Right
{-# LANGUAGE ScopedTypeVariables #-}
data MyRecord
= forall a b
. ( Loooooooooooooooooooooooooooooooong a
, Loooooooooooooooooooooooooooooooong b
) =>
MyConstructor
{ foo, foo2
:: loooooooooooooooooooooooooooooooong
-> loooooooooooooooooooooooooooooooong
, bar :: a
, bazz :: b
}
deriving Show
but got: Right
{-# LANGUAGE ScopedTypeVariables #-}
data MyRecord = forall a b
. ( Loooooooooooooooooooooooooooooooong a
, Loooooooooooooooooooooooooooooooong b
) =>
MyConstructor
{ foo, foo2
:: loooooooooooooooooooooooooooooooong
-> loooooooooooooooooooooooooooooooong
, bar :: a
, bazz :: b
}
deriving Show
6) data type declarations single record existential
expected: Right
{-# LANGUAGE ExistentialQuantification #-}
data Foo = forall a . Show a => Bar
{ foo :: a
}
but got: Right
{-# LANGUAGE ExistentialQuantification #-}
data Foo = forall a
. Show a =>
Bar
{ foo :: a
}
7) data type declarations record multiple types existential
expected: Right
{-# LANGUAGE ExistentialQuantification #-}
data Foo = forall a b . (Show a, Eq b) => Bar
{ foo :: a
, bars :: b
}
but got: Right
{-# LANGUAGE ExistentialQuantification #-}
data Foo = forall a b
. (Show a, Eq b) =>
Bar
{ foo :: a
, bars :: b
}
8) data type declarations record newline comment
expected: Right
data MyRecord = MyRecord
{ a :: Int
-- comment
, b :: Int
}
but got: Right
data MyRecord = MyRecord
{ a :: Int
-- comment
, b :: Int
}
9) data type declarations comment before equal sign
expected: Right
{-# LANGUAGE ExistentialQuantification #-}
data MyRecord
-- test comment
= forall a b
. ( Loooooooooooooooooooooooooooooooong a
, Loooooooooooooooooooooooooooooooong b
) =>
MyConstructor a b
but got: Right
{-# LANGUAGE ExistentialQuantification #-}
data MyRecord
-- test comment
= forall a b
. ( Loooooooooooooooooooooooooooooooong a
, Loooooooooooooooooooooooooooooooong b
) =>
MyConstructor a b
10) data type declarations large record with a comment
expected: Right
data XIILqcacwiuNiu = XIILqcacwiuNiu
{ oyyFtvbepgbOge_pebzVmuftEijwuj :: Jgtoyuh HessJvNlo
, wloQsiskdoxJop_xatiKrwedOxtu :: Jgtoyuh [Inotg]
, mmmJjcqtemyIyo_ovosDoreKeeoyamvove :: Jgtoyuh Eujo
, mbiIatelofxOzr_uluxNngiiMjah :: Jgtoyuh HessJvNlo
, obxIskfcxpkIkb_uuviTuevcSkrgo :: Jgtoyuh Int
, wqrAtuvuecoHwr_ilotNxbuPleo :: Jgtoyuh Ufaxdeq
, lofAfuebdhpLuv_cnekPoyFxmg :: Jgtoyuh Ufaxdeq
, ouoFugtawzvUpk_oupiLzptugy :: Jgtoyuh Eujo
, iqiXjtziwogNsa_uiyvSunaTtgUsf3 :: Jgtoyuh Oaivn
, odbIriaqnojUlz_onotoWuunehIpuy :: Jgtoyuh Eujo
, opjUxtkxzkiKse_luqjuZazt
:: Jgtoyuh [(Eujo, Int, Int, Int, Int, Int, NELUxro)]
-- , jcqRaqznxfhIpa_ywevMezmoYkutuwa :: Jgtoyuh ()
, vayOmuasyphOfd_bcsVljmvt :: Jgtoyuh Eujo
, rifArahilooRax_ufikecqdImsv :: Jgtoyuh Oaivn
, raqKtopcpszDwb_oqocubasZuqjcryoDojGkw :: Jgtoyuh Oaivn
, mluJiilpcijUtt_gaisklifVekfeyagRmfbyzz :: Jgtoyuh Oaivn
, oqhPaahjupaSmi_gamwwoovKyxznecvEayluc :: Jgtoyuh Oaivn
, mazFubimwebZpa_itidehDodiDlboz :: Jgtoyuh Vrep
, jeyOcuesexaYoy_vpqn :: Jgtoyuh ()
}
but got: Right
data XIILqcacwiuNiu = XIILqcacwiuNiu
{ oyyFtvbepgbOge_pebzVmuftEijwuj :: Jgtoyuh HessJvNlo
, wloQsiskdoxJop_xatiKrwedOxtu :: Jgtoyuh [Inotg]
, mmmJjcqtemyIyo_ovosDoreKeeoyamvove :: Jgtoyuh Eujo
, mbiIatelofxOzr_uluxNngiiMjah :: Jgtoyuh HessJvNlo
, obxIskfcxpkIkb_uuviTuevcSkrgo :: Jgtoyuh Int
, wqrAtuvuecoHwr_ilotNxbuPleo :: Jgtoyuh Ufaxdeq
, lofAfuebdhpLuv_cnekPoyFxmg :: Jgtoyuh Ufaxdeq
, ouoFugtawzvUpk_oupiLzptugy :: Jgtoyuh Eujo
, iqiXjtziwogNsa_uiyvSunaTtgUsf3 :: Jgtoyuh Oaivn
, odbIriaqnojUlz_onotoWuunehIpuy :: Jgtoyuh Eujo
, opjUxtkxzkiKse_luqjuZazt
:: Jgtoyuh [(Eujo, Int, Int, Int, Int, Int, NELUxro)]
-- , jcqRaqznxfhIpa_ywevMezmoYkutuwa :: Jgtoyuh ()
, vayOmuasyphOfd_bcsVljmvt :: Jgtoyuh Eujo
, rifArahilooRax_ufikecqdImsv :: Jgtoyuh Oaivn
, raqKtopcpszDwb_oqocubasZuqjcryoDojGkw :: Jgtoyuh Oaivn
, mluJiilpcijUtt_gaisklifVekfeyagRmfbyzz :: Jgtoyuh Oaivn
, oqhPaahjupaSmi_gamwwoovKyxznecvEayluc :: Jgtoyuh Oaivn
, mazFubimwebZpa_itidehDodiDlboz :: Jgtoyuh Vrep
, jeyOcuesexaYoy_vpqn :: Jgtoyuh ()
}
11) data type declarations records in sum
expected: Right
-- brittany {lconfig_indentPolicy: IndentPolicyLeft }
data Foo
= Bar
{ foo :: Int -- hello
, bar :: Foo
-- how are you
}
| Baz
| Biz
{ foo :: Int
, bar :: Foo
}
but got: Right
-- brittany {lconfig_indentPolicy: IndentPolicyLeft }
data Foo
= Bar
{ foo :: Int -- hello
, bar :: Foo
-- how are you
}
| Baz
| Biz
{ foo :: Int
, bar :: Foo
}
```