Commit 43e7140a authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Update test suite following the removal of the default grouping

clause from the SQL-like comprehension notation
parent ad357819
-- Tests grouping WITH a by clause but WITHOUT a using clause
-- Tests grouping WITH a by clause
{-# OPTIONS_GHC -XTransformListComp #-}
module Main where
import GHC.Exts(the)
import GHC.Exts(the,groupWith)
main = putStrLn (show output)
where
output = [ (the dept, sum salary, name)
| (dept, salary, name) <- [("A", 1, "Bob"), ("B", 2, "Fred"), ("A", 5, "Jim"), ("A", 9, "Jim")]
, then group by dept ]
\ No newline at end of file
, then group by dept using groupWith ]
\ No newline at end of file
......@@ -4,7 +4,7 @@
module Main where
import GHC.Exts(sortWith, the)
import GHC.Exts(sortWith, the, groupWith)
employees = [ ("Simon", "MS", 80)
, ("Erik", "MS", 100)
......@@ -16,7 +16,7 @@ main = putStrLn (show can_still_use_group_function) >> putStrLn (show output)
where
output = [ (the dept, map sum salary, (show x) ++ " and " ++ (show y))
| (name, dept, salary) <- employees
, then group by dept
, then group by dept using groupWith
, x <- [1, 2, 3]
, y <- [4, 5, 6]
, then sortWith by sum salary
......
......@@ -4,7 +4,7 @@
module Main where
import GHC.Exts(sortWith, the)
import GHC.Exts(sortWith, the, groupWith)
employees = [ ("Simon", "MS", 80)
, ("Erik", "MS", 100)
......@@ -16,7 +16,7 @@ main = putStrLn (show can_still_use_group_function) >> putStrLn (show output)
where
output = [ (the dept, map sum salary, (show x) ++ " and " ++ (show y))
| (name, dept, salary) <- employees
, then group by dept
, then group by dept using groupWith
, x <- [1, 2, 3]
, y <- [4, 5, 6]
, then sortWith by sum salary
......
-- Tests grouping WITH a by clause but WITHOUT a using clause
-- Tests grouping WITH a by clause
{-# OPTIONS_GHC -XMonadComprehensions -XTransformListComp #-}
module Main where
import GHC.Exts(the)
import GHC.Exts(the, groupWith)
main = putStrLn (show output)
where
output = [ (the dept, sum salary, name)
| (dept, salary, name) <- [("A", 1, "Bob"), ("B", 2, "Fred"), ("A", 5, "Jim"), ("A", 9, "Jim")]
, then group by dept ]
, then group by dept using groupWith]
......@@ -9,7 +9,7 @@ foo = [ ()
| x <- [1..10]
, then take 5
, then sortWith by x
, then group by x
, then group by x using groupWith
, then group using inits
, then group by x using groupWith
]
......
......@@ -9,7 +9,7 @@ foo = [ ()
| x <- [1..10]
, then take 5
, then sortWith by x
, then group by x
, then group by x using groupWith
, then group using inits
, then group by x using groupWith
]
......
......@@ -7,7 +7,7 @@ import GHC.Exts
foo = [ ()
| x <- [1..10]
, then group by x
, then group by x using groupWith
, then group by x using groupWith
, then group using inits
]
......
......@@ -7,6 +7,8 @@ readFail043.hs:10:20: Not in scope: `by'
readFail043.hs:10:23: Not in scope: `x'
readFail043.hs:10:25: Not in scope: `using'
readFail043.hs:11:9:
Unexpected transform statement in a list comprehension
Use -XTransformListComp
......
......@@ -2,13 +2,15 @@
module T3901 where
import GHC.Exts (groupWith)
data Rec = Rec {a :: Int} deriving (Show)
recs1 = [a | Rec {a=a} <- [Rec 1], then group by a]
recs1 = [a | Rec {a=a} <- [Rec 1], then group by a using groupWith]
recs2 = [a | Rec {a} <- [Rec 1], then group by a]
recs2 = [a | Rec {a} <- [Rec 1], then group by a using groupWith]
recs3 = [a | Rec {..} <- [Rec 1], then group by a]
recs3 = [a | Rec {..} <- [Rec 1], then group by a using groupWith]
recs4 :: [[Int]]
recs4 = [a | Rec {..} <- [Rec 1], then group by a]
recs4 = [a | Rec {..} <- [Rec 1], then group by a using groupWith]
......@@ -2,13 +2,15 @@
module T3901 where
import GHC.Exts (groupWith)
data Rec = Rec {a :: Int} deriving (Show)
recs1 = [a | Rec {a=a} <- [Rec 1], then group by a]
recs1 = [a | Rec {a=a} <- [Rec 1], then group by a using groupWith]
recs2 = [a | Rec {a} <- [Rec 1], then group by a]
recs2 = [a | Rec {a} <- [Rec 1], then group by a using groupWith]
recs3 = [a | Rec {..} <- [Rec 1], then group by a]
recs3 = [a | Rec {..} <- [Rec 1], then group by a using groupWith]
recs4 :: [[Int]]
recs4 = [a | Rec {..} <- [Rec 1], then group by a]
recs4 = [a | Rec {..} <- [Rec 1], then group by a using groupWith]
......@@ -27,7 +27,6 @@ import Control.Exception.Base
import Control.Monad
import Control.Monad.Fix
import Control.Monad.Group
import Control.Monad.Instances
import Control.Monad.Zip
......
-- Checks that the ordering constraint on the implicit groupWith is respected
-- Checks that the ordering constraint on the groupWith function is respected
{-# OPTIONS_GHC -XMonadComprehensions -XTransformListComp #-}
module ShouldFail where
import GHC.Exts (groupWith)
data Unorderable = Gnorf | Pinky | Brain
foo = [ ()
| x <- [Gnorf, Brain]
, then group by x
, then group by x using groupWith
]
mc20.hs:12:9:
mc20.hs:14:31:
No instance for (Ord Unorderable)
arising from a use of `Control.Monad.Group.mgroupWith'
arising from a use of `groupWith'
Possible fix: add an instance declaration for (Ord Unorderable)
In the expression: Control.Monad.Group.mgroupWith
In a stmt of a monad comprehension: then group by x
In the expression: [() | x <- [Gnorf, Brain], then group by x]
In the expression: groupWith
In a stmt of a monad comprehension: then group by x using groupWith
In the expression:
[() | x <- [Gnorf, Brain], then group by x using groupWith]
-- Checks that the ordering constraint on the implicit groupWith is respected
-- Checks that the ordering constraint on the groupWith function is respected
{-# OPTIONS_GHC -XTransformListComp #-}
module ShouldFail where
import GHC.Exts (groupWith)
data Unorderable = Gnorf | Pinky | Brain
foo = [ ()
| x <- [Gnorf, Brain]
, then group by x
, then group by x using groupWith
]
tcfail190.hs:12:9:
tcfail190.hs:14:31:
No instance for (Ord Unorderable)
arising from a use of `Control.Monad.Group.mgroupWith'
arising from a use of `groupWith'
Possible fix: add an instance declaration for (Ord Unorderable)
In the expression: Control.Monad.Group.mgroupWith
In a stmt of a list comprehension: then group by x
In the expression: [() | x <- [Gnorf, Brain], then group by x]
In the expression: groupWith
In a stmt of a list comprehension: then group by x using groupWith
In the expression:
[() | x <- [Gnorf, Brain], then group by x using groupWith]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment