-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.hs
40 lines (31 loc) · 1.11 KB
/
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
32
33
34
35
36
37
38
39
40
module Main where
import Amendment
import Control.Arrow.Unicode
import Control.Monad
import Data.Aeson.Encode.Pretty (encodePretty)
import qualified Data.ByteString.Lazy as B
import Data.Eq.Unicode
import Data.Function ((&))
import GHC.IO.Exception
import Cli
import Tika
main ∷ IO ()
main = do
(errCode, rawHTML, stderr') ← runTika =<< getOptions
when (errCode ≠ ExitSuccess)
(fail stderr')
B.putStr (tikaOutputToJson rawHTML)
tikaOutputToJson ∷ String → B.ByteString
tikaOutputToJson = paragraphs ⋙ makeAmendment ⋙ encodePretty
makeAmendment ∷ [String] → Amendment
makeAmendment phrases =
Amendment {
bill = phrases |> findCitation |> makeBill,
summary = phrases |> findSummary,
affectedSections = phrases |> findSummary |> findChangedStatutes,
year = phrases |> findYear,
effectiveDate = phrases |> findEffectiveDate,
chapter = phrases |> findChapter
}
-- Function application operator from Elm, F#, and Elixir
(|>) = (&)