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:
parent
19deae563b
commit
9a1f5ebd87
14
data/examples/declaration/class/associated-data1-out.hs
Normal file
14
data/examples/declaration/class/associated-data1-out.hs
Normal 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
|
12
data/examples/declaration/class/associated-data1.hs
Normal file
12
data/examples/declaration/class/associated-data1.hs
Normal 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
|
@ -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
|
||||
|
@ -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
|
14
data/examples/declaration/class/associated-types1-out.hs
Normal file
14
data/examples/declaration/class/associated-types1-out.hs
Normal 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
|
12
data/examples/declaration/class/associated-types1.hs
Normal file
12
data/examples/declaration/class/associated-types1.hs
Normal 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
|
@ -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
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
-- | Something.
|
||||
class Foo a where
|
||||
|
||||
-- | Foo
|
||||
foo :: a -> String
|
||||
|
||||
default foo :: Show a => a -> String
|
||||
foo = show
|
@ -0,0 +1,7 @@
|
||||
-- | Something.
|
||||
class Foo a where
|
||||
-- | Foo
|
||||
foo :: a -> String
|
||||
default foo :: Show a => a -> String
|
||||
foo = show
|
||||
|
@ -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
|
||||
|
17
data/examples/declaration/class/multi-parameters1-out.hs
Normal file
17
data/examples/declaration/class/multi-parameters1-out.hs
Normal 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
|
18
data/examples/declaration/class/multi-parameters1.hs
Normal file
18
data/examples/declaration/class/multi-parameters1.hs
Normal 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
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
||||
|
||||
|
21
data/examples/declaration/class/type-operators1-out.hs
Normal file
21
data/examples/declaration/class/type-operators1-out.hs
Normal 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
|
19
data/examples/declaration/class/type-operators1.hs
Normal file
19
data/examples/declaration/class/type-operators1.hs
Normal 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
|
16
data/examples/declaration/class/type-operators2-out.hs
Normal file
16
data/examples/declaration/class/type-operators2-out.hs
Normal 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
|
16
data/examples/declaration/class/type-operators2.hs
Normal file
16
data/examples/declaration/class/type-operators2.hs
Normal 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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
19
data/examples/declaration/deriving/overlapping-out.hs
Normal file
19
data/examples/declaration/deriving/overlapping-out.hs
Normal 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
|
17
data/examples/declaration/deriving/overlapping.hs
Normal file
17
data/examples/declaration/deriving/overlapping.hs
Normal 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
|
||||
|
18
data/examples/declaration/instance/contexts-comments-out.hs
Normal file
18
data/examples/declaration/instance/contexts-comments-out.hs
Normal 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
|
18
data/examples/declaration/instance/contexts-comments.hs
Normal file
18
data/examples/declaration/instance/contexts-comments.hs
Normal 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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
@ -0,0 +1,7 @@
|
||||
{-# LANGUAGE GADTSyntax #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
||||
newtype instance Foo [Double]
|
||||
= DoubleListFoo
|
||||
{ unDoubleListFoo :: Double
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{-# LANGUAGE GADTSyntax #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
newtype instance Foo [Double] = DoubleListFoo {
|
||||
unDoubleListFoo :: Double
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -0,0 +1,12 @@
|
||||
{-# LANGUAGE InstanceSigs #-}
|
||||
|
||||
instance Applicative [] where
|
||||
|
||||
pure
|
||||
:: a
|
||||
-> [a]
|
||||
pure a = [a]
|
||||
|
||||
(<*>)
|
||||
:: [a] -> [a] -> [a]
|
||||
(<*>) _ _ = []
|
10
data/examples/declaration/instance/instance-sigs-multiple.hs
Normal file
10
data/examples/declaration/instance/instance-sigs-multiple.hs
Normal file
@ -0,0 +1,10 @@
|
||||
{-# LANGUAGE InstanceSigs #-}
|
||||
|
||||
instance Applicative [] where
|
||||
pure ::
|
||||
a
|
||||
-> [a]
|
||||
pure a = [a]
|
||||
(<*>)
|
||||
:: [ a ] -> [ a ] -> [ a ]
|
||||
(<*>) _ _ = []
|
@ -15,14 +15,3 @@ instance Ord Int where
|
||||
_
|
||||
_ =
|
||||
GT
|
||||
|
||||
instance Applicative [] where
|
||||
|
||||
pure
|
||||
:: a
|
||||
-> [a]
|
||||
pure a = [a]
|
||||
|
||||
(<*>)
|
||||
:: [a] -> [a] -> [a]
|
||||
(<*>) _ _ = []
|
||||
|
@ -14,12 +14,3 @@ instance Ord Int where
|
||||
_
|
||||
_
|
||||
= GT
|
||||
|
||||
instance Applicative [] where
|
||||
pure ::
|
||||
a
|
||||
-> [a]
|
||||
pure a = [a]
|
||||
(<*>)
|
||||
:: [ a ] -> [ a ] -> [ a ]
|
||||
(<*>) _ _ = []
|
||||
|
18
data/examples/declaration/rewrite-rule/basic1-out.hs
Normal file
18
data/examples/declaration/rewrite-rule/basic1-out.hs
Normal 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
|
||||
#-}
|
17
data/examples/declaration/rewrite-rule/basic1.hs
Normal file
17
data/examples/declaration/rewrite-rule/basic1.hs
Normal 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
|
||||
#-}
|
||||
|
@ -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
|
@ -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
|
@ -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
|
||||
#-}
|
@ -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
|
||||
#-}
|
18
data/examples/declaration/rewrite-rule/prelude1-out.hs
Normal file
18
data/examples/declaration/rewrite-rule/prelude1-out.hs
Normal 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
|
||||
#-}
|
17
data/examples/declaration/rewrite-rule/prelude1.hs
Normal file
17
data/examples/declaration/rewrite-rule/prelude1.hs
Normal 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
|
||||
#-}
|
||||
|
30
data/examples/declaration/rewrite-rule/prelude2-out.hs
Normal file
30
data/examples/declaration/rewrite-rule/prelude2-out.hs
Normal 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
|
||||
#-}
|
30
data/examples/declaration/rewrite-rule/prelude2.hs
Normal file
30
data/examples/declaration/rewrite-rule/prelude2.hs
Normal 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
|
||||
#-}
|
||||
|
10
data/examples/declaration/rewrite-rule/prelude3-out.hs
Normal file
10
data/examples/declaration/rewrite-rule/prelude3-out.hs
Normal 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
|
||||
#-}
|
10
data/examples/declaration/rewrite-rule/prelude3.hs
Normal file
10
data/examples/declaration/rewrite-rule/prelude3.hs
Normal 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
|
||||
#-}
|
7
data/examples/declaration/rewrite-rule/prelude4-out.hs
Normal file
7
data/examples/declaration/rewrite-rule/prelude4-out.hs
Normal 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
|
9
data/examples/declaration/rewrite-rule/prelude4.hs
Normal file
9
data/examples/declaration/rewrite-rule/prelude4.hs
Normal 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
|
||||
|
||||
#-}
|
15
data/examples/declaration/role-annotation/multi-line-out.hs
Normal file
15
data/examples/declaration/role-annotation/multi-line-out.hs
Normal file
@ -0,0 +1,15 @@
|
||||
type role
|
||||
D
|
||||
phantom
|
||||
nominal
|
||||
|
||||
type role
|
||||
E
|
||||
_
|
||||
nominal
|
||||
|
||||
type role
|
||||
E
|
||||
_
|
||||
nominal
|
||||
phantom
|
15
data/examples/declaration/role-annotation/multi-line.hs
Normal file
15
data/examples/declaration/role-annotation/multi-line.hs
Normal file
@ -0,0 +1,15 @@
|
||||
type role
|
||||
D phantom nominal
|
||||
|
||||
type
|
||||
role
|
||||
E
|
||||
_
|
||||
nominal
|
||||
|
||||
type
|
||||
role
|
||||
E
|
||||
_
|
||||
nominal
|
||||
phantom
|
@ -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
|
@ -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
|
26
data/examples/declaration/splice/bracket-declaration-out.hs
Normal file
26
data/examples/declaration/splice/bracket-declaration-out.hs
Normal 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)
|
||||
|]
|
||||
)
|
22
data/examples/declaration/splice/bracket-declaration.hs
Normal file
22
data/examples/declaration/splice/bracket-declaration.hs
Normal 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)
|
||||
|])
|
@ -12,13 +12,6 @@ foo =
|
||||
|
||||
foo = [t|Char|]
|
||||
|
||||
foo =
|
||||
[d|
|
||||
foo :: Int -> Char
|
||||
|
||||
bar = 42
|
||||
|]
|
||||
|
||||
foo =
|
||||
[||
|
||||
foo bar
|
||||
|
@ -8,10 +8,5 @@ foo = [e| foo bar
|
||||
|
||||
foo = [t| Char |]
|
||||
|
||||
foo = [d|
|
||||
foo:: Int -> Char
|
||||
bar = 42
|
||||
|]
|
||||
|
||||
foo = [|| foo bar
|
||||
||]
|
||||
|
@ -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)
|
||||
|]
|
||||
)
|
||||
|
@ -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)
|
||||
|])
|
||||
|
||||
|
@ -11,3 +11,11 @@ type Foo
|
||||
= Bar
|
||||
Baz
|
||||
Quux
|
||||
|
||||
type API
|
||||
= "route1" :> ApiRoute1
|
||||
:<|> "route2"
|
||||
:> ApiRoute2 -- comment here
|
||||
:<|> OmitDocs
|
||||
:> "i"
|
||||
:> ASomething API
|
||||
|
@ -10,3 +10,11 @@ type Foo =
|
||||
Bar
|
||||
Baz
|
||||
Quux
|
||||
|
||||
type API
|
||||
= "route1" :> ApiRoute1
|
||||
:<|> "route2" :> ApiRoute2 -- comment here
|
||||
:<|> OmitDocs :> "i" :> ASomething API
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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
|
@ -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
|
@ -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)
|
@ -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)
|
@ -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
|
||||
)
|
||||
|)
|
@ -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)
|
||||
|)
|
||||
|
@ -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)
|
@ -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)
|
@ -0,0 +1,9 @@
|
||||
withGuards :: Int -> Int
|
||||
withGuards x =
|
||||
case x of
|
||||
x
|
||||
| x > 10 ->
|
||||
foo
|
||||
+ bar
|
||||
x | x > 5 -> 10
|
||||
_ -> 20
|
@ -0,0 +1,9 @@
|
||||
withGuards :: Int -> Int
|
||||
withGuards x =
|
||||
case x of
|
||||
x | x > 10 ->
|
||||
foo +
|
||||
bar
|
||||
x | x > 5 -> 10
|
||||
_ -> 20
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
() -> ()
|
||||
|
@ -0,0 +1,11 @@
|
||||
{-# LANGUAGE TransformListComp #-}
|
||||
|
||||
foo' xs ys =
|
||||
[ ( x,
|
||||
y
|
||||
)
|
||||
| x <- xs,
|
||||
y <- ys,
|
||||
-- First comment
|
||||
then reverse -- Second comment
|
||||
]
|
@ -0,0 +1,10 @@
|
||||
{-# LANGUAGE TransformListComp #-}
|
||||
|
||||
foo' xs ys = [
|
||||
(x,
|
||||
y) |
|
||||
x <- xs,
|
||||
y <- ys,
|
||||
then -- First comment
|
||||
reverse -- Second comment
|
||||
]
|
@ -0,0 +1,15 @@
|
||||
{-# LANGUAGE TransformListComp #-}
|
||||
|
||||
bar' xs ys =
|
||||
[ ( x,
|
||||
y
|
||||
)
|
||||
| x <- xs,
|
||||
y <- ys,
|
||||
-- First comment
|
||||
then sortWith
|
||||
by
|
||||
( x
|
||||
+ y -- Second comment
|
||||
)
|
||||
]
|
@ -0,0 +1,15 @@
|
||||
{-# LANGUAGE TransformListComp #-}
|
||||
|
||||
bar' xs ys = [
|
||||
(x,
|
||||
y) |
|
||||
x <- xs,
|
||||
y <- ys,
|
||||
then -- First comment
|
||||
sortWith
|
||||
by
|
||||
(x
|
||||
+ y) -- Second comment
|
||||
]
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
{-# LANGUAGE TransformListComp #-}
|
||||
|
||||
baz' xs ys =
|
||||
[ ( x,
|
||||
y
|
||||
)
|
||||
| x <- xs,
|
||||
y <- ys,
|
||||
-- First comment
|
||||
then group using permutations -- Second comment
|
||||
]
|
@ -0,0 +1,13 @@
|
||||
{-# LANGUAGE TransformListComp #-}
|
||||
|
||||
baz' xs ys = [
|
||||
(x,
|
||||
y) |
|
||||
x <- xs,
|
||||
y <- ys,
|
||||
then
|
||||
group
|
||||
using -- First comment
|
||||
permutations -- Second comment
|
||||
]
|
||||
|
@ -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
|
||||
]
|
@ -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
|
||||
]
|
@ -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]
|
@ -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]
|
@ -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
|
@ -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
|
||||
|
18
data/examples/declaration/value/function/do/blocks-out.hs
Normal file
18
data/examples/declaration/value/function/do/blocks-out.hs
Normal 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
|
17
data/examples/declaration/value/function/do/blocks.hs
Normal file
17
data/examples/declaration/value/function/do/blocks.hs
Normal 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
|
10
data/examples/declaration/value/function/do/expr-out.hs
Normal file
10
data/examples/declaration/value/function/do/expr-out.hs
Normal file
@ -0,0 +1,10 @@
|
||||
quux = something $ do
|
||||
foo
|
||||
case x of
|
||||
1 -> 10
|
||||
2 -> 20
|
||||
bar
|
||||
if something
|
||||
then x
|
||||
else y
|
||||
baz
|
11
data/examples/declaration/value/function/do/expr.hs
Normal file
11
data/examples/declaration/value/function/do/expr.hs
Normal 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
Loading…
Reference in New Issue
Block a user