-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaper.hs
More file actions
119 lines (95 loc) · 3.02 KB
/
Copy pathPaper.hs
File metadata and controls
119 lines (95 loc) · 3.02 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
module WebPage.Pubs.Paper where
-- * Representation
type Key = String
type Name = String
type Title = String
type URL = String
type Year = Int
data Kind = Journal | Chapter | Conference | Workshop | Thesis
| Report | Consortium | DraftPaper
deriving (Eq,Enum,Show)
data Status = Appeared | Accepted | Submitted | Draft
deriving (Eq,Enum,Show)
data Author = Author {
_firstName :: Name,
_middleName :: Maybe Name,
_lastName :: Name,
_suffix :: Maybe Name
} deriving (Eq,Show)
author :: Name -> Name -> Author
author first last = Author first Nothing last Nothing
data Pages = Pages Int Int
| PagesIn Int Int Int
deriving (Eq,Show)
-- ** Papers
data Paper = Paper {
_status :: Status,
_kind :: Kind,
_key :: Key,
_authors :: [Author],
_title :: Title,
_year :: Year,
_venue :: Maybe Venue,
_pages :: Maybe Pages,
_url :: Maybe URL,
_note :: Maybe String,
_codeLink :: Maybe String,
_dataLink :: Maybe String,
_bothLink :: Maybe String,
_pdfLink :: Maybe String,
_abstract :: Maybe String
} deriving (Eq,Show)
-- Minimum definition.
paper s k e a t y = Paper s k e a t y Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
draft = paper Draft DraftPaper
appeared = paper Appeared
accepted = paper Accepted
submitted = paper Submitted
journal = appeared Journal
chapter = appeared Chapter
conference = appeared Conference
workshop = appeared Workshop
thesis = appeared Thesis
isStatus :: Status -> Paper -> Bool
isStatus s p = s == _status p
isKind :: Kind -> Paper -> Bool
isKind k p = k == _kind p
ofKind :: Kind -> [Paper] -> [Paper]
ofKind = filter . isKind
ofKinds :: [Kind] -> [Paper] -> [Paper]
ofKinds ks = filter (\p -> any (flip isKind p) ks)
-- Optional field setters.
infix 3 @@
p @@ a = p { _venue = Just a }
onPages p a = p { _pages = Just a }
atURL p a = p { _url = Just a }
withNote p a = p { _note = Just a }
setCodeLink p a = p { _codeLink = Just a }
setDataLink p a = p { _dataLink = Just a }
setBothLink p a = p { _bothLink = Just a }
setPdfLink p a = p { _pdfLink = Just a }
setAbstract p a = p { _abstract = Just a }
-- ** Venues
data Venue = Venue {
_longName :: Name,
_shortName :: Maybe Name,
_issue :: Maybe Name,
_venueKind :: Maybe Name,
_publisher :: Maybe Name,
_editors :: Maybe [Author],
_volume :: Maybe Int,
_number :: Maybe Int,
_series :: Maybe (Name,Int)
} deriving (Eq,Show)
-- Minimum definition.
venue l = Venue l Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
short s l = venue l `setShortName` s
-- Optional field setters.
setShortName v a = v { _shortName = Just a }
setIssue v a = v { _issue = Just a }
setVenueKind v a = v { _venueKind = Just a }
setPublisher v a = v { _publisher = Just a }
setEditor v a = v { _editors = Just a }
setVolume v a = v { _volume = Just a }
setNumber v a = v { _number = Just a }
setSeries v a = v { _series = Just a }