examples: apply DeriveGeneric.

This commit is contained in:
Kei Hibino 2017-03-17 10:56:33 +09:00
parent 8a0083598f
commit b545487b97
11 changed files with 33 additions and 22 deletions

View File

@ -1,9 +1,10 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module Group where
import GHC.Generics (Generic)
import Prelude hiding (id)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE1" "group" [''Show])
"EXAMPLE1" "group" [''Show, ''Generic])

View File

@ -1,8 +1,9 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module Membership where
import GHC.Generics (Generic)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE1" "membership" [])
"EXAMPLE1" "membership" [''Generic])

View File

@ -1,9 +1,10 @@
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module QueryArrowExample where
import GHC.Generics (Generic)
import Database.Record
import Database.Relational.Query.Arrow
@ -54,7 +55,7 @@ haskUserGroup =
returnA -< u >< mg ?! snd'
data UserOrGroup = UserOrGroup { mayUser :: Maybe User, mayGroup :: Maybe Group }
deriving Show
deriving (Show, Generic)
$(makeRecordPersistableDefault ''UserOrGroup)

View File

@ -1,9 +1,10 @@
{-# LANGUAGE MonadComprehensions #-}
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module QueryExample where
import GHC.Generics (Generic)
import Database.Record
import Database.Relational.Query
@ -56,7 +57,7 @@ haskUserGroup =
]
data UserOrGroup = UserOrGroup { mayUser :: Maybe User, mayGroup :: Maybe Group }
deriving Show
deriving (Show, Generic)
$(makeRecordPersistableDefault ''UserOrGroup)

View File

@ -1,9 +1,10 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module User where
import GHC.Generics (Generic)
import Prelude hiding (id)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE1" "user" [''Show])
"EXAMPLE1" "user" [''Show, ''Generic])

View File

@ -1,8 +1,9 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module KeyTest where
import GHC.Generics (Generic)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE2" "keyTest" [])
"EXAMPLE2" "keyTest" [''Generic])

View File

@ -1,9 +1,10 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module History where
import GHC.Generics (Generic)
import Prelude hiding (seq, log)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE3" "history" [''Show])
"EXAMPLE3" "history" [''Show, ''Generic])

View File

@ -1,9 +1,10 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module SetA where
import GHC.Generics (Generic)
import Prelude hiding (seq)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE3" "set_a" [''Show])
"EXAMPLE3" "set_a" [''Show, ''Generic])

View File

@ -1,9 +1,10 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module SetB where
import GHC.Generics (Generic)
import Prelude hiding (seq)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE3" "set_b" [''Show])
"EXAMPLE3" "set_b" [''Show, ''Generic])

View File

@ -1,9 +1,10 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module One where
import GHC.Generics (Generic)
import Prelude hiding (seq)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE4" "one" [''Show])
"EXAMPLE4" "one" [''Show, ''Generic])

View File

@ -1,9 +1,10 @@
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, DeriveGeneric #-}
module StockGoods where
import GHC.Generics (Generic)
import Prelude hiding (seq)
import PgTestDataSource (defineTable)
$(defineTable []
"EXAMPLE4" "stock_goods" [''Show])
"EXAMPLE4" "stock_goods" [''Show, ''Generic])