mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-29 15:03:31 +03:00
examples: apply DeriveGeneric.
This commit is contained in:
parent
8a0083598f
commit
b545487b97
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module Group where
|
module Group where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Prelude hiding (id)
|
import Prelude hiding (id)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE1" "group" [''Show])
|
"EXAMPLE1" "group" [''Show, ''Generic])
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module Membership where
|
module Membership where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE1" "membership" [])
|
"EXAMPLE1" "membership" [''Generic])
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE Arrows #-}
|
{-# LANGUAGE Arrows #-}
|
||||||
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-}
|
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, DeriveGeneric #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
module QueryArrowExample where
|
module QueryArrowExample where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Database.Record
|
import Database.Record
|
||||||
|
|
||||||
import Database.Relational.Query.Arrow
|
import Database.Relational.Query.Arrow
|
||||||
@ -54,7 +55,7 @@ haskUserGroup =
|
|||||||
returnA -< u >< mg ?! snd'
|
returnA -< u >< mg ?! snd'
|
||||||
|
|
||||||
data UserOrGroup = UserOrGroup { mayUser :: Maybe User, mayGroup :: Maybe Group }
|
data UserOrGroup = UserOrGroup { mayUser :: Maybe User, mayGroup :: Maybe Group }
|
||||||
deriving Show
|
deriving (Show, Generic)
|
||||||
|
|
||||||
$(makeRecordPersistableDefault ''UserOrGroup)
|
$(makeRecordPersistableDefault ''UserOrGroup)
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE MonadComprehensions #-}
|
{-# LANGUAGE MonadComprehensions #-}
|
||||||
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-}
|
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, DeriveGeneric #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
module QueryExample where
|
module QueryExample where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Database.Record
|
import Database.Record
|
||||||
|
|
||||||
import Database.Relational.Query
|
import Database.Relational.Query
|
||||||
@ -56,7 +57,7 @@ haskUserGroup =
|
|||||||
]
|
]
|
||||||
|
|
||||||
data UserOrGroup = UserOrGroup { mayUser :: Maybe User, mayGroup :: Maybe Group }
|
data UserOrGroup = UserOrGroup { mayUser :: Maybe User, mayGroup :: Maybe Group }
|
||||||
deriving Show
|
deriving (Show, Generic)
|
||||||
|
|
||||||
$(makeRecordPersistableDefault ''UserOrGroup)
|
$(makeRecordPersistableDefault ''UserOrGroup)
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module User where
|
module User where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Prelude hiding (id)
|
import Prelude hiding (id)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE1" "user" [''Show])
|
"EXAMPLE1" "user" [''Show, ''Generic])
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module KeyTest where
|
module KeyTest where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE2" "keyTest" [])
|
"EXAMPLE2" "keyTest" [''Generic])
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module History where
|
module History where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Prelude hiding (seq, log)
|
import Prelude hiding (seq, log)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE3" "history" [''Show])
|
"EXAMPLE3" "history" [''Show, ''Generic])
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module SetA where
|
module SetA where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Prelude hiding (seq)
|
import Prelude hiding (seq)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE3" "set_a" [''Show])
|
"EXAMPLE3" "set_a" [''Show, ''Generic])
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module SetB where
|
module SetB where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Prelude hiding (seq)
|
import Prelude hiding (seq)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE3" "set_b" [''Show])
|
"EXAMPLE3" "set_b" [''Show, ''Generic])
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module One where
|
module One where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Prelude hiding (seq)
|
import Prelude hiding (seq)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE4" "one" [''Show])
|
"EXAMPLE4" "one" [''Show, ''Generic])
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
|
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
|
||||||
|
|
||||||
module StockGoods where
|
module StockGoods where
|
||||||
|
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Prelude hiding (seq)
|
import Prelude hiding (seq)
|
||||||
import PgTestDataSource (defineTable)
|
import PgTestDataSource (defineTable)
|
||||||
|
|
||||||
$(defineTable []
|
$(defineTable []
|
||||||
"EXAMPLE4" "stock_goods" [''Show])
|
"EXAMPLE4" "stock_goods" [''Show, ''Generic])
|
||||||
|
Loading…
Reference in New Issue
Block a user