-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.hs
33 lines (23 loc) · 838 Bytes
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Main where
import BibTex
import Formats
import Search
import System.Environment (getArgs)
import Text.ParserCombinators.Parsec (parseFromFile)
import Control.Monad (mapM_)
main = do
args <- getArgs
let file = head args
filters = pairElements $ tail args
references <- parseFromFile bibliography file
case references of
Left err -> print err
Right refs -> mapM_ (printReference filters bibtexFormat)
$ refs `refMatching` filters
pairElements :: [a] -> [(a, a)]
pairElements xs = case xs of
(x : y : xs') -> (x, y) : (pairElements xs')
(x : []) -> []
_ -> []
printReference :: [Filter] -> RefFormatter -> Reference -> IO ()
printReference filters formatter = mapM_ putStrLn . (formatter filters)