diff --git a/data/examples/declaration/class/associated-data1-out.hs b/data/examples/declaration/class/associated-data1-out.hs new file mode 100644 index 0000000..462b460 --- /dev/null +++ b/data/examples/declaration/class/associated-data1-out.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE TypeFamilies #-} + +class Foo a where data FooBar a + +-- | Something. +class Bar a where + + -- | Bar bar + data BarBar a + + -- | Bar baz + data + BarBaz + a diff --git a/data/examples/declaration/class/associated-data1.hs b/data/examples/declaration/class/associated-data1.hs new file mode 100644 index 0000000..d654d17 --- /dev/null +++ b/data/examples/declaration/class/associated-data1.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE TypeFamilies #-} + +class Foo a where data FooBar a + +-- | Something. +class Bar a + where + -- | Bar bar + data BarBar a + -- | Bar baz + data family BarBaz + a diff --git a/data/examples/declaration/class/associated-data-out.hs b/data/examples/declaration/class/associated-data2-out.hs similarity index 56% rename from data/examples/declaration/class/associated-data-out.hs rename to data/examples/declaration/class/associated-data2-out.hs index 02483d9..8d830e7 100644 --- a/data/examples/declaration/class/associated-data-out.hs +++ b/data/examples/declaration/class/associated-data2-out.hs @@ -1,18 +1,5 @@ {-# LANGUAGE TypeFamilies #-} -class Foo a where data FooBar a - --- | Something. -class Bar a where - - -- | Bar bar - data BarBar a - - -- | Bar baz - data - BarBaz - a - -- | Something more. class Baz a where diff --git a/data/examples/declaration/class/associated-data.hs b/data/examples/declaration/class/associated-data2.hs similarity index 56% rename from data/examples/declaration/class/associated-data.hs rename to data/examples/declaration/class/associated-data2.hs index b5bedc3..166bced 100644 --- a/data/examples/declaration/class/associated-data.hs +++ b/data/examples/declaration/class/associated-data2.hs @@ -1,16 +1,5 @@ {-# LANGUAGE TypeFamilies #-} -class Foo a where data FooBar a - --- | Something. -class Bar a - where - -- | Bar bar - data BarBar a - -- | Bar baz - data family BarBaz - a - -- | Something more. class Baz a where -- | Baz bar diff --git a/data/examples/declaration/class/associated-types1-out.hs b/data/examples/declaration/class/associated-types1-out.hs new file mode 100644 index 0000000..ab51c5f --- /dev/null +++ b/data/examples/declaration/class/associated-types1-out.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE TypeFamilies #-} + +class Foo a where type FooBar a + +-- | Something. +class Bar a where + + -- | Bar bar + type BarBar a + + -- | Bar baz + type + BarBaz + a diff --git a/data/examples/declaration/class/associated-types1.hs b/data/examples/declaration/class/associated-types1.hs new file mode 100644 index 0000000..b26e93b --- /dev/null +++ b/data/examples/declaration/class/associated-types1.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE TypeFamilies #-} + +class Foo a where type FooBar a + +-- | Something. +class Bar a + where + -- | Bar bar + type BarBar a + -- | Bar baz + type BarBaz + a diff --git a/data/examples/declaration/class/associated-types-out.hs b/data/examples/declaration/class/associated-types2-out.hs similarity index 60% rename from data/examples/declaration/class/associated-types-out.hs rename to data/examples/declaration/class/associated-types2-out.hs index 5f547a1..65e1b2a 100644 --- a/data/examples/declaration/class/associated-types-out.hs +++ b/data/examples/declaration/class/associated-types2-out.hs @@ -1,18 +1,5 @@ {-# LANGUAGE TypeFamilies #-} -class Foo a where type FooBar a - --- | Something. -class Bar a where - - -- | Bar bar - type BarBar a - - -- | Bar baz - type - BarBaz - a - -- | Something more. class Baz a where diff --git a/data/examples/declaration/class/associated-types.hs b/data/examples/declaration/class/associated-types2.hs similarity index 62% rename from data/examples/declaration/class/associated-types.hs rename to data/examples/declaration/class/associated-types2.hs index 9be40e1..8b2c581 100644 --- a/data/examples/declaration/class/associated-types.hs +++ b/data/examples/declaration/class/associated-types2.hs @@ -1,16 +1,5 @@ {-# LANGUAGE TypeFamilies #-} -class Foo a where type FooBar a - --- | Something. -class Bar a - where - -- | Bar bar - type BarBar a - -- | Bar baz - type BarBaz - a - -- | Something more. class Baz a where -- | Baz bar diff --git a/data/examples/declaration/class/default-implementations-comments-out.hs b/data/examples/declaration/class/default-implementations-comments-out.hs new file mode 100644 index 0000000..42d9f23 --- /dev/null +++ b/data/examples/declaration/class/default-implementations-comments-out.hs @@ -0,0 +1,25 @@ +-- | Baz +class Baz a where + + foobar :: a -> a + foobar a = + barbaz (bazbar a) + + -- | Bar baz + barbaz + :: a -> a + + -- | Baz bar + bazbar + :: a + -> a + + -- First comment + barbaz a = + bazbar -- Middle comment + a + + -- Last comment + bazbar a = + barbaz + a diff --git a/data/examples/declaration/class/default-implementations-comments.hs b/data/examples/declaration/class/default-implementations-comments.hs new file mode 100644 index 0000000..95a8d41 --- /dev/null +++ b/data/examples/declaration/class/default-implementations-comments.hs @@ -0,0 +1,20 @@ +-- | Baz +class Baz a where + foobar :: a -> a + foobar a = + barbaz (bazbar a) + -- | Bar baz + barbaz :: + a -> a + -- | Baz bar + bazbar :: + a -> + a + -- First comment + barbaz a + = bazbar -- Middle comment + a + -- Last comment + bazbar a + = barbaz + a diff --git a/data/examples/declaration/class/default-implementations-out.hs b/data/examples/declaration/class/default-implementations-out.hs index 698ebda..015c4e0 100644 --- a/data/examples/declaration/class/default-implementations-out.hs +++ b/data/examples/declaration/class/default-implementations-out.hs @@ -11,29 +11,3 @@ class Bar a where :: a -> Int bar = const 0 - --- | Baz -class Baz a where - - foobar :: a -> a - foobar a = - barbaz (bazbar a) - - -- | Bar baz - barbaz - :: a -> a - - -- | Baz bar - bazbar - :: a - -> a - - -- First comment - barbaz a = - bazbar -- Middle comment - a - - -- Last comment - bazbar a = - barbaz - a diff --git a/data/examples/declaration/class/default-implementations.hs b/data/examples/declaration/class/default-implementations.hs index e7b616b..3415f41 100644 --- a/data/examples/declaration/class/default-implementations.hs +++ b/data/examples/declaration/class/default-implementations.hs @@ -10,23 +10,3 @@ class Bar a where -> Int bar = const 0 --- | Baz -class Baz a where - foobar :: a -> a - foobar a = - barbaz (bazbar a) - -- | Bar baz - barbaz :: - a -> a - -- | Baz bar - bazbar :: - a -> - a - -- First comment - barbaz a - = bazbar -- Middle comment - a - -- Last comment - bazbar a - = barbaz - a diff --git a/data/examples/declaration/class/default-signatures-out.hs b/data/examples/declaration/class/default-signatures-out.hs index fcb1144..2bca107 100644 --- a/data/examples/declaration/class/default-signatures-out.hs +++ b/data/examples/declaration/class/default-signatures-out.hs @@ -1,14 +1,5 @@ {-# LANGUAGE DefaultSignatures #-} --- | Something. -class Foo a where - - -- | Foo - foo :: a -> String - - default foo :: Show a => a -> String - foo = show - -- | Something else. class Bar a where diff --git a/data/examples/declaration/class/default-signatures-simple-out.hs b/data/examples/declaration/class/default-signatures-simple-out.hs new file mode 100644 index 0000000..839a6f6 --- /dev/null +++ b/data/examples/declaration/class/default-signatures-simple-out.hs @@ -0,0 +1,8 @@ +-- | Something. +class Foo a where + + -- | Foo + foo :: a -> String + + default foo :: Show a => a -> String + foo = show diff --git a/data/examples/declaration/class/default-signatures-simple.hs b/data/examples/declaration/class/default-signatures-simple.hs new file mode 100644 index 0000000..3739320 --- /dev/null +++ b/data/examples/declaration/class/default-signatures-simple.hs @@ -0,0 +1,7 @@ +-- | Something. +class Foo a where + -- | Foo + foo :: a -> String + default foo :: Show a => a -> String + foo = show + diff --git a/data/examples/declaration/class/default-signatures.hs b/data/examples/declaration/class/default-signatures.hs index 37fbb00..2a1932a 100644 --- a/data/examples/declaration/class/default-signatures.hs +++ b/data/examples/declaration/class/default-signatures.hs @@ -1,12 +1,5 @@ {-# LANGUAGE DefaultSignatures #-} --- | Something. -class Foo a where - -- | Foo - foo :: a -> String - default foo :: Show a => a -> String - foo = show - -- | Something else. class Bar a where diff --git a/data/examples/declaration/class/multi-parameters1-out.hs b/data/examples/declaration/class/multi-parameters1-out.hs new file mode 100644 index 0000000..aa3f3cf --- /dev/null +++ b/data/examples/declaration/class/multi-parameters1-out.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE MultiParamTypeClasses #-} + +class Foo a b where foo :: a -> b + +-- | Something. +class Bar a b c d where + + bar + :: a + -> b + -> c + -> d + +class -- Before name + Baz where + + baz :: Int diff --git a/data/examples/declaration/class/multi-parameters1.hs b/data/examples/declaration/class/multi-parameters1.hs new file mode 100644 index 0000000..156540a --- /dev/null +++ b/data/examples/declaration/class/multi-parameters1.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE MultiParamTypeClasses #-} + +class Foo a b where foo :: a -> b + +-- | Something. +class Bar a b c d + where + bar :: + a + -> b + -> c + -> d + +class -- Before name + Baz + where + baz :: Int + diff --git a/data/examples/declaration/class/multi-parameters-out.hs b/data/examples/declaration/class/multi-parameters2-out.hs similarity index 56% rename from data/examples/declaration/class/multi-parameters-out.hs rename to data/examples/declaration/class/multi-parameters2-out.hs index 6e321e4..e0623bd 100644 --- a/data/examples/declaration/class/multi-parameters-out.hs +++ b/data/examples/declaration/class/multi-parameters2-out.hs @@ -1,21 +1,5 @@ {-# LANGUAGE MultiParamTypeClasses #-} -class Foo a b where foo :: a -> b - --- | Something. -class Bar a b c d where - - bar - :: a - -> b - -> c - -> d - -class -- Before name - Baz where - - baz :: Int - -- | Something else. class BarBaz diff --git a/data/examples/declaration/class/multi-parameters.hs b/data/examples/declaration/class/multi-parameters2.hs similarity index 62% rename from data/examples/declaration/class/multi-parameters.hs rename to data/examples/declaration/class/multi-parameters2.hs index 21cb0c6..7e7894a 100644 --- a/data/examples/declaration/class/multi-parameters.hs +++ b/data/examples/declaration/class/multi-parameters2.hs @@ -1,21 +1,5 @@ {-# LANGUAGE MultiParamTypeClasses #-} -class Foo a b where foo :: a -> b - --- | Something. -class Bar a b c d - where - bar :: - a - -> b - -> c - -> d - -class -- Before name - Baz - where - baz :: Int - -- | Something else. class BarBaz diff --git a/data/examples/declaration/class/type-operators-out.hs b/data/examples/declaration/class/type-operators-out.hs deleted file mode 100644 index 56d43d7..0000000 --- a/data/examples/declaration/class/type-operators-out.hs +++ /dev/null @@ -1,43 +0,0 @@ -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE TypeOperators #-} - -class (:$) a b - -class - (:&) - a - b - -class a :* b - -class - a -- Before operator - :+ b -- After operator - -class - ( f - :. g - ) - a - -class a `Pair` b - -class - a - `Sum` b - -class (f `Product` g) a - -class - ( f - `Sum` g - ) - a - -type API - = "route1" :> ApiRoute1 - :<|> "route2" - :> ApiRoute2 -- comment here - :<|> OmitDocs - :> "i" - :> ASomething API diff --git a/data/examples/declaration/class/type-operators.hs b/data/examples/declaration/class/type-operators.hs deleted file mode 100644 index 3cc002b..0000000 --- a/data/examples/declaration/class/type-operators.hs +++ /dev/null @@ -1,39 +0,0 @@ -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE TypeOperators #-} - -class (:$) a b - -class (:&) - a - b - -class a:*b - -class - a -- Before operator - :+ - b -- After operator - -class ( - f :. g - ) a - -class - a`Pair`b - -class - a - `Sum` b - -class (f`Product`g)a - -class ( - f `Sum` g - ) a - -type API - = "route1" :> ApiRoute1 - :<|> "route2" :> ApiRoute2 -- comment here - :<|> OmitDocs :> "i" :> ASomething API - - diff --git a/data/examples/declaration/class/type-operators1-out.hs b/data/examples/declaration/class/type-operators1-out.hs new file mode 100644 index 0000000..5c39e60 --- /dev/null +++ b/data/examples/declaration/class/type-operators1-out.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} + +class (:$) a b + +class + (:&) + a + b + +class a :* b + +class + a -- Before operator + :+ b -- After operator + +class + ( f + :. g + ) + a diff --git a/data/examples/declaration/class/type-operators1.hs b/data/examples/declaration/class/type-operators1.hs new file mode 100644 index 0000000..db3f5c2 --- /dev/null +++ b/data/examples/declaration/class/type-operators1.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} + +class (:$) a b + +class (:&) + a + b + +class a:*b + +class + a -- Before operator + :+ + b -- After operator + +class ( + f :. g + ) a diff --git a/data/examples/declaration/class/type-operators2-out.hs b/data/examples/declaration/class/type-operators2-out.hs new file mode 100644 index 0000000..370291a --- /dev/null +++ b/data/examples/declaration/class/type-operators2-out.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} + +class a `Pair` b + +class + a + `Sum` b + +class (f `Product` g) a + +class + ( f + `Sum` g + ) + a diff --git a/data/examples/declaration/class/type-operators2.hs b/data/examples/declaration/class/type-operators2.hs new file mode 100644 index 0000000..9b752de --- /dev/null +++ b/data/examples/declaration/class/type-operators2.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeOperators #-} + +class + a`Pair`b + +class + a + `Sum` b + +class (f`Product`g)a + +class ( + f `Sum` g + ) a + diff --git a/data/examples/declaration/deriving/multiline-out.hs b/data/examples/declaration/deriving/multiline-out.hs index 00833e6..2479e7d 100644 --- a/data/examples/declaration/deriving/multiline-out.hs +++ b/data/examples/declaration/deriving/multiline-out.hs @@ -14,26 +14,6 @@ deriving newtype instance Data Foo -deriving instance - {-# OVERLAPPABLE #-} - Ord - Foo - -deriving instance - {-# OVERLAPPING #-} - Num - Foo - -deriving instance - {-# OVERLAPS #-} - Read - Foo - -deriving instance - {-# INCOHERENT #-} - Show - Foo - deriving via Foo Int diff --git a/data/examples/declaration/deriving/multiline.hs b/data/examples/declaration/deriving/multiline.hs index 980c332..5db03f1 100644 --- a/data/examples/declaration/deriving/multiline.hs +++ b/data/examples/declaration/deriving/multiline.hs @@ -11,23 +11,6 @@ deriving newtype instance Data Foo -deriving instance - {-# OVERLAPPABLE #-} - Ord - Foo -deriving instance - {-# OVERLAPPING #-} - Num - Foo -deriving instance - {-# OVERLAPS #-} - Read - Foo -deriving instance - {-# INCOHERENT #-} - Show - Foo - deriving via Foo Int instance Triple diff --git a/data/examples/declaration/deriving/overlapping-out.hs b/data/examples/declaration/deriving/overlapping-out.hs new file mode 100644 index 0000000..53a315f --- /dev/null +++ b/data/examples/declaration/deriving/overlapping-out.hs @@ -0,0 +1,19 @@ +deriving instance + {-# OVERLAPPABLE #-} + Ord + Foo + +deriving instance + {-# OVERLAPPING #-} + Num + Foo + +deriving instance + {-# OVERLAPS #-} + Read + Foo + +deriving instance + {-# INCOHERENT #-} + Show + Foo diff --git a/data/examples/declaration/deriving/overlapping.hs b/data/examples/declaration/deriving/overlapping.hs new file mode 100644 index 0000000..013f989 --- /dev/null +++ b/data/examples/declaration/deriving/overlapping.hs @@ -0,0 +1,17 @@ +deriving instance + {-# OVERLAPPABLE #-} + Ord + Foo +deriving instance + {-# OVERLAPPING #-} + Num + Foo +deriving instance + {-# OVERLAPS #-} + Read + Foo +deriving instance + {-# INCOHERENT #-} + Show + Foo + diff --git a/data/examples/declaration/instance/contexts-comments-out.hs b/data/examples/declaration/instance/contexts-comments-out.hs new file mode 100644 index 0000000..d49b2ca --- /dev/null +++ b/data/examples/declaration/instance/contexts-comments-out.hs @@ -0,0 +1,18 @@ +instance + ( Read a, -- Foo + Read b, + Read + ( c, -- Bar + d + ) + ) + => Read + ( a, -- Baz + b, + ( c, -- Quux + d + ) + ) + where + + readsPrec = undefined diff --git a/data/examples/declaration/instance/contexts-comments.hs b/data/examples/declaration/instance/contexts-comments.hs new file mode 100644 index 0000000..cbaa041 --- /dev/null +++ b/data/examples/declaration/instance/contexts-comments.hs @@ -0,0 +1,18 @@ +instance ( + Read a, -- Foo + Read b + , Read ( + c, -- Bar + d + ) + ) + => + Read ( + a, -- Baz + b + ,( + c, -- Quux + d + ) + ) where + readsPrec = undefined diff --git a/data/examples/declaration/instance/contexts-out.hs b/data/examples/declaration/instance/contexts-out.hs index 7abd17f..fa9ba42 100644 --- a/data/examples/declaration/instance/contexts-out.hs +++ b/data/examples/declaration/instance/contexts-out.hs @@ -18,22 +18,3 @@ instance where showsPrec _ _ = showString "" - -instance - ( Read a, -- Foo - Read b, - Read - ( c, -- Bar - d - ) - ) - => Read - ( a, -- Baz - b, - ( c, -- Quux - d - ) - ) - where - - readsPrec = undefined diff --git a/data/examples/declaration/instance/contexts.hs b/data/examples/declaration/instance/contexts.hs index 8167194..b6ce8c1 100644 --- a/data/examples/declaration/instance/contexts.hs +++ b/data/examples/declaration/instance/contexts.hs @@ -12,22 +12,3 @@ instance (Show a, Show b) => b ) where showsPrec _ _ = showString "" - -instance ( - Read a, -- Foo - Read b - , Read ( - c, -- Bar - d - ) - ) - => - Read ( - a, -- Baz - b - ,( - c, -- Quux - d - ) - ) where - readsPrec = undefined diff --git a/data/examples/declaration/instance/data-family-instances-gadt-out.hs b/data/examples/declaration/instance/data-family-instances-gadt-out.hs new file mode 100644 index 0000000..e1d135b --- /dev/null +++ b/data/examples/declaration/instance/data-family-instances-gadt-out.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE GADTSyntax #-} +{-# LANGUAGE TypeFamilies #-} + +data instance Bar Int a where + SameBar + :: Bar Int + Int + CloseBar :: Bar Int Double + OtherBar + :: Bar Int + a diff --git a/data/examples/declaration/instance/data-family-instances-gadt.hs b/data/examples/declaration/instance/data-family-instances-gadt.hs new file mode 100644 index 0000000..d3e7dc6 --- /dev/null +++ b/data/examples/declaration/instance/data-family-instances-gadt.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE GADTSyntax #-} +{-# LANGUAGE TypeFamilies #-} +data instance Bar Int a where + SameBar + :: Bar Int + Int + CloseBar :: Bar Int Double + OtherBar + :: Bar Int + a diff --git a/data/examples/declaration/instance/data-family-instances-newtype-out.hs b/data/examples/declaration/instance/data-family-instances-newtype-out.hs new file mode 100644 index 0000000..eee6145 --- /dev/null +++ b/data/examples/declaration/instance/data-family-instances-newtype-out.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE GADTSyntax #-} +{-# LANGUAGE TypeFamilies #-} + +newtype instance Foo [Double] + = DoubleListFoo + { unDoubleListFoo :: Double + } diff --git a/data/examples/declaration/instance/data-family-instances-newtype.hs b/data/examples/declaration/instance/data-family-instances-newtype.hs new file mode 100644 index 0000000..bd512d9 --- /dev/null +++ b/data/examples/declaration/instance/data-family-instances-newtype.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE GADTSyntax #-} +{-# LANGUAGE TypeFamilies #-} +newtype instance Foo [Double] = DoubleListFoo { + unDoubleListFoo :: Double +} + diff --git a/data/examples/declaration/instance/data-family-instances-out.hs b/data/examples/declaration/instance/data-family-instances-out.hs index bec0fea..3598698 100644 --- a/data/examples/declaration/instance/data-family-instances-out.hs +++ b/data/examples/declaration/instance/data-family-instances-out.hs @@ -14,21 +14,7 @@ data instance Double ) -newtype instance Foo [Double] - = DoubleListFoo - { unDoubleListFoo :: Double - } - data instance Bar Double a = DoubleBar Double (Bar a) - -data instance Bar Int a where - SameBar - :: Bar Int - Int - CloseBar :: Bar Int Double - OtherBar - :: Bar Int - a diff --git a/data/examples/declaration/instance/data-family-instances.hs b/data/examples/declaration/instance/data-family-instances.hs index 8ab9512..ff00bbc 100644 --- a/data/examples/declaration/instance/data-family-instances.hs +++ b/data/examples/declaration/instance/data-family-instances.hs @@ -13,20 +13,8 @@ data instance Double ) -newtype instance Foo [Double] = DoubleListFoo { - unDoubleListFoo :: Double -} - data instance Bar Double a = DoubleBar Double (Bar a) -data instance Bar Int a where - SameBar - :: Bar Int - Int - CloseBar :: Bar Int Double - OtherBar - :: Bar Int - a diff --git a/data/examples/declaration/instance/instance-sigs-multiple-out.hs b/data/examples/declaration/instance/instance-sigs-multiple-out.hs new file mode 100644 index 0000000..29f91b5 --- /dev/null +++ b/data/examples/declaration/instance/instance-sigs-multiple-out.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE InstanceSigs #-} + +instance Applicative [] where + + pure + :: a + -> [a] + pure a = [a] + + (<*>) + :: [a] -> [a] -> [a] + (<*>) _ _ = [] diff --git a/data/examples/declaration/instance/instance-sigs-multiple.hs b/data/examples/declaration/instance/instance-sigs-multiple.hs new file mode 100644 index 0000000..decc695 --- /dev/null +++ b/data/examples/declaration/instance/instance-sigs-multiple.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE InstanceSigs #-} + +instance Applicative [] where + pure :: + a + -> [a] + pure a = [a] + (<*>) + :: [ a ] -> [ a ] -> [ a ] + (<*>) _ _ = [] diff --git a/data/examples/declaration/instance/instance-sigs-out.hs b/data/examples/declaration/instance/instance-sigs-out.hs index 69ce6d5..0bbcf30 100644 --- a/data/examples/declaration/instance/instance-sigs-out.hs +++ b/data/examples/declaration/instance/instance-sigs-out.hs @@ -15,14 +15,3 @@ instance Ord Int where _ _ = GT - -instance Applicative [] where - - pure - :: a - -> [a] - pure a = [a] - - (<*>) - :: [a] -> [a] -> [a] - (<*>) _ _ = [] diff --git a/data/examples/declaration/instance/instance-sigs.hs b/data/examples/declaration/instance/instance-sigs.hs index 23ed092..352b689 100644 --- a/data/examples/declaration/instance/instance-sigs.hs +++ b/data/examples/declaration/instance/instance-sigs.hs @@ -14,12 +14,3 @@ instance Ord Int where _ _ = GT - -instance Applicative [] where - pure :: - a - -> [a] - pure a = [a] - (<*>) - :: [ a ] -> [ a ] -> [ a ] - (<*>) _ _ = [] diff --git a/data/examples/declaration/rewrite-rule/basic1-out.hs b/data/examples/declaration/rewrite-rule/basic1-out.hs new file mode 100644 index 0000000..1e44ca1 --- /dev/null +++ b/data/examples/declaration/rewrite-rule/basic1-out.hs @@ -0,0 +1,18 @@ +{-# RULES +"fold/build" foldr k z (build g) = g k z + #-} + +{-# RULES +"fusable/aux" + fusable x (aux y) = + faux x y + #-} + +{-# RULES +"map/map" + map f + (map g xs) = + map + (f . g) + xs + #-} diff --git a/data/examples/declaration/rewrite-rule/basic1.hs b/data/examples/declaration/rewrite-rule/basic1.hs new file mode 100644 index 0000000..22c031e --- /dev/null +++ b/data/examples/declaration/rewrite-rule/basic1.hs @@ -0,0 +1,17 @@ +{-# RULES +"fold/build" foldr k z (build g) = g k z + #-} + +{-# RULES +"fusable/aux" + fusable x (aux y) = faux x y + #-} + +{-# RULES +"map/map" + map f + (map g xs) = map + (f . g) + xs + #-} + diff --git a/data/examples/declaration/rewrite-rule/basic-out.hs b/data/examples/declaration/rewrite-rule/basic2-out.hs similarity index 66% rename from data/examples/declaration/rewrite-rule/basic-out.hs rename to data/examples/declaration/rewrite-rule/basic2-out.hs index 5408c14..43fe6de 100644 --- a/data/examples/declaration/rewrite-rule/basic-out.hs +++ b/data/examples/declaration/rewrite-rule/basic2-out.hs @@ -1,22 +1,3 @@ -{-# RULES -"fold/build" foldr k z (build g) = g k z - #-} - -{-# RULES -"fusable/aux" - fusable x (aux y) = - faux x y - #-} - -{-# RULES -"map/map" - map f - (map g xs) = - map - (f . g) - xs - #-} - {-# RULES "++" xs ++ ys = augment (\c n -> foldr c n xs) ys "concat" xs `concat` ys = augment (\c n -> foldr c n xs) ys diff --git a/data/examples/declaration/rewrite-rule/basic.hs b/data/examples/declaration/rewrite-rule/basic2.hs similarity index 68% rename from data/examples/declaration/rewrite-rule/basic.hs rename to data/examples/declaration/rewrite-rule/basic2.hs index 9d6758f..6b4a3a0 100644 --- a/data/examples/declaration/rewrite-rule/basic.hs +++ b/data/examples/declaration/rewrite-rule/basic2.hs @@ -1,20 +1,3 @@ -{-# RULES -"fold/build" foldr k z (build g) = g k z - #-} - -{-# RULES -"fusable/aux" - fusable x (aux y) = faux x y - #-} - -{-# RULES -"map/map" - map f - (map g xs) = map - (f . g) - xs - #-} - {-# RULES "++" xs ++ ys = augment (\c n -> foldr c n xs) ys "concat" xs `concat` ys = augment (\c n -> foldr c n xs) ys diff --git a/data/examples/declaration/rewrite-rule/prelude-out.hs b/data/examples/declaration/rewrite-rule/prelude-out.hs deleted file mode 100644 index 99ec708..0000000 --- a/data/examples/declaration/rewrite-rule/prelude-out.hs +++ /dev/null @@ -1,74 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -{-# RULES -"map/map" forall f g xs. map f (map g xs) = map (f . g) xs -"map/append" forall f xs ys. map f (xs ++ ys) = map f xs ++ map f ys - #-} - -{-# RULES -"fold/build" forall k z (g :: forall b. (a -> b -> b) -> b -> b). - foldr k z (build g) = - g k z -"foldr/augment" forall k z xs (g :: forall b. (a -> b -> b) -> b -> b). - foldr k z (augment g xs) = - g k (foldr k z xs) -"foldr/id" foldr (:) [] = \x -> x -"foldr/app" [1] forall ys. foldr (:) ys = \xs -> xs ++ ys --- Only activate this from phase 1, because that's --- when we disable the rule that expands (++) into foldr - --- The foldr/cons rule looks nice, but it can give disastrously --- bloated code when commpiling --- array (a,b) [(1,2), (2,2), (3,2), ...very long list... ] --- i.e. when there are very very long literal lists --- So I've disabled it for now. We could have special cases --- for short lists, I suppose. --- "foldr/cons" forall k z x xs. foldr k z (x:xs) = k x (foldr k z xs) -"foldr/single" forall k z x. foldr k z [x] = k x z -"foldr/nil" forall k z. foldr k z [] = z -"augment/build" forall - (g :: forall b. (a -> b -> b) -> b -> b) - (h :: forall b. (a -> b -> b) -> b -> b). - augment g (build h) = - build (\c n -> g c (h c n)) -"augment/nil" forall (g :: forall b. (a -> b -> b) -> b -> b). - augment g [] = - build g - #-} - -{-# RULES -"map" [~1] forall f xs. map f xs = build (\c n -> foldr (mapFB c f) n xs) -"mapList" [1] forall f. foldr (mapFB (:) f) [] = map f -"mapFB" forall c f g. mapFB (mapFB c f) g = mapFB c (f . g) - #-} - -{-# RULES -"map/map" [~2] forall f g xs. - map f (map g xs) = - map (f . g) xs -"f" op True y = False -"g" op True y = False - #-} - -{-# RULES -"x# `eqChar#` x#" forall x#. x# `eqChar#` x# = True -"x# `neChar#` x#" forall x#. x# `neChar#` x# = False -"x# `gtChar#` x#" forall x#. x# `gtChar#` x# = False -"x# `geChar#` x#" forall x#. x# `geChar#` x# = True -"x# `leChar#` x#" forall x#. x# `leChar#` x# = True -"x# `ltChar#` x#" forall x#. x# `ltChar#` x# = False - #-} - -{-# RULES -"unpack" [~1] forall a. unpackCString# a = build (unpackFoldrCString# a) -"unpack-list" [1] forall a. unpackFoldrCString# a (:) [] = unpackCString# a -"unpack-append" forall a n. unpackFoldrCString# a (:) n = unpackAppendCString# a n --- There's a built-in rule (in PrelRules.lhs) for --- unpackFoldr "foo" c (unpackFoldr "baz" c n) = unpackFoldr "foobaz" c n - #-} - -{-# RULES -"foldr/build" forall f n (g :: forall b. (a -> b -> b) -> b -> b). - foldr f n (build g) = - g f n - #-} diff --git a/data/examples/declaration/rewrite-rule/prelude.hs b/data/examples/declaration/rewrite-rule/prelude.hs deleted file mode 100644 index 76a595e..0000000 --- a/data/examples/declaration/rewrite-rule/prelude.hs +++ /dev/null @@ -1,73 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -{-# RULES -"map/map" forall f g xs. map f (map g xs) = map (f.g) xs -"map/append" forall f xs ys. map f (xs ++ ys) = map f xs ++ map f ys - #-} - -{-# RULES -"fold/build" forall k z (g::forall b. (a->b->b) -> b -> b) . - foldr k z (build g) = g k z - -"foldr/augment" forall k z xs (g::forall b. (a->b->b) -> b -> b) . - foldr k z (augment g xs) = g k (foldr k z xs) - -"foldr/id" foldr (:) [] = \x -> x -"foldr/app" [1] forall ys. foldr (:) ys = \xs -> xs ++ ys - -- Only activate this from phase 1, because that's - -- when we disable the rule that expands (++) into foldr - --- The foldr/cons rule looks nice, but it can give disastrously --- bloated code when commpiling --- array (a,b) [(1,2), (2,2), (3,2), ...very long list... ] --- i.e. when there are very very long literal lists --- So I've disabled it for now. We could have special cases --- for short lists, I suppose. --- "foldr/cons" forall k z x xs. foldr k z (x:xs) = k x (foldr k z xs) - -"foldr/single" forall k z x. foldr k z [x] = k x z -"foldr/nil" forall k z. foldr k z [] = z - -"augment/build" forall (g::forall b. (a->b->b) -> b -> b) - (h::forall b. (a->b->b) -> b -> b) . - augment g (build h) = build (\c n -> g c (h c n)) -"augment/nil" forall (g::forall b. (a->b->b) -> b -> b) . - augment g [] = build g - #-} - -{-# RULES -"map" [~1] forall f xs. map f xs = build (\c n -> foldr (mapFB c f) n xs) -"mapList" [1] forall f. foldr (mapFB (:) f) [] = map f -"mapFB" forall c f g. mapFB (mapFB c f) g = mapFB c (f.g) - #-} - -{-# RULES - "map/map" [~2] forall f g xs. - map f (map g xs) = map (f.g) xs; "f" op True y = False; - "g" op True y = False -#-} - -{-# RULES -"x# `eqChar#` x#" forall x#. x# `eqChar#` x# = True -"x# `neChar#` x#" forall x#. x# `neChar#` x# = False -"x# `gtChar#` x#" forall x#. x# `gtChar#` x# = False -"x# `geChar#` x#" forall x#. x# `geChar#` x# = True -"x# `leChar#` x#" forall x#. x# `leChar#` x# = True -"x# `ltChar#` x#" forall x#. x# `ltChar#` x# = False - #-} - -{-# RULES -"unpack" [~1] forall a . unpackCString# a = build (unpackFoldrCString# a) -"unpack-list" [1] forall a . unpackFoldrCString# a (:) [] = unpackCString# a -"unpack-append" forall a n . unpackFoldrCString# a (:) n = unpackAppendCString# a n - --- There's a built-in rule (in PrelRules.lhs) for --- unpackFoldr "foo" c (unpackFoldr "baz" c n) = unpackFoldr "foobaz" c n - - #-} - -{-# RULES - "foldr/build" - forall f n (g :: forall b. (a -> b -> b) -> b -> b). - foldr f n (build g) = g f n -#-} diff --git a/data/examples/declaration/rewrite-rule/prelude1-out.hs b/data/examples/declaration/rewrite-rule/prelude1-out.hs new file mode 100644 index 0000000..4132e0a --- /dev/null +++ b/data/examples/declaration/rewrite-rule/prelude1-out.hs @@ -0,0 +1,18 @@ +{-# RULES +"map/map" forall f g xs. map f (map g xs) = map (f . g) xs +"map/append" forall f xs ys. map f (xs ++ ys) = map f xs ++ map f ys + #-} + +{-# RULES +"map" [~1] forall f xs. map f xs = build (\c n -> foldr (mapFB c f) n xs) +"mapList" [1] forall f. foldr (mapFB (:) f) [] = map f +"mapFB" forall c f g. mapFB (mapFB c f) g = mapFB c (f . g) + #-} + +{-# RULES +"map/map" [~2] forall f g xs. + map f (map g xs) = + map (f . g) xs +"f" op True y = False +"g" op True y = False + #-} diff --git a/data/examples/declaration/rewrite-rule/prelude1.hs b/data/examples/declaration/rewrite-rule/prelude1.hs new file mode 100644 index 0000000..ef79140 --- /dev/null +++ b/data/examples/declaration/rewrite-rule/prelude1.hs @@ -0,0 +1,17 @@ +{-# RULES +"map/map" forall f g xs. map f (map g xs) = map (f.g) xs +"map/append" forall f xs ys. map f (xs ++ ys) = map f xs ++ map f ys + #-} + +{-# RULES +"map" [~1] forall f xs. map f xs = build (\c n -> foldr (mapFB c f) n xs) +"mapList" [1] forall f. foldr (mapFB (:) f) [] = map f +"mapFB" forall c f g. mapFB (mapFB c f) g = mapFB c (f.g) + #-} + +{-# RULES + "map/map" [~2] forall f g xs. + map f (map g xs) = map (f.g) xs; "f" op True y = False; + "g" op True y = False +#-} + diff --git a/data/examples/declaration/rewrite-rule/prelude2-out.hs b/data/examples/declaration/rewrite-rule/prelude2-out.hs new file mode 100644 index 0000000..b63091f --- /dev/null +++ b/data/examples/declaration/rewrite-rule/prelude2-out.hs @@ -0,0 +1,30 @@ +{-# RULES +"fold/build" forall k z (g :: forall b. (a -> b -> b) -> b -> b). + foldr k z (build g) = + g k z +"foldr/augment" forall k z xs (g :: forall b. (a -> b -> b) -> b -> b). + foldr k z (augment g xs) = + g k (foldr k z xs) +"foldr/id" foldr (:) [] = \x -> x +"foldr/app" [1] forall ys. foldr (:) ys = \xs -> xs ++ ys +-- Only activate this from phase 1, because that's +-- when we disable the rule that expands (++) into foldr + +-- The foldr/cons rule looks nice, but it can give disastrously +-- bloated code when commpiling +-- array (a,b) [(1,2), (2,2), (3,2), ...very long list... ] +-- i.e. when there are very very long literal lists +-- So I've disabled it for now. We could have special cases +-- for short lists, I suppose. +-- "foldr/cons" forall k z x xs. foldr k z (x:xs) = k x (foldr k z xs) +"foldr/single" forall k z x. foldr k z [x] = k x z +"foldr/nil" forall k z. foldr k z [] = z +"augment/build" forall + (g :: forall b. (a -> b -> b) -> b -> b) + (h :: forall b. (a -> b -> b) -> b -> b). + augment g (build h) = + build (\c n -> g c (h c n)) +"augment/nil" forall (g :: forall b. (a -> b -> b) -> b -> b). + augment g [] = + build g + #-} diff --git a/data/examples/declaration/rewrite-rule/prelude2.hs b/data/examples/declaration/rewrite-rule/prelude2.hs new file mode 100644 index 0000000..4b766bb --- /dev/null +++ b/data/examples/declaration/rewrite-rule/prelude2.hs @@ -0,0 +1,30 @@ +{-# RULES +"fold/build" forall k z (g::forall b. (a->b->b) -> b -> b) . + foldr k z (build g) = g k z + +"foldr/augment" forall k z xs (g::forall b. (a->b->b) -> b -> b) . + foldr k z (augment g xs) = g k (foldr k z xs) + +"foldr/id" foldr (:) [] = \x -> x +"foldr/app" [1] forall ys. foldr (:) ys = \xs -> xs ++ ys + -- Only activate this from phase 1, because that's + -- when we disable the rule that expands (++) into foldr + +-- The foldr/cons rule looks nice, but it can give disastrously +-- bloated code when commpiling +-- array (a,b) [(1,2), (2,2), (3,2), ...very long list... ] +-- i.e. when there are very very long literal lists +-- So I've disabled it for now. We could have special cases +-- for short lists, I suppose. +-- "foldr/cons" forall k z x xs. foldr k z (x:xs) = k x (foldr k z xs) + +"foldr/single" forall k z x. foldr k z [x] = k x z +"foldr/nil" forall k z. foldr k z [] = z + +"augment/build" forall (g::forall b. (a->b->b) -> b -> b) + (h::forall b. (a->b->b) -> b -> b) . + augment g (build h) = build (\c n -> g c (h c n)) +"augment/nil" forall (g::forall b. (a->b->b) -> b -> b) . + augment g [] = build g + #-} + diff --git a/data/examples/declaration/rewrite-rule/prelude3-out.hs b/data/examples/declaration/rewrite-rule/prelude3-out.hs new file mode 100644 index 0000000..1f7fa0e --- /dev/null +++ b/data/examples/declaration/rewrite-rule/prelude3-out.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE MagicHash #-} + +{-# RULES +"x# `eqChar#` x#" forall x#. x# `eqChar#` x# = True +"x# `neChar#` x#" forall x#. x# `neChar#` x# = False +"x# `gtChar#` x#" forall x#. x# `gtChar#` x# = False +"x# `geChar#` x#" forall x#. x# `geChar#` x# = True +"x# `leChar#` x#" forall x#. x# `leChar#` x# = True +"x# `ltChar#` x#" forall x#. x# `ltChar#` x# = False + #-} diff --git a/data/examples/declaration/rewrite-rule/prelude3.hs b/data/examples/declaration/rewrite-rule/prelude3.hs new file mode 100644 index 0000000..1f7fa0e --- /dev/null +++ b/data/examples/declaration/rewrite-rule/prelude3.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE MagicHash #-} + +{-# RULES +"x# `eqChar#` x#" forall x#. x# `eqChar#` x# = True +"x# `neChar#` x#" forall x#. x# `neChar#` x# = False +"x# `gtChar#` x#" forall x#. x# `gtChar#` x# = False +"x# `geChar#` x#" forall x#. x# `geChar#` x# = True +"x# `leChar#` x#" forall x#. x# `leChar#` x# = True +"x# `ltChar#` x#" forall x#. x# `ltChar#` x# = False + #-} diff --git a/data/examples/declaration/rewrite-rule/prelude4-out.hs b/data/examples/declaration/rewrite-rule/prelude4-out.hs new file mode 100644 index 0000000..cf84dd6 --- /dev/null +++ b/data/examples/declaration/rewrite-rule/prelude4-out.hs @@ -0,0 +1,7 @@ +{-# RULES +"unpack" [~1] forall a. unpackCString # a = build (unpackFoldrCString # a) +"unpack-list" [1] forall a. unpackFoldrCString # a (:) [] = unpackCString # a +"unpack-append" forall a n. unpackFoldrCString # a (:) n = unpackAppendCString # a n + #-} +-- There's a built-in rule (in PrelRules.lhs) for +-- unpackFoldr "foo" c (unpackFoldr "baz" c n) = unpackFoldr "foobaz" c n diff --git a/data/examples/declaration/rewrite-rule/prelude4.hs b/data/examples/declaration/rewrite-rule/prelude4.hs new file mode 100644 index 0000000..c8ea2aa --- /dev/null +++ b/data/examples/declaration/rewrite-rule/prelude4.hs @@ -0,0 +1,9 @@ +{-# RULES +"unpack" [~1] forall a . unpackCString# a = build (unpackFoldrCString# a) +"unpack-list" [1] forall a . unpackFoldrCString# a (:) [] = unpackCString# a +"unpack-append" forall a n . unpackFoldrCString# a (:) n = unpackAppendCString# a n + +-- There's a built-in rule (in PrelRules.lhs) for +-- unpackFoldr "foo" c (unpackFoldr "baz" c n) = unpackFoldr "foobaz" c n + + #-} diff --git a/data/examples/declaration/role-annotation/multi-line-out.hs b/data/examples/declaration/role-annotation/multi-line-out.hs new file mode 100644 index 0000000..7febd8a --- /dev/null +++ b/data/examples/declaration/role-annotation/multi-line-out.hs @@ -0,0 +1,15 @@ +type role + D + phantom + nominal + +type role + E + _ + nominal + +type role + E + _ + nominal + phantom diff --git a/data/examples/declaration/role-annotation/multi-line.hs b/data/examples/declaration/role-annotation/multi-line.hs new file mode 100644 index 0000000..a8e317e --- /dev/null +++ b/data/examples/declaration/role-annotation/multi-line.hs @@ -0,0 +1,15 @@ +type role + D phantom nominal + +type + role + E + _ + nominal + +type + role + E + _ + nominal + phantom diff --git a/data/examples/declaration/role-annotation/simple-out.hs b/data/examples/declaration/role-annotation/single-line-out.hs similarity index 57% rename from data/examples/declaration/role-annotation/simple-out.hs rename to data/examples/declaration/role-annotation/single-line-out.hs index 4103892..25b6990 100644 --- a/data/examples/declaration/role-annotation/simple-out.hs +++ b/data/examples/declaration/role-annotation/single-line-out.hs @@ -8,19 +8,3 @@ type role A nominal nominal type role B _ phantom type role C _ _ - -type role - D - phantom - nominal - -type role - E - _ - nominal - -type role - E - _ - nominal - phantom diff --git a/data/examples/declaration/role-annotation/simple.hs b/data/examples/declaration/role-annotation/single-line.hs similarity index 55% rename from data/examples/declaration/role-annotation/simple.hs rename to data/examples/declaration/role-annotation/single-line.hs index 7cdeada..1f6bf9e 100644 --- a/data/examples/declaration/role-annotation/simple.hs +++ b/data/examples/declaration/role-annotation/single-line.hs @@ -7,19 +7,3 @@ type role A nominal nominal type role B _ phantom type role C _ _ - -type role - D phantom nominal - -type - role - E - _ - nominal - -type - role - E - _ - nominal - phantom diff --git a/data/examples/declaration/splice/bracket-declaration-out.hs b/data/examples/declaration/splice/bracket-declaration-out.hs new file mode 100644 index 0000000..61d64ff --- /dev/null +++ b/data/examples/declaration/splice/bracket-declaration-out.hs @@ -0,0 +1,26 @@ +{-# LANGUAGE TemplateHaskell #-} + +[d|data T a where Foo :: T ()|] + +foo = + [d| + foo :: Int -> Char + + bar = 42 + |] + +[d| + data T = T + deriving (Eq, Ord, Enum, Bounded, Show) + |] + +$(do [d|baz = baz|]) + +$(singletons [d|data T = T deriving (Eq, Ord, Enum, Bounded, Show)|]) + +$( singletons + [d| + data T = T + deriving (Eq, Ord, Enum, Bounded, Show) + |] + ) diff --git a/data/examples/declaration/splice/bracket-declaration.hs b/data/examples/declaration/splice/bracket-declaration.hs new file mode 100644 index 0000000..ed05d14 --- /dev/null +++ b/data/examples/declaration/splice/bracket-declaration.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE TemplateHaskell #-} + +[d| data T a where Foo :: T () |] + +foo = [d| + foo:: Int -> Char + bar = 42 + |] + +[d| + data T = T + deriving (Eq, Ord, Enum, Bounded, Show) + |] + +$( do [d| baz = baz |] ) + +$(singletons [d| data T = T deriving (Eq, Ord, Enum, Bounded, Show) |]) + +$(singletons [d| + data T = T + deriving (Eq, Ord, Enum, Bounded, Show) + |]) diff --git a/data/examples/declaration/splice/bracket-out.hs b/data/examples/declaration/splice/bracket-out.hs index 877415e..77cea55 100644 --- a/data/examples/declaration/splice/bracket-out.hs +++ b/data/examples/declaration/splice/bracket-out.hs @@ -12,13 +12,6 @@ foo = foo = [t|Char|] -foo = - [d| - foo :: Int -> Char - - bar = 42 - |] - foo = [|| foo bar diff --git a/data/examples/declaration/splice/bracket.hs b/data/examples/declaration/splice/bracket.hs index ac0d22a..d07dace 100644 --- a/data/examples/declaration/splice/bracket.hs +++ b/data/examples/declaration/splice/bracket.hs @@ -8,10 +8,5 @@ foo = [e| foo bar foo = [t| Char |] -foo = [d| - foo:: Int -> Char - bar = 42 - |] - foo = [|| foo bar ||] diff --git a/data/examples/declaration/splice/splice-decl-out.hs b/data/examples/declaration/splice/splice-decl-out.hs index 5d1ec43..93f794c 100644 --- a/data/examples/declaration/splice/splice-decl-out.hs +++ b/data/examples/declaration/splice/splice-decl-out.hs @@ -15,21 +15,3 @@ foo bar -- TemplateHaskell allows Q () at the top level do pure [] - -$(do [d|baz = baz|]) - -[d|data T a where Foo :: T ()|] - -[d| - data T = T - deriving (Eq, Ord, Enum, Bounded, Show) - |] - -$(singletons [d|data T = T deriving (Eq, Ord, Enum, Bounded, Show)|]) - -$( singletons - [d| - data T = T - deriving (Eq, Ord, Enum, Bounded, Show) - |] - ) diff --git a/data/examples/declaration/splice/splice-decl.hs b/data/examples/declaration/splice/splice-decl.hs index a4c732e..595a8fa 100644 --- a/data/examples/declaration/splice/splice-decl.hs +++ b/data/examples/declaration/splice/splice-decl.hs @@ -16,19 +16,3 @@ foo bar do pure [] -$( do [d| baz = baz |] ) - -[d| data T a where Foo :: T () |] - -[d| - data T = T - deriving (Eq, Ord, Enum, Bounded, Show) - |] - -$(singletons [d| data T = T deriving (Eq, Ord, Enum, Bounded, Show) |]) - -$(singletons [d| - data T = T - deriving (Eq, Ord, Enum, Bounded, Show) - |]) - diff --git a/data/examples/declaration/type-synonyms/multi-line-out.hs b/data/examples/declaration/type-synonyms/multi-line-out.hs index dcb913a..710c48b 100644 --- a/data/examples/declaration/type-synonyms/multi-line-out.hs +++ b/data/examples/declaration/type-synonyms/multi-line-out.hs @@ -11,3 +11,11 @@ type Foo = Bar Baz Quux + +type API + = "route1" :> ApiRoute1 + :<|> "route2" + :> ApiRoute2 -- comment here + :<|> OmitDocs + :> "i" + :> ASomething API diff --git a/data/examples/declaration/type-synonyms/multi-line.hs b/data/examples/declaration/type-synonyms/multi-line.hs index c8745f9..b794adf 100644 --- a/data/examples/declaration/type-synonyms/multi-line.hs +++ b/data/examples/declaration/type-synonyms/multi-line.hs @@ -10,3 +10,11 @@ type Foo = Bar Baz Quux + +type API + = "route1" :> ApiRoute1 + :<|> "route2" :> ApiRoute2 -- comment here + :<|> OmitDocs :> "i" :> ASomething API + + + diff --git a/data/examples/declaration/value/function/arrow/proc-do-simple1-out.hs b/data/examples/declaration/value/function/arrow/proc-do-simple1-out.hs new file mode 100644 index 0000000..fbc89a0 --- /dev/null +++ b/data/examples/declaration/value/function/arrow/proc-do-simple1-out.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE Arrows #-} + +bar f = proc a -> do + b <- f -< a + +barbar f g = proc a -> do + b <- f -< a + returnA -< b + +barbaz f g = proc (a, b) -> do + c <- f -< a + d <- g -< b + +bazbar f = proc a -> do + a <- + f -< + a diff --git a/data/examples/declaration/value/function/arrow/proc-do-simple1.hs b/data/examples/declaration/value/function/arrow/proc-do-simple1.hs new file mode 100644 index 0000000..8c2a9ab --- /dev/null +++ b/data/examples/declaration/value/function/arrow/proc-do-simple1.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE Arrows #-} + +bar f = proc a -> + do b <- f -< a + +barbar f g = proc a -> + do b <- f -< a + returnA -< b + +barbaz f g = proc (a, b) -> + do c <- f -< a + d <- g -< b + +bazbar f = proc a -> + do a + <- + f + -< + a + diff --git a/data/examples/declaration/value/function/arrow/proc-do-simple-out.hs b/data/examples/declaration/value/function/arrow/proc-do-simple2-out.hs similarity index 53% rename from data/examples/declaration/value/function/arrow/proc-do-simple-out.hs rename to data/examples/declaration/value/function/arrow/proc-do-simple2-out.hs index 701b940..91ff35a 100644 --- a/data/examples/declaration/value/function/arrow/proc-do-simple-out.hs +++ b/data/examples/declaration/value/function/arrow/proc-do-simple2-out.hs @@ -3,22 +3,6 @@ foo f = proc a -> do f -< a -bar f = proc a -> do - b <- f -< a - -barbar f g = proc a -> do - b <- f -< a - returnA -< b - -barbaz f g = proc (a, b) -> do - c <- f -< a - d <- g -< b - -bazbar f = proc a -> do - a <- - f -< - a - bazbaz f g h = proc (a, b, c) -> do x <- f b -< a diff --git a/data/examples/declaration/value/function/arrow/proc-do-simple.hs b/data/examples/declaration/value/function/arrow/proc-do-simple2.hs similarity index 54% rename from data/examples/declaration/value/function/arrow/proc-do-simple.hs rename to data/examples/declaration/value/function/arrow/proc-do-simple2.hs index e3da86a..f63e985 100644 --- a/data/examples/declaration/value/function/arrow/proc-do-simple.hs +++ b/data/examples/declaration/value/function/arrow/proc-do-simple2.hs @@ -1,26 +1,7 @@ {-# LANGUAGE Arrows #-} - foo f = proc a -> do f -< a -bar f = proc a -> - do b <- f -< a - -barbar f g = proc a -> - do b <- f -< a - returnA -< b - -barbaz f g = proc (a, b) -> - do c <- f -< a - d <- g -< b - -bazbar f = proc a -> - do a - <- - f - -< - a - bazbaz f g h = proc (a, b, c) -> do x <- f b -< a diff --git a/data/examples/declaration/value/function/arrow/proc-forms-out.hs b/data/examples/declaration/value/function/arrow/proc-forms-out.hs deleted file mode 100644 index d1b3677..0000000 --- a/data/examples/declaration/value/function/arrow/proc-forms-out.hs +++ /dev/null @@ -1,35 +0,0 @@ -{-# LANGUAGE Arrows #-} - -foo0 f g x y = proc _ -> (|f (g -< (x, y))|) - -foo1 f g h x = - proc (y, z) -> - (|test (h f . (h g) -< (y x) . y z) ((h g) . h f -< y z . (y x))|) - -foo2 f g h x = - proc (y, z) -> - (| test - ( h f - . h g -< - y x - . y z - ) - ( h g - . h f -< - y z - . y x - ) - |) - -bar0 f g x y = proc _ -> f -< x &&& g -< y - -bar1 f g h x = - proc (y, z) -> - h f . (h g) -< (y x) . y z ||| (h g) . h f -< y z . (y x) - -bar2 f g h x = - proc (y, z) -> - (h f . h g) -< - (y x) . y z - ||| (h g . h f) -< - y z . (y x) diff --git a/data/examples/declaration/value/function/arrow/proc-forms.hs b/data/examples/declaration/value/function/arrow/proc-forms.hs deleted file mode 100644 index 2a705c7..0000000 --- a/data/examples/declaration/value/function/arrow/proc-forms.hs +++ /dev/null @@ -1,36 +0,0 @@ -{-# LANGUAGE Arrows #-} - -foo0 f g x y = proc _ -> (| f (g -< (x, y)) |) - -foo1 f g h x = - proc (y, z) -> - (| test (h f.(h g) -< (y x).y z)((h g) . h f- (| - test ( h f - . h g - -< - y x - . y z - ) - ( h g - . h f - -< - y z - . y x) - |) - -bar0 f g x y = proc _ -> f -< x&&&g -< y - -bar1 f g h x = - proc (y, z) -> - h f.(h g) -< (y x).y z ||| (h g) . h f- - (h f.h g) - -< (y x).y z - ||| - (h g . h f) - - (|f (g -< (x, y))|) + +foo1 f g h x = + proc (y, z) -> + (| test + ( h f + . h g -< + y x + . y z + ) + ( h g + . h f -< + y z + . y x + ) + |) diff --git a/data/examples/declaration/value/function/arrow/proc-forms1.hs b/data/examples/declaration/value/function/arrow/proc-forms1.hs new file mode 100644 index 0000000..f0d6c81 --- /dev/null +++ b/data/examples/declaration/value/function/arrow/proc-forms1.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE Arrows #-} + +foo0 f g x y = proc _ -> (| f (g -< (x, y)) |) + +foo1 f g h x = + proc (y, z) -> (| + test ( h f + . h g + -< + y x + . y z + ) + ( h g + . h f + -< + y z + . y x) + |) + diff --git a/data/examples/declaration/value/function/arrow/proc-forms2-out.hs b/data/examples/declaration/value/function/arrow/proc-forms2-out.hs new file mode 100644 index 0000000..af98cdf --- /dev/null +++ b/data/examples/declaration/value/function/arrow/proc-forms2-out.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE Arrows #-} + +bar0 f g h x = + proc (y, z) -> + (|test (h f . (h g) -< (y x) . y z) ((h g) . h f -< y z . (y x))|) + +bar1 f g x y = proc _ -> f -< x &&& g -< y + +bar2 f g h x = + proc (y, z) -> + h f . (h g) -< (y x) . y z ||| (h g) . h f -< y z . (y x) + +bar3 f g h x = + proc (y, z) -> + (h f . h g) -< + (y x) . y z + ||| (h g . h f) -< + y z . (y x) diff --git a/data/examples/declaration/value/function/arrow/proc-forms2.hs b/data/examples/declaration/value/function/arrow/proc-forms2.hs new file mode 100644 index 0000000..d239f5b --- /dev/null +++ b/data/examples/declaration/value/function/arrow/proc-forms2.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE Arrows #-} + +bar0 f g h x = + proc (y, z) -> + (| test (h f.(h g) -< (y x).y z)((h g) . h f- f -< x&&&g -< y + +bar2 f g h x = + proc (y, z) -> + h f.(h g) -< (y x).y z ||| (h g) . h f- + (h f.h g) + -< (y x).y z + ||| + (h g . h f) + - Int +withGuards x = + case x of + x + | x > 10 -> + foo + + bar + x | x > 5 -> 10 + _ -> 20 diff --git a/data/examples/declaration/value/function/case-multi-line-guards.hs b/data/examples/declaration/value/function/case-multi-line-guards.hs new file mode 100644 index 0000000..057d492 --- /dev/null +++ b/data/examples/declaration/value/function/case-multi-line-guards.hs @@ -0,0 +1,9 @@ +withGuards :: Int -> Int +withGuards x = + case x of + x | x > 10 -> + foo + + bar + x | x > 5 -> 10 + _ -> 20 + diff --git a/data/examples/declaration/value/function/case-multi-line-out.hs b/data/examples/declaration/value/function/case-multi-line-out.hs index c502952..9d43347 100644 --- a/data/examples/declaration/value/function/case-multi-line-out.hs +++ b/data/examples/declaration/value/function/case-multi-line-out.hs @@ -21,16 +21,6 @@ quux :: Int -> Int quux x = case x of x -> x -withGuards :: Int -> Int -withGuards x = - case x of - x - | x > 10 -> - foo - + bar - x | x > 5 -> 10 - _ -> 20 - funnyComment = -- comment case () of diff --git a/data/examples/declaration/value/function/case-multi-line.hs b/data/examples/declaration/value/function/case-multi-line.hs index 7cf8115..7666518 100644 --- a/data/examples/declaration/value/function/case-multi-line.hs +++ b/data/examples/declaration/value/function/case-multi-line.hs @@ -18,15 +18,6 @@ quux :: Int -> Int quux x = case x of x -> x -withGuards :: Int -> Int -withGuards x = - case x of - x | x > 10 -> - foo + - bar - x | x > 5 -> 10 - _ -> 20 - funnyComment = -- comment case () of () -> () diff --git a/data/examples/declaration/value/function/comprehension/transform-multi-line1-out.hs b/data/examples/declaration/value/function/comprehension/transform-multi-line1-out.hs new file mode 100644 index 0000000..769e7fc --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-multi-line1-out.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE TransformListComp #-} + +foo' xs ys = + [ ( x, + y + ) + | x <- xs, + y <- ys, + -- First comment + then reverse -- Second comment + ] diff --git a/data/examples/declaration/value/function/comprehension/transform-multi-line1.hs b/data/examples/declaration/value/function/comprehension/transform-multi-line1.hs new file mode 100644 index 0000000..055af86 --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-multi-line1.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TransformListComp #-} + +foo' xs ys = [ + (x, + y) | + x <- xs, + y <- ys, + then -- First comment + reverse -- Second comment + ] diff --git a/data/examples/declaration/value/function/comprehension/transform-multi-line2-out.hs b/data/examples/declaration/value/function/comprehension/transform-multi-line2-out.hs new file mode 100644 index 0000000..52e5085 --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-multi-line2-out.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TransformListComp #-} + +bar' xs ys = + [ ( x, + y + ) + | x <- xs, + y <- ys, + -- First comment + then sortWith + by + ( x + + y -- Second comment + ) + ] diff --git a/data/examples/declaration/value/function/comprehension/transform-multi-line2.hs b/data/examples/declaration/value/function/comprehension/transform-multi-line2.hs new file mode 100644 index 0000000..858ec09 --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-multi-line2.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TransformListComp #-} + +bar' xs ys = [ + (x, + y) | + x <- xs, + y <- ys, + then -- First comment + sortWith + by + (x + + y) -- Second comment + ] + + diff --git a/data/examples/declaration/value/function/comprehension/transform-multi-line3-out.hs b/data/examples/declaration/value/function/comprehension/transform-multi-line3-out.hs new file mode 100644 index 0000000..2dcd053 --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-multi-line3-out.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE TransformListComp #-} + +baz' xs ys = + [ ( x, + y + ) + | x <- xs, + y <- ys, + -- First comment + then group using permutations -- Second comment + ] diff --git a/data/examples/declaration/value/function/comprehension/transform-multi-line3.hs b/data/examples/declaration/value/function/comprehension/transform-multi-line3.hs new file mode 100644 index 0000000..20dd259 --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-multi-line3.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE TransformListComp #-} + +baz' xs ys = [ + (x, + y) | + x <- xs, + y <- ys, + then + group + using -- First comment + permutations -- Second comment + ] + diff --git a/data/examples/declaration/value/function/comprehension/transform-multi-line4-out.hs b/data/examples/declaration/value/function/comprehension/transform-multi-line4-out.hs new file mode 100644 index 0000000..b0f7bea --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-multi-line4-out.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE TransformListComp #-} + +quux' xs ys = + [ ( x, + y + ) + | x <- xs, + y <- ys, + -- First comment + then group by + ( x + + y + ) + -- Second comment + using groupWith -- Third comment + ] diff --git a/data/examples/declaration/value/function/comprehension/transform-multi-line4.hs b/data/examples/declaration/value/function/comprehension/transform-multi-line4.hs new file mode 100644 index 0000000..8087e60 --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-multi-line4.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TransformListComp #-} + +quux' xs ys = [ + (x, + y) | + x <- xs, + y <- ys, + then + group + by -- First comment + (x + + y) + using -- Second comment + groupWith -- Third comment + ] diff --git a/data/examples/declaration/value/function/comprehension/transform-single-line-out.hs b/data/examples/declaration/value/function/comprehension/transform-single-line-out.hs new file mode 100644 index 0000000..53561ec --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-single-line-out.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TransformListComp #-} + +foo xs ys = [(x, y) | x <- xs, y <- ys, then reverse] + +bar xs ys = [(x, y) | x <- xs, y <- ys, then sortWith by (x + y)] + +baz xs ys = [(x, y) | x <- xs, y <- ys, then group using permutations] + +quux xs ys = [(x, y) | x <- xs, y <- ys, then group by (x + y) using groupWith] diff --git a/data/examples/declaration/value/function/comprehension/transform-single-line.hs b/data/examples/declaration/value/function/comprehension/transform-single-line.hs new file mode 100644 index 0000000..53561ec --- /dev/null +++ b/data/examples/declaration/value/function/comprehension/transform-single-line.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TransformListComp #-} + +foo xs ys = [(x, y) | x <- xs, y <- ys, then reverse] + +bar xs ys = [(x, y) | x <- xs, y <- ys, then sortWith by (x + y)] + +baz xs ys = [(x, y) | x <- xs, y <- ys, then group using permutations] + +quux xs ys = [(x, y) | x <- xs, y <- ys, then group by (x + y) using groupWith] diff --git a/data/examples/declaration/value/function/do-out.hs b/data/examples/declaration/value/function/do-out.hs deleted file mode 100644 index de7f87c..0000000 --- a/data/examples/declaration/value/function/do-out.hs +++ /dev/null @@ -1,111 +0,0 @@ -{-# LANGUAGE RecursiveDo #-} - -bar = do foo; bar - -baz = - mdo - bar a - a <- foo - b <- - bar - 1 - 2 - 3 - return (a + b) - -baz = do - a <- foo - let b = a + 2 - c = b + 3 - bar c - let d = c + 2 - return d - -quux = something $ do - foo - case x of - 1 -> 10 - 2 -> 20 - bar - if something - then x - else y - baz - -foo = do - rec a <- b + 5 - let d = c - b <- a * 5 - something - c <- a + b - print c - rec something $ do - x <- a - print x - y <- c - print y - -trickyLet = do - foo - let x = 5 - in bar x - -f = unFoo . foo bar baz 3 $ do - act - ret - -g = unFoo - . foo - bar - baz - 3 - $ do - act - ret - -main = - do stuff - `finally` do - recover - -main = do stuff `finally` recover - -main = do { stuff } `finally` recover - -foo = do do { foo; bar }; baz - -foo = - do - 1 - + 2 - --- single line let-where -samples n f = do - gen <- newQCGen - let rands g = g1 : rands g2 where { (g1, g2) = split g } - return $ rands gen - -main = do bar - -main = do bar; baz - -main = do - bar - baz - -main = do - a <- bar - let a = b; c = d - baz d - let e = f - g = h - return c - -readInClause = do - do - lookAhead g_Do - parseNote ErrorC 1063 "You need a line feed or semicolon before the 'do'." - <|> do - optional g_Semi - void allspacing - return things diff --git a/data/examples/declaration/value/function/do.hs b/data/examples/declaration/value/function/do.hs deleted file mode 100644 index 7e3358c..0000000 --- a/data/examples/declaration/value/function/do.hs +++ /dev/null @@ -1,111 +0,0 @@ -{-# LANGUAGE RecursiveDo #-} - -bar = do { foo; bar } - -baz = - mdo bar a - a <- foo - b <- bar - 1 2 3 - return (a + b) - -baz = do - a <- foo - let b = a + 2 - c = b + 3 - bar c - let d = c + 2 - return d - -quux = something $ do - foo - case x of - 1 -> 10 - 2 -> 20 - bar - if something - then x - else y - baz - -foo = do - rec - a <- b + 5 - - let d = c - - b <- a * 5 - - something - - c <- a + b - print c - rec something $ do - x <- a - print x - - y <- c - print y - -trickyLet = do - foo - let x = 5 - in bar x - -f = unFoo . foo bar baz 3 $ do - act - ret - -g = unFoo . foo - bar - baz 3 $ do - act - ret - -main = - do stuff - `finally` do - recover - -main = do stuff `finally` recover - -main = do { stuff } `finally` recover - -foo = do { do {foo; bar}; baz } - -foo = do - 1 - + - 2 - --- single line let-where -samples n f = do - gen <- newQCGen - let rands g = g1 : rands g2 where (g1, g2) = split g - return $ rands gen - -main = do bar -main = do { bar; baz } -main = do { bar - ; baz - } - -main = do - a <- bar - let a = b; c = d - baz d - let e = f - g = h - return c - -readInClause = do - do { - lookAhead g_Do; - parseNote ErrorC 1063 "You need a line feed or semicolon before the 'do'."; - } <|> do { - optional g_Semi; - void allspacing; - } - - return things - diff --git a/data/examples/declaration/value/function/do/blocks-out.hs b/data/examples/declaration/value/function/do/blocks-out.hs new file mode 100644 index 0000000..199f9be --- /dev/null +++ b/data/examples/declaration/value/function/do/blocks-out.hs @@ -0,0 +1,18 @@ +foo = do bar + +foo = do bar; baz + +foo = do + bar + baz + +foo = do do { foo; bar }; baz + +readInClause = do + do + lookAhead g_Do + parseNote ErrorC 1063 "You need a line feed or semicolon before the 'do'." + <|> do + optional g_Semi + void allspacing + return things diff --git a/data/examples/declaration/value/function/do/blocks.hs b/data/examples/declaration/value/function/do/blocks.hs new file mode 100644 index 0000000..3eeb0e0 --- /dev/null +++ b/data/examples/declaration/value/function/do/blocks.hs @@ -0,0 +1,17 @@ +foo = do bar +foo = do { bar; baz } +foo = do { bar + ; baz + } +foo = do { do {foo; bar}; baz } + +readInClause = do + do { + lookAhead g_Do; + parseNote ErrorC 1063 "You need a line feed or semicolon before the 'do'."; + } <|> do { + optional g_Semi; + void allspacing; + } + + return things diff --git a/data/examples/declaration/value/function/do/expr-out.hs b/data/examples/declaration/value/function/do/expr-out.hs new file mode 100644 index 0000000..c6310f6 --- /dev/null +++ b/data/examples/declaration/value/function/do/expr-out.hs @@ -0,0 +1,10 @@ +quux = something $ do + foo + case x of + 1 -> 10 + 2 -> 20 + bar + if something + then x + else y + baz diff --git a/data/examples/declaration/value/function/do/expr.hs b/data/examples/declaration/value/function/do/expr.hs new file mode 100644 index 0000000..9025734 --- /dev/null +++ b/data/examples/declaration/value/function/do/expr.hs @@ -0,0 +1,11 @@ +quux = something $ do + foo + case x of + 1 -> 10 + 2 -> 20 + bar + if something + then x + else y + baz + diff --git a/data/examples/declaration/value/function/do/hanging-out.hs b/data/examples/declaration/value/function/do/hanging-out.hs new file mode 100644 index 0000000..e69de29 diff --git a/data/examples/declaration/value/function/do/hanging.hs b/data/examples/declaration/value/function/do/hanging.hs new file mode 100644 index 0000000..e69de29 diff --git a/data/examples/declaration/value/function/do/let-out.hs b/data/examples/declaration/value/function/do/let-out.hs new file mode 100644 index 0000000..1cd9d1e --- /dev/null +++ b/data/examples/declaration/value/function/do/let-out.hs @@ -0,0 +1,18 @@ +main = do + a <- bar + let a = b; c = d + baz d + let e = f + g = h + return c + +-- single line let-where +samples n f = do + gen <- newQCGen + let rands g = g1 : rands g2 where { (g1, g2) = split g } + return $ rands gen + +trickyLet = do + foo + let x = 5 + in bar x diff --git a/data/examples/declaration/value/function/do/let.hs b/data/examples/declaration/value/function/do/let.hs new file mode 100644 index 0000000..01d465e --- /dev/null +++ b/data/examples/declaration/value/function/do/let.hs @@ -0,0 +1,18 @@ +main = do + a <- bar + let a = b; c = d + baz d + let e = f + g = h + return c + +-- single line let-where +samples n f = do + gen <- newQCGen + let rands g = g1 : rands g2 where (g1, g2) = split g + return $ rands gen + +trickyLet = do + foo + let x = 5 + in bar x diff --git a/data/examples/declaration/value/function/do/recursive-do-mdo-out.hs b/data/examples/declaration/value/function/do/recursive-do-mdo-out.hs new file mode 100644 index 0000000..85e69b8 --- /dev/null +++ b/data/examples/declaration/value/function/do/recursive-do-mdo-out.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE RecursiveDo #-} + +baz = + mdo + bar a + a <- foo + b <- + bar + 1 + 2 + 3 + return (a + b) diff --git a/data/examples/declaration/value/function/do/recursive-do-mdo.hs b/data/examples/declaration/value/function/do/recursive-do-mdo.hs new file mode 100644 index 0000000..d9198fc --- /dev/null +++ b/data/examples/declaration/value/function/do/recursive-do-mdo.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE RecursiveDo #-} + +baz = + mdo bar a + a <- foo + b <- bar + 1 2 3 + return (a + b) diff --git a/data/examples/declaration/value/function/do/recursive-do-rec-out.hs b/data/examples/declaration/value/function/do/recursive-do-rec-out.hs new file mode 100644 index 0000000..300980d --- /dev/null +++ b/data/examples/declaration/value/function/do/recursive-do-rec-out.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE RecursiveDo #-} + +foo = do + rec a <- b + 5 + let d = c + b <- a * 5 + something + c <- a + b + print c + rec something $ do + x <- a + print x + y <- c + print y diff --git a/data/examples/declaration/value/function/do/recursive-do-rec.hs b/data/examples/declaration/value/function/do/recursive-do-rec.hs new file mode 100644 index 0000000..d6c70fa --- /dev/null +++ b/data/examples/declaration/value/function/do/recursive-do-rec.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE RecursiveDo #-} + +foo = do + rec + a <- b + 5 + + let d = c + + b <- a * 5 + + something + + c <- a + b + print c + rec something $ do + x <- a + print x + + y <- c + print y diff --git a/data/examples/declaration/value/function/guards-out.hs b/data/examples/declaration/value/function/guards-out.hs index 762228d..bd77908 100644 --- a/data/examples/declaration/value/function/guards-out.hs +++ b/data/examples/declaration/value/function/guards-out.hs @@ -1,18 +1,3 @@ -foo :: Int -> Int -foo x - | x == 5 = 10 - | otherwise = 12 - -bar :: Int -> Int -bar x - | x == 5 = - foo x - + foo 10 - | x == 6 = - foo x - + foo 20 - | otherwise = foo 100 - baz :: Int -> Int baz x | x < 0 = x baz x | otherwise = x diff --git a/data/examples/declaration/value/function/guards.hs b/data/examples/declaration/value/function/guards.hs index 212c2e1..bd77908 100644 --- a/data/examples/declaration/value/function/guards.hs +++ b/data/examples/declaration/value/function/guards.hs @@ -1,16 +1,3 @@ -foo :: Int -> Int -foo x - | x == 5 = 10 - | otherwise = 12 - -bar :: Int -> Int -bar x - | x == 5 = foo x - + foo 10 - | x == 6 = foo x - + foo 20 - | otherwise = foo 100 - baz :: Int -> Int baz x | x < 0 = x baz x | otherwise = x diff --git a/data/examples/declaration/value/function/infix/applicative-out.hs b/data/examples/declaration/value/function/infix/applicative-out.hs new file mode 100644 index 0000000..0e58cf9 --- /dev/null +++ b/data/examples/declaration/value/function/infix/applicative-out.hs @@ -0,0 +1,4 @@ +f = + Foo <$> bar + <*> baz + <*> baz' diff --git a/data/examples/declaration/value/function/infix/applicative.hs b/data/examples/declaration/value/function/infix/applicative.hs new file mode 100644 index 0000000..753af1e --- /dev/null +++ b/data/examples/declaration/value/function/infix/applicative.hs @@ -0,0 +1,6 @@ + +f = + Foo <$> bar + <*> baz + <*> baz' + diff --git a/data/examples/declaration/value/function/infix/comments-out.hs b/data/examples/declaration/value/function/infix/comments-out.hs new file mode 100644 index 0000000..1d0c33f --- /dev/null +++ b/data/examples/declaration/value/function/infix/comments-out.hs @@ -0,0 +1,9 @@ +main = + bar + $ baz -- bar + -- baz + +bar + $ {- foo + -} + bar diff --git a/data/examples/declaration/value/function/infix/comments.hs b/data/examples/declaration/value/function/infix/comments.hs new file mode 100644 index 0000000..12ea795 --- /dev/null +++ b/data/examples/declaration/value/function/infix/comments.hs @@ -0,0 +1,11 @@ +main = + bar $ -- bar + baz -- baz + +bar $ + {- foo + -} + bar + + + diff --git a/data/examples/declaration/value/function/infix/do-out.hs b/data/examples/declaration/value/function/infix/do-out.hs new file mode 100644 index 0000000..dc2e110 --- /dev/null +++ b/data/examples/declaration/value/function/infix/do-out.hs @@ -0,0 +1,13 @@ +main = + do stuff + `finally` do + recover + +main = do stuff `finally` recover + +main = do { stuff } `finally` recover + +foo = + do + 1 + + 2 diff --git a/data/examples/declaration/value/function/infix/do.hs b/data/examples/declaration/value/function/infix/do.hs new file mode 100644 index 0000000..cea11ee --- /dev/null +++ b/data/examples/declaration/value/function/infix/do.hs @@ -0,0 +1,13 @@ +main = + do stuff + `finally` do + recover + +main = do stuff `finally` recover + +main = do { stuff } `finally` recover + +foo = do + 1 + + + 2 diff --git a/data/examples/declaration/value/function/infix/hanging-out.hs b/data/examples/declaration/value/function/infix/hanging-out.hs new file mode 100644 index 0000000..072e12f --- /dev/null +++ b/data/examples/declaration/value/function/infix/hanging-out.hs @@ -0,0 +1,22 @@ +f = unFoo . foo bar baz 3 $ do + act + ret + +g = unFoo + . foo + bar + baz + 3 + $ do + act + ret + +update = + do + foobar + `catch` \case + a -> a + +foo = bar + ++ case foo of + a -> a diff --git a/data/examples/declaration/value/function/infix/hanging.hs b/data/examples/declaration/value/function/infix/hanging.hs new file mode 100644 index 0000000..75eacee --- /dev/null +++ b/data/examples/declaration/value/function/infix/hanging.hs @@ -0,0 +1,19 @@ +f = unFoo . foo bar baz 3 $ do + act + ret + +g = unFoo . foo + bar + baz 3 $ do + act + ret + +update = + do + foobar + `catch` \case + a -> a + +foo = bar ++ + case foo of + a -> a diff --git a/data/examples/declaration/value/function/infix/lenses-out.hs b/data/examples/declaration/value/function/infix/lenses-out.hs new file mode 100644 index 0000000..68c4fa1 --- /dev/null +++ b/data/examples/declaration/value/function/infix/lenses-out.hs @@ -0,0 +1,11 @@ +lenses = + Just $ M.fromList + $ "type" + .= ("user.connection" :: Text) + # "connection" + .= uc + # "user" + .= case name of + Just n -> Just $ object ["name" .= n] + Nothing -> Nothing + # [] diff --git a/data/examples/declaration/value/function/infix/lenses.hs b/data/examples/declaration/value/function/infix/lenses.hs new file mode 100644 index 0000000..5f63740 --- /dev/null +++ b/data/examples/declaration/value/function/infix/lenses.hs @@ -0,0 +1,7 @@ +lenses = Just $ M.fromList + $ "type" .= ("user.connection" :: Text) + # "connection" .= uc + # "user" .= case name of + Just n -> Just $ object ["name" .= n] + Nothing -> Nothing + # [] diff --git a/data/examples/declaration/value/function/infix-out.hs b/data/examples/declaration/value/function/infix/simple-out.hs similarity index 100% rename from data/examples/declaration/value/function/infix-out.hs rename to data/examples/declaration/value/function/infix/simple-out.hs diff --git a/data/examples/declaration/value/function/infix.hs b/data/examples/declaration/value/function/infix/simple.hs similarity index 100% rename from data/examples/declaration/value/function/infix.hs rename to data/examples/declaration/value/function/infix/simple.hs diff --git a/data/examples/declaration/value/function/lambda-multi-line1-out.hs b/data/examples/declaration/value/function/lambda-multi-line1-out.hs new file mode 100644 index 0000000..05308a9 --- /dev/null +++ b/data/examples/declaration/value/function/lambda-multi-line1-out.hs @@ -0,0 +1,14 @@ +foo :: a -> a -> a +foo x = \y -> + x + +bar :: Int -> Int -> Int +bar x = \y -> + if x > y + then 10 + else 12 + +foo = + prop "is inverse to closure" $ \(f :: StaticPtr (Int -> Int)) + (x :: Int) -> + (unclosure . closure) f x == deRefStaticPtr f x diff --git a/data/examples/declaration/value/function/lambda-multi-line1.hs b/data/examples/declaration/value/function/lambda-multi-line1.hs new file mode 100644 index 0000000..a9359fc --- /dev/null +++ b/data/examples/declaration/value/function/lambda-multi-line1.hs @@ -0,0 +1,15 @@ +foo :: a -> a -> a +foo x = \y -> + x + +bar :: Int -> Int -> Int +bar x = \y -> + if x > y + then 10 + else 12 + +foo = + prop "is inverse to closure" $ \(f :: StaticPtr (Int -> Int)) + (x :: Int) -> + (unclosure . closure) f x == deRefStaticPtr f x + diff --git a/data/examples/declaration/value/function/lambda-multi-line-out.hs b/data/examples/declaration/value/function/lambda-multi-line2-out.hs similarity index 54% rename from data/examples/declaration/value/function/lambda-multi-line-out.hs rename to data/examples/declaration/value/function/lambda-multi-line2-out.hs index a151d5a..ac82b75 100644 --- a/data/examples/declaration/value/function/lambda-multi-line-out.hs +++ b/data/examples/declaration/value/function/lambda-multi-line2-out.hs @@ -1,13 +1,3 @@ -foo :: a -> a -> a -foo x = \y -> - x - -bar :: Int -> Int -> Int -bar x = \y -> - if x > y - then 10 - else 12 - tricky0 = flip all (zip ws gs) $ \(wt, gt) -> canUnify poly_given_ok wt gt || go False wt gt @@ -20,8 +10,3 @@ tricky2 = flip all (zip ws gs) $ \(wt, gt) -> canUnify poly_given_ok wt gt || go False wt gt - -foo = - prop "is inverse to closure" $ \(f :: StaticPtr (Int -> Int)) - (x :: Int) -> - (unclosure . closure) f x == deRefStaticPtr f x diff --git a/data/examples/declaration/value/function/lambda-multi-line.hs b/data/examples/declaration/value/function/lambda-multi-line2.hs similarity index 51% rename from data/examples/declaration/value/function/lambda-multi-line.hs rename to data/examples/declaration/value/function/lambda-multi-line2.hs index dce0aea..b18066a 100644 --- a/data/examples/declaration/value/function/lambda-multi-line.hs +++ b/data/examples/declaration/value/function/lambda-multi-line2.hs @@ -1,13 +1,3 @@ -foo :: a -> a -> a -foo x = \y -> - x - -bar :: Int -> Int -> Int -bar x = \y -> - if x > y - then 10 - else 12 - tricky0 = flip all (zip ws gs) $ \(wt, gt) -> canUnify poly_given_ok wt gt || go False wt gt @@ -21,8 +11,3 @@ tricky2 = \(wt, gt) -> canUnify poly_given_ok wt gt || go False wt gt -foo = - prop "is inverse to closure" $ \(f :: StaticPtr (Int -> Int)) - (x :: Int) -> - (unclosure . closure) f x == deRefStaticPtr f x - diff --git a/data/examples/declaration/value/function/multiple-guards-out.hs b/data/examples/declaration/value/function/multiple-guards-out.hs new file mode 100644 index 0000000..ef57761 --- /dev/null +++ b/data/examples/declaration/value/function/multiple-guards-out.hs @@ -0,0 +1,14 @@ +foo :: Int -> Int +foo x + | x == 5 = 10 + | otherwise = 12 + +bar :: Int -> Int +bar x + | x == 5 = + foo x + + foo 10 + | x == 6 = + foo x + + foo 20 + | otherwise = foo 100 diff --git a/data/examples/declaration/value/function/multiple-guards.hs b/data/examples/declaration/value/function/multiple-guards.hs new file mode 100644 index 0000000..60307a9 --- /dev/null +++ b/data/examples/declaration/value/function/multiple-guards.hs @@ -0,0 +1,13 @@ +foo :: Int -> Int +foo x + | x == 5 = 10 + | otherwise = 12 + +bar :: Int -> Int +bar x + | x == 5 = foo x + + foo 10 + | x == 6 = foo x + + foo 20 + | otherwise = foo 100 + diff --git a/data/examples/declaration/value/function/operators-out.hs b/data/examples/declaration/value/function/operators-out.hs deleted file mode 100644 index a4ec721..0000000 --- a/data/examples/declaration/value/function/operators-out.hs +++ /dev/null @@ -1,45 +0,0 @@ -foo = bar - ++ case foo of - a -> a - -main = - bar - $ baz -- bar - -- baz - -bar - $ {- foo - -} - bar - -f = - Foo <$> bar - <*> baz - -update = - do - foobar - `catch` \case - a -> a - -foo = - do - 1 - + 2 - -main = - do stuff - `finally` do - recover - -lenses = - Just $ M.fromList - $ "type" - .= ("user.connection" :: Text) - # "connection" - .= uc - # "user" - .= case name of - Just n -> Just $ object ["name" .= n] - Nothing -> Nothing - # [] diff --git a/data/examples/declaration/value/function/operators.hs b/data/examples/declaration/value/function/operators.hs deleted file mode 100644 index a18a1c1..0000000 --- a/data/examples/declaration/value/function/operators.hs +++ /dev/null @@ -1,40 +0,0 @@ -foo = bar ++ - case foo of - a -> a - -main = - bar $ -- bar - baz -- baz - -bar $ - {- foo - -} - bar - -f = - Foo <$> bar - <*> baz - -update = - do - foobar - `catch` \case - a -> a - -foo = do - 1 - + - 2 - -main = - do stuff - `finally` do - recover - -lenses = Just $ M.fromList - $ "type" .= ("user.connection" :: Text) - # "connection" .= uc - # "user" .= case name of - Just n -> Just $ object ["name" .= n] - Nothing -> Nothing - # [] diff --git a/data/examples/declaration/value/function/parallel-comprehensions-out.hs b/data/examples/declaration/value/function/parallel-comprehensions-complex-out.hs similarity index 83% rename from data/examples/declaration/value/function/parallel-comprehensions-out.hs rename to data/examples/declaration/value/function/parallel-comprehensions-complex-out.hs index 51252ef..0593605 100644 --- a/data/examples/declaration/value/function/parallel-comprehensions-out.hs +++ b/data/examples/declaration/value/function/parallel-comprehensions-complex-out.hs @@ -1,7 +1,3 @@ -foo x y = [(a, b) | a <- x | b <- y] - -bar x y z w = [(a, b, c, d) | a <- x, b <- y, a `mod` b == 0 | c <- z | d <- w] - baz x y z w = [ ( a, b, diff --git a/data/examples/declaration/value/function/parallel-comprehensions.hs b/data/examples/declaration/value/function/parallel-comprehensions-complex.hs similarity index 89% rename from data/examples/declaration/value/function/parallel-comprehensions.hs rename to data/examples/declaration/value/function/parallel-comprehensions-complex.hs index e2b5cfb..528e61c 100644 --- a/data/examples/declaration/value/function/parallel-comprehensions.hs +++ b/data/examples/declaration/value/function/parallel-comprehensions-complex.hs @@ -1,7 +1,3 @@ -foo x y = [(a,b) | a<-x | b<-y] - -bar x y z w = [(a,b,c,d) | a<-x, b<-y, a`mod`b == 0|c<-z|d<-w ] - baz x y z w = [ (a,b,c,d,e, f,g,h,i,j) | diff --git a/data/examples/declaration/value/function/parallel-comprehensions-single-line-out.hs b/data/examples/declaration/value/function/parallel-comprehensions-single-line-out.hs new file mode 100644 index 0000000..70455c6 --- /dev/null +++ b/data/examples/declaration/value/function/parallel-comprehensions-single-line-out.hs @@ -0,0 +1,3 @@ +foo x y = [(a, b) | a <- x | b <- y] + +bar x y z w = [(a, b, c, d) | a <- x, b <- y, a `mod` b == 0 | c <- z | d <- w] diff --git a/data/examples/declaration/value/function/parallel-comprehensions-single-line.hs b/data/examples/declaration/value/function/parallel-comprehensions-single-line.hs new file mode 100644 index 0000000..7d646c7 --- /dev/null +++ b/data/examples/declaration/value/function/parallel-comprehensions-single-line.hs @@ -0,0 +1,4 @@ +foo x y = [(a,b) | a<-x | b<-y] + +bar x y z w = [(a,b,c,d) | a<-x, b<-y, a`mod`b == 0|c<-z|d<-w ] + diff --git a/data/examples/declaration/value/function/transform-comprehensions-out.hs b/data/examples/declaration/value/function/transform-comprehensions-out.hs deleted file mode 100644 index 3726658..0000000 --- a/data/examples/declaration/value/function/transform-comprehensions-out.hs +++ /dev/null @@ -1,58 +0,0 @@ -{-# LANGUAGE TransformListComp #-} - -foo xs ys = [(x, y) | x <- xs, y <- ys, then reverse] - -foo' xs ys = - [ ( x, - y - ) - | x <- xs, - y <- ys, - -- First comment - then reverse -- Second comment - ] - -bar xs ys = [(x, y) | x <- xs, y <- ys, then sortWith by (x + y)] - -bar' xs ys = - [ ( x, - y - ) - | x <- xs, - y <- ys, - -- First comment - then sortWith - by - ( x - + y -- Second comment - ) - ] - -baz xs ys = [(x, y) | x <- xs, y <- ys, then group using permutations] - -baz' xs ys = - [ ( x, - y - ) - | x <- xs, - y <- ys, - -- First comment - then group using permutations -- Second comment - ] - -quux xs ys = [(x, y) | x <- xs, y <- ys, then group by (x + y) using groupWith] - -quux' xs ys = - [ ( x, - y - ) - | x <- xs, - y <- ys, - -- First comment - then group by - ( x - + y - ) - -- Second comment - using groupWith -- Third comment - ] diff --git a/data/examples/declaration/value/function/transform-comprehensions.hs b/data/examples/declaration/value/function/transform-comprehensions.hs deleted file mode 100644 index 6b9e324..0000000 --- a/data/examples/declaration/value/function/transform-comprehensions.hs +++ /dev/null @@ -1,55 +0,0 @@ -{-# LANGUAGE TransformListComp #-} - -foo xs ys = [(x, y) | x <- xs, y <- ys, then reverse] - -foo' xs ys = [ - (x, - y) | - x <- xs, - y <- ys, - then -- First comment - reverse -- Second comment - ] - -bar xs ys = [(x, y) | x <- xs, y <- ys, then sortWith by (x + y)] - -bar' xs ys = [ - (x, - y) | - x <- xs, - y <- ys, - then -- First comment - sortWith - by - (x - + y) -- Second comment - ] - -baz xs ys = [(x, y) | x <- xs, y <- ys, then group using permutations] - -baz' xs ys = [ - (x, - y) | - x <- xs, - y <- ys, - then - group - using -- First comment - permutations -- Second comment - ] - -quux xs ys = [(x, y) | x <- xs, y <- ys, then group by (x + y) using groupWith] - -quux' xs ys = [ - (x, - y) | - x <- xs, - y <- ys, - then - group - by -- First comment - (x - + y) - using -- Second comment - groupWith -- Third comment - ]