1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-- Transformation stress test
{-# OPTIONS_GHC -XTransformListComp #-}
module Main where
import Data.List(takeWhile)
import GHC.Exts(sortWith)
employees = [ ("Simon", "MS", 80)
, ("Erik", "MS", 100)
, ("Phil", "Ed", 40)
, ("Gordon", "Ed", 45)
, ("Paul", "Yale", 60)]
main = putStrLn (show output)
where
output = [ (dept, salary)
| (name, dept, salary) <- employees
, then sortWith by salary
, then filter by salary > 50
, then take 1 ]
|