summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_run/mc06.hs
blob: 20fe041283cff44a1f3c62985339f74f35f9eb93 (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 -XMonadComprehensions -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 ]