1 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE QuasiQuotes #-}
4 {-# LANGUAGE TemplateHaskell #-}
5 {-# LANGUAGE TypeFamilies #-}
7 -- | (At least) two different XML types have a notion of locations:
8 -- "TSN.XML.News" and "TSN.XML.Scores". And in fact those two types
9 -- agree on the city, state, and country -- at least for the
10 -- database representation.
12 -- This module contains a data type for the common database
17 LocationConstructor(..) )
21 import Database.Groundhog () -- Required for some String instance
22 import Database.Groundhog.TH (
28 -- | Database representation of a location.
30 -- The country has always been present in the XML that we've
31 -- seen. The city/state however have been observed missing in some
32 -- cases. The Scores are better about always having a city/state,
33 -- but in the interest of consolidation, we've made them optional so
34 -- that they can be mushed together into this one type.
39 state :: Maybe String,
44 -- Generate the Groundhog code for 'Location'.
45 mkPersist defaultCodegenConfig [groundhog|
51 - name: unique_location
53 fields: [city, state, country]