Implement TSV internally, remove the "csv" package dependency.
[match/match.git] / program / Main.hs
CommitLineData
bbabbd01
MM
1import PMInstance
2import PMDefaults
3import ProposalMatcher
4import System.IO
5import Data.Array.IArray
6import Data.Array.Unboxed
7import ArrayStuff
a70586aa 8import TSV
bbabbd01
MM
9
10-- Command-line interface with simple tab-separated input/output formats.
11-- ./match <example.in
12
bbabbd01
MM
13main = do
14 incsv <- hGetContents stdin
15 -- handle errors another day, or let the platform do it
a70586aa 16 let inll = parseTSV incsv
bbabbd01
MM
17 let loadList = head inll
18 let numRvrs = length loadList
19 let loadA = listArray (0, numRvrs-1) (map read loadList)
20 let numProps = length (tail inll)
21 -- explicit type on the next line appears to be necessary
22 let pxarr = listOfListsToArray2D (tail inll) :: Array (Int,Int) String
23 -- careful, we end up transposing the array in here
24 let prefA = funcArray ((0,0), (numRvrs-1,numProps-1)) (\(i,j) -> read (pxarr ! (j, i)))
25 let theInst = PMInstance numRvrs numProps loadA prefA
26 let PMatching theMatching = doMatching pmDefaults theInst
a70586aa 27 hPutStr stdout $ formatTSV $ map (\(i, j) -> map show [i, j]) theMatching