mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-09-11 08:55:25 +03:00
cabalize relational-record-examples
This commit is contained in:
parent
4b8dac476a
commit
1e1aa96a44
30
relational-record-examples/LICENSE
Normal file
30
relational-record-examples/LICENSE
Normal file
@ -0,0 +1,30 @@
|
||||
Copyright (c) 2014, Shohei Murayama
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Shohei Murayama nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
54
relational-record-examples/relational-record-examples.cabal
Normal file
54
relational-record-examples/relational-record-examples.cabal
Normal file
@ -0,0 +1,54 @@
|
||||
name: relational-record-examples
|
||||
version: 0.1.0.0
|
||||
synopsis: Examples of Haskell Relationa Record
|
||||
description: Provides examples of Haskell Relational Record
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
author: Kazu Yamamoto <kazu@iij.ad.jp>
|
||||
Shohei Murayama <shohei.murayama@gmail.com>
|
||||
maintainer: Shohei Murayama <shohei.murayama@gmail.com>
|
||||
category: Database
|
||||
build-type: Simple
|
||||
cabal-version: >=1.10
|
||||
|
||||
library
|
||||
hs-source-dirs: src
|
||||
exposed-modules: Account
|
||||
Branch
|
||||
Business
|
||||
Customer
|
||||
DataSource
|
||||
Department
|
||||
Employee
|
||||
Individual
|
||||
Officer
|
||||
Product
|
||||
ProductType
|
||||
Transaction
|
||||
build-depends: base <5
|
||||
, time
|
||||
, template-haskell
|
||||
, HDBC
|
||||
, HDBC-sqlite3
|
||||
, names-th
|
||||
, sql-words
|
||||
, HDBC-session
|
||||
, persistable-record
|
||||
, relational-query
|
||||
, relational-schemas
|
||||
, relational-query-HDBC
|
||||
default-language: Haskell2010
|
||||
|
||||
executable query
|
||||
hs-source-dirs: mains
|
||||
main-is: Query.hs
|
||||
build-depends: base <5
|
||||
, HDBC
|
||||
, HDBC-sqlite3
|
||||
, HDBC-session
|
||||
, persistable-record
|
||||
, relational-query
|
||||
, relational-query-HDBC
|
||||
, relational-record-examples
|
||||
default-language: Haskell2010
|
||||
|
@ -5,7 +5,7 @@ module Account where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "account" [derivingShow])
|
@ -5,7 +5,7 @@ module Branch where
|
||||
import Prelude hiding (id, zip)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "branch" [derivingShow])
|
@ -5,7 +5,7 @@ module Business where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "business" [derivingShow])
|
@ -5,7 +5,7 @@ module Customer where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "customer" [derivingShow])
|
@ -24,8 +24,9 @@ convTypes =
|
||||
, ("varchar", [t|String|])
|
||||
]
|
||||
|
||||
defineTable :: [(String, TypeQ)] -> String -> String -> [ConName] -> Q [Dec]
|
||||
defineTable tmap =
|
||||
defineTable :: String -> String -> [ConName] -> Q [Dec]
|
||||
defineTable =
|
||||
defineTableFromDB
|
||||
connect
|
||||
(driverSQLite3 { typeMap = tmap })
|
||||
(driverSQLite3 { typeMap = convTypes }) -- overwrite the default type map with yours
|
||||
|
@ -5,7 +5,7 @@ module Department where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "department" [derivingShow])
|
@ -5,7 +5,7 @@ module Employee where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "employee" [derivingShow])
|
@ -5,7 +5,7 @@ module Individual where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "individual" [derivingShow])
|
@ -5,7 +5,7 @@ module Officer where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "officer" [derivingShow])
|
@ -6,7 +6,7 @@ module Product where
|
||||
import Prelude hiding (id, product)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "product" [derivingShow])
|
@ -6,7 +6,7 @@ module ProductType where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "product_type" [derivingShow])
|
2
relational-record-examples/src/Setup.hs
Normal file
2
relational-record-examples/src/Setup.hs
Normal file
@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
@ -5,9 +5,9 @@ module Transaction where
|
||||
import Prelude hiding (id)
|
||||
import Database.Record.TH (derivingShow)
|
||||
|
||||
import DataSource (convTypes, defineTable)
|
||||
import DataSource (defineTable)
|
||||
|
||||
$(defineTable convTypes
|
||||
$(defineTable
|
||||
"main" "transaction0" [derivingShow])
|
||||
|
||||
type Transaction = Transaction0
|
Loading…
Reference in New Issue
Block a user