1
1
mirror of https://github.com/google/ormolu.git synced 2024-11-27 13:13:23 +03:00

Split large examples

There has been a lot of good intense work lately and as a result of that
some examples have grown considerably. The problem is that we do not show
diffs when something is not formatted as expected, we show entire
"expected/got" files. It works well when files are small, but not so well
where they are huge (some of our examples are well beyond 100 lines). It can
be hard to understand where the problem is.

This commit split long examples into smaller ones to make it easier to see
what went wrong when a test fails.
This commit is contained in:
Utku Demir 2019-08-19 15:01:39 +12:00 committed by Mark Karpov
parent 19deae563b
commit 9a1f5ebd87
136 changed files with 1184 additions and 1217 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,8 @@
-- | Something.
class Foo a where
-- | Foo
foo :: a -> String
default foo :: Show a => a -> String
foo = show

View File

@ -0,0 +1,7 @@
-- | Something.
class Foo a where
-- | Foo
foo :: a -> String
default foo :: Show a => a -> String
foo = show

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,19 @@
deriving instance
{-# OVERLAPPABLE #-}
Ord
Foo
deriving instance
{-# OVERLAPPING #-}
Num
Foo
deriving instance
{-# OVERLAPS #-}
Read
Foo
deriving instance
{-# INCOHERENT #-}
Show
Foo

View File

@ -0,0 +1,17 @@
deriving instance
{-# OVERLAPPABLE #-}
Ord
Foo
deriving instance
{-# OVERLAPPING #-}
Num
Foo
deriving instance
{-# OVERLAPS #-}
Read
Foo
deriving instance
{-# INCOHERENT #-}
Show
Foo

View File

@ -0,0 +1,18 @@
instance
( Read a, -- Foo
Read b,
Read
( c, -- Bar
d
)
)
=> Read
( a, -- Baz
b,
( c, -- Quux
d
)
)
where
readsPrec = undefined

View File

@ -0,0 +1,18 @@
instance (
Read a, -- Foo
Read b
, Read (
c, -- Bar
d
)
)
=>
Read (
a, -- Baz
b
,(
c, -- Quux
d
)
) where
readsPrec = undefined

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,7 @@
{-# LANGUAGE GADTSyntax #-}
{-# LANGUAGE TypeFamilies #-}
newtype instance Foo [Double]
= DoubleListFoo
{ unDoubleListFoo :: Double
}

View File

@ -0,0 +1,6 @@
{-# LANGUAGE GADTSyntax #-}
{-# LANGUAGE TypeFamilies #-}
newtype instance Foo [Double] = DoubleListFoo {
unDoubleListFoo :: Double
}

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,12 @@
{-# LANGUAGE InstanceSigs #-}
instance Applicative [] where
pure
:: a
-> [a]
pure a = [a]
(<*>)
:: [a] -> [a] -> [a]
(<*>) _ _ = []

View File

@ -0,0 +1,10 @@
{-# LANGUAGE InstanceSigs #-}
instance Applicative [] where
pure ::
a
-> [a]
pure a = [a]
(<*>)
:: [ a ] -> [ a ] -> [ a ]
(<*>) _ _ = []

View File

@ -15,14 +15,3 @@ instance Ord Int where
_
_ =
GT
instance Applicative [] where
pure
:: a
-> [a]
pure a = [a]
(<*>)
:: [a] -> [a] -> [a]
(<*>) _ _ = []

View File

@ -14,12 +14,3 @@ instance Ord Int where
_
_
= GT
instance Applicative [] where
pure ::
a
-> [a]
pure a = [a]
(<*>)
:: [ a ] -> [ a ] -> [ a ]
(<*>) _ _ = []

View File

@ -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
#-}

View File

@ -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
#-}

View File

@ -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

View File

@ -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

View File

@ -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
#-}

View File

@ -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
#-}

View File

@ -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
#-}

View File

@ -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
#-}

View File

@ -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
#-}

View File

@ -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
#-}

View File

@ -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
#-}

View File

@ -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
#-}

View File

@ -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

View File

@ -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
#-}

View File

@ -0,0 +1,15 @@
type role
D
phantom
nominal
type role
E
_
nominal
type role
E
_
nominal
phantom

View File

@ -0,0 +1,15 @@
type role
D phantom nominal
type
role
E
_
nominal
type
role
E
_
nominal
phantom

View File

@ -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

View File

@ -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

View File

@ -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)
|]
)

View File

@ -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)
|])

View File

@ -12,13 +12,6 @@ foo =
foo = [t|Char|]
foo =
[d|
foo :: Int -> Char
bar = 42
|]
foo =
[||
foo bar

View File

@ -8,10 +8,5 @@ foo = [e| foo bar
foo = [t| Char |]
foo = [d|
foo:: Int -> Char
bar = 42
|]
foo = [|| foo bar
||]

View File

@ -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)
|]
)

View File

@ -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)
|])

View File

@ -11,3 +11,11 @@ type Foo
= Bar
Baz
Quux
type API
= "route1" :> ApiRoute1
:<|> "route2"
:> ApiRoute2 -- comment here
:<|> OmitDocs
:> "i"
:> ASomething API

View File

@ -10,3 +10,11 @@ type Foo =
Bar
Baz
Quux
type API
= "route1" :> ApiRoute1
:<|> "route2" :> ApiRoute2 -- comment here
:<|> OmitDocs :> "i" :> ASomething API

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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-<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)

View File

@ -0,0 +1,18 @@
{-# 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
)
|)

View File

@ -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)
|)

View File

@ -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)

View File

@ -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-<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)

View File

@ -0,0 +1,9 @@
withGuards :: Int -> Int
withGuards x =
case x of
x
| x > 10 ->
foo
+ bar
x | x > 5 -> 10
_ -> 20

View File

@ -0,0 +1,9 @@
withGuards :: Int -> Int
withGuards x =
case x of
x | x > 10 ->
foo +
bar
x | x > 5 -> 10
_ -> 20

View File

@ -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

View File

@ -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
() -> ()

View File

@ -0,0 +1,11 @@
{-# LANGUAGE TransformListComp #-}
foo' xs ys =
[ ( x,
y
)
| x <- xs,
y <- ys,
-- First comment
then reverse -- Second comment
]

View File

@ -0,0 +1,10 @@
{-# LANGUAGE TransformListComp #-}
foo' xs ys = [
(x,
y) |
x <- xs,
y <- ys,
then -- First comment
reverse -- Second comment
]

View File

@ -0,0 +1,15 @@
{-# LANGUAGE TransformListComp #-}
bar' xs ys =
[ ( x,
y
)
| x <- xs,
y <- ys,
-- First comment
then sortWith
by
( x
+ y -- Second comment
)
]

View File

@ -0,0 +1,15 @@
{-# LANGUAGE TransformListComp #-}
bar' xs ys = [
(x,
y) |
x <- xs,
y <- ys,
then -- First comment
sortWith
by
(x
+ y) -- Second comment
]

View File

@ -0,0 +1,11 @@
{-# LANGUAGE TransformListComp #-}
baz' xs ys =
[ ( x,
y
)
| x <- xs,
y <- ys,
-- First comment
then group using permutations -- Second comment
]

View File

@ -0,0 +1,13 @@
{-# LANGUAGE TransformListComp #-}
baz' xs ys = [
(x,
y) |
x <- xs,
y <- ys,
then
group
using -- First comment
permutations -- Second comment
]

View File

@ -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
]

View File

@ -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
]

View File

@ -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]

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,10 @@
quux = something $ do
foo
case x of
1 -> 10
2 -> 20
bar
if something
then x
else y
baz

View File

@ -0,0 +1,11 @@
quux = something $ do
foo
case x of
1 -> 10
2 -> 20
bar
if something
then x
else y
baz

Some files were not shown because too many files have changed in this diff Show More