Commit | Line | Data |
---|---|---|
bbabbd01 MM |
1 | import PMInstance |
2 | import PMDefaults | |
3 | import ProposalMatcher | |
4 | import System.IO | |
5 | import Data.Array.IArray | |
6 | import Data.Array.Unboxed | |
7 | import ArrayStuff | |
a70586aa | 8 | import TSV |
bbabbd01 MM |
9 | |
10 | -- Command-line interface with simple tab-separated input/output formats. | |
11 | -- ./match <example.in | |
12 | ||
bbabbd01 MM |
13 | main = 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 |