]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blob - src/TSN/Team.hs
Make team names and abbreviations optional.
[dead/htsn-import.git] / src / TSN / Team.hs
1 {-# LANGUAGE FlexibleInstances #-}
2 {-# LANGUAGE GADTs #-}
3 {-# LANGUAGE QuasiQuotes #-}
4 {-# LANGUAGE TemplateHaskell #-}
5 {-# LANGUAGE TypeFamilies #-}
6
7 -- | Two different XML types have a notion of teams: "TSN.XML.Odds"
8 -- and "TSN.XML.JFile". And in fact those two types agree on the
9 -- team id, abbreviation, and name -- at least for the database
10 -- representation.
11 --
12 -- This module contains a data type for the common database
13 -- representation.
14 --
15 module TSN.Team (
16 Team(..),
17 -- * WARNING: these are private but exported to silence warnings
18 TeamConstructor(..) )
19 where
20
21 -- System imports
22 import Database.Groundhog () -- Required for some String instance
23 import Database.Groundhog.TH (
24 defaultCodegenConfig,
25 groundhog,
26 mkPersist )
27
28
29 -- | The database representation of a team. The 'team_id' is a
30 -- 'String' field because some teams do in fact have ids like
31 -- \"B52\".
32 --
33 data Team =
34 Team {
35 team_id :: String, -- ^ Some of them contain characters
36 team_abbreviation :: Maybe String, -- ^ Some teams don't have abbreviations,
37 -- or at least, some sample jfilexml
38 -- don't have them for some teams.
39 team_name :: Maybe String -- ^ Some teams don't even have names!
40 }
41 deriving (Eq, Show)
42
43
44 -- Generate the Groundhog code for 'Team'.
45 mkPersist defaultCodegenConfig [groundhog|
46 - entity: Team
47 dbName: teams
48 constructors:
49 - name: Team
50 uniques:
51 - name: unique_odds_games_team
52 type: constraint
53 fields: [team_id]
54 |]