summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/deSugar/should_run/dsrun018.hs
blob: d89f5b24f34d0b439d98542f25cb0bce77ab9813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- Test grouping with both a using and a by clause

{-# OPTIONS_GHC -XTransformListComp #-}

module Main where

import Data.List(groupBy)
import GHC.Exts(the)

groupRuns :: Eq b => (a -> b) -> [a] -> [[a]]
groupRuns f = groupBy (\x y -> f x == f y)

main = putStrLn (show output)
  where
    output = [ (the x, product y)
             | x <- ([1, 1, 1, 2, 2, 1, 3])
             , y <- [4..6]
             , then group by x using groupRuns ]