By | fr33domlover |
At | 2015-12-21 |
Title | use unqualified import, Text looks nicer than T.Text |
Description |
Edit file src/FunBot/ExtEvents.hs 33188 → 33188
29 29 , ExtEvent (..)
30 30 )
31 31 where
32 32 33 33 import Control.Applicative
- 34 --import Control.Monad (mzero)
35 34 import Data.Aeson
36 35 import Data.Aeson.Types (Parser, typeMismatch)
- 37 - 38 import qualified Data.Text as T
+ 36 import Data.Text (Text)
39 37 40 38 {-data Repository = Repository
- 41 { repoName :: T.Text
- 42 , repoSpace :: T.Text
- 43 , repoHost :: T.Text
+ 39 { repoName :: Text
+ 40 , repoSpace :: Text
+ 41 , repoHost :: Text
44 42 }-}
45 43 46 44 data Branch = Branch
- 47 { branchName :: T.Text
- 48 , branchRepo :: T.Text
- 49 , branchRepoOwner :: T.Text
+ 45 { branchName :: Text
+ 46 , branchRepo :: Text
+ 47 , branchRepoOwner :: Text
50 48 }
51 49 deriving Show
52 50 53 51 instance FromJSON Branch where
54 52 parseJSON (Object o) =
… … … … 64 62 , "repo" .= repo
65 63 , "user" .= owner
66 64 ]
67 65 68 66 data Commit = Commit
- 69 { commitAuthor :: T.Text
- 70 , commitTitle :: T.Text
- 71 , commitUrl :: T.Text
- 72 , commitAdded :: [T.Text]
- 73 , commitModified :: [T.Text]
- 74 , commitRemoved :: [T.Text]
+ 67 { commitAuthor :: Text
+ 68 , commitTitle :: Text
+ 69 , commitUrl :: Text
+ 70 , commitAdded :: [Text]
+ 71 , commitModified :: [Text]
+ 72 , commitRemoved :: [Text]
75 73 }
76 74 deriving Show
77 75 78 76 instance FromJSON Commit where
79 77 parseJSON (Object o) =
… … … … 114 112 [ "branch" .= branch
115 113 , "commits" .= commits
116 114 ]
117 115 118 116 data Tag = Tag
- 119 { tagAuthor :: T.Text
- 120 , tagRef :: T.Text
- 121 , tagRepo :: T.Text
- 122 , tagRepoOwner :: T.Text
+ 117 { tagAuthor :: Text
+ 118 , tagRef :: Text
+ 119 , tagRepo :: Text
+ 120 , tagRepoOwner :: Text
123 121 }
124 122 deriving Show
125 123 126 124 instance FromJSON Tag where
127 125 parseJSON (Object o) =
… … … … 139 137 , "repo" .= tagRepo tag
140 138 , "user" .= tagRepoOwner tag
141 139 ]
142 140 143 141 data Issue = Issue
- 144 { issueAuthor :: T.Text
+ 142 { issueAuthor :: Text
145 143 , issueId :: Int
- 146 , issueRepo :: T.Text
- 147 , issueRepoOwner :: T.Text
- 148 , issueTitle :: T.Text
- 149 , issueUrl :: T.Text
- 150 , issueAction :: T.Text
+ 144 , issueRepo :: Text
+ 145 , issueRepoOwner :: Text
+ 146 , issueTitle :: Text
+ 147 , issueUrl :: Text
+ 148 , issueAction :: Text
151 149 }
152 150 deriving Show
153 151 154 152 instance FromJSON Issue where
155 153 parseJSON (Object o) =
… … … … 173 171 , "url" .= issueUrl issue
174 172 , "action" .= issueAction issue
175 173 ]
176 174 177 175 data Note = Note
- 178 { noteAuthor :: T.Text
- 179 , noteRepo :: T.Text
- 180 , noteRepoOwner :: T.Text
- 181 , noteContent :: T.Text
- 182 , noteTarget :: T.Text
- 183 , noteUrl :: T.Text
+ 176 { noteAuthor :: Text
+ 177 , noteRepo :: Text
+ 178 , noteRepoOwner :: Text
+ 179 , noteContent :: Text
+ 180 , noteTarget :: Text
+ 181 , noteUrl :: Text
184 182 }
185 183 deriving Show
186 184 187 185 instance FromJSON Note where
188 186 parseJSON (Object o) =
… … … … 204 202 , "target" .= target
205 203 , "url" .= url
206 204 ]
207 205 208 206 data MergeRequest = MergeRequest
- 209 { mrAuthor :: T.Text
+ 207 { mrAuthor :: Text
210 208 , mrId :: Int
- 211 , mrRepo :: T.Text
- 212 , mrRepoOwner :: T.Text
- 213 , mrTitle :: T.Text
- 214 , mrUrl :: T.Text
- 215 , mrAction :: T.Text
+ 209 , mrRepo :: Text
+ 210 , mrRepoOwner :: Text
+ 211 , mrTitle :: Text
+ 212 , mrUrl :: Text
+ 213 , mrAction :: Text
216 214 }
217 215 deriving Show
218 216 219 217 instance FromJSON MergeRequest where
220 218 parseJSON (Object o) =
… … … … 238 236 , "url" .= mrUrl mr
239 237 , "action" .= mrAction mr
240 238 ]
241 239 242 240 data NewsItem = NewsItem
- 243 { itemFeedLabel :: T.Text
- 244 , itemFeedTitle :: Maybe T.Text
- 245 , itemTitle :: T.Text
- 246 , itemAuthor :: Maybe T.Text
- 247 , itemUrl :: Maybe T.Text
+ 241 { itemFeedLabel :: Text
+ 242 , itemFeedTitle :: Maybe Text
+ 243 , itemTitle :: Text
+ 244 , itemAuthor :: Maybe Text
+ 245 , itemUrl :: Maybe Text
248 246 }
249 247 deriving Show
250 248 251 249 instance FromJSON NewsItem where
252 250 parseJSON (Object o) =
… … … … 266 264 , "author" .= author
267 265 , "url" .= url
268 266 ]
269 267 270 268 data Paste = Paste
- 271 { pasteAuthor :: T.Text
- 272 , pasteVerb :: T.Text
- 273 , pasteTitle :: T.Text
- 274 , pasteUrl :: T.Text
- 275 , pasteChannel :: T.Text
+ 269 { pasteAuthor :: Text
+ 270 , pasteVerb :: Text
+ 271 , pasteTitle :: Text
+ 272 , pasteUrl :: Text
+ 273 , pasteChannel :: Text
276 274 }
277 275 deriving Show
278 276 279 277 instance FromJSON Paste where
280 278 parseJSON (Object o) =
… … … … 310 308 -- | New news item published.
311 309 | NewsEvent NewsItem
312 310 -- | Paste related event in a paste server.
313 311 | PasteEvent Paste
314 312 -- | A new IRC user needs to be welcomed to a channel.
- 315 | WelcomeEvent T.Text T.Text
+ 313 | WelcomeEvent Text Text
316 314 deriving Show
317 315 - 318 text :: Parser T.Text -> T.Text -> Parser T.Text
+ 316 text :: Parser Text -> Text -> Parser Text
319 317 text parser expected = do
320 318 got <- parser
321 319 if got == expected
322 320 then return got
323 321 else empty
… … … … 332 330 kind "news" *> (NewsEvent <$> o .: "data") <|>
333 331 kind "paste" *> (PasteEvent <$> o .: "data")
334 332 parseJSON v = typeMismatch "ExtEvent" v
335 333 336 334 instance ToJSON ExtEvent where
- 337 toJSON (GitPushEvent commits) = object [ "type" .= ("push" :: T.Text)
+ 335 toJSON (GitPushEvent commits) = object [ "type" .= ("push" :: Text)
338 336 , "data" .= commits
339 337 ]
- 340 toJSON (GitTagEvent tag) = object [ "type" .= ("tag" :: T.Text)
+ 338 toJSON (GitTagEvent tag) = object [ "type" .= ("tag" :: Text)
341 339 , "data" .= tag
342 340 ]
- 343 toJSON (IssueEvent issue) = object [ "type" .= ("issue" :: T.Text)
+ 341 toJSON (IssueEvent issue) = object [ "type" .= ("issue" :: Text)
344 342 , "data" .= issue
345 343 ]
- 346 toJSON (MergeRequestEvent mr) = object [ "type" .= ("mr" :: T.Text)
+ 344 toJSON (MergeRequestEvent mr) = object [ "type" .= ("mr" :: Text)
347 345 , "data" .= mr
348 346 ]
- 349 toJSON (NoteEvent note) = object [ "type" .= ("note" :: T.Text)
+ 347 toJSON (NoteEvent note) = object [ "type" .= ("note" :: Text)
350 348 , "data" .= note
351 349 ]
- 352 toJSON (NewsEvent item) = object [ "type" .= ("news" :: T.Text)
+ 350 toJSON (NewsEvent item) = object [ "type" .= ("news" :: Text)
353 351 , "data" .= item
354 352 ]
- 355 toJSON (PasteEvent paste) = object [ "type" .= ("paste" :: T.Text)
+ 353 toJSON (PasteEvent paste) = object [ "type" .= ("paste" :: Text)
356 354 , "data" .= paste
357 355 ]
358 356 toJSON (WelcomeEvent _ _) = object []
… … … …