]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blob - src/TSN/Team.hs
Add the TSN.Team module housing a common database representation of teams.
[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 :: String,
37 team_name :: String }
38 deriving (Eq, Show)
39
40
41 -- Generate the Groundhog code for 'Team'.
42 mkPersist defaultCodegenConfig [groundhog|
43 - entity: Team
44 dbName: teams
45 constructors:
46 - name: Team
47 uniques:
48 - name: unique_odds_games_team
49 type: constraint
50 fields: [team_id]
51 |]