mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-12 12:09:08 +03:00
25 lines
701 B
Haskell
25 lines
701 B
Haskell
{-# LANGUAGE TemplateHaskell #-}
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
module Birthday where
|
|
|
|
import Data.Time
|
|
|
|
import Opaleye
|
|
import Data.Profunctor.Product.TH
|
|
|
|
data Birthday' a b = Birthday { name :: a, day :: b }
|
|
type Birthday = Birthday' String Day
|
|
type BirthdayColumn = Birthday' (Column PGText) (Column PGDate)
|
|
|
|
$(makeAdaptorAndInstance "pBirthday" ''Birthday')
|
|
|
|
birthdayTable :: Table BirthdayColumn BirthdayColumn
|
|
birthdayTable = Table "birthdayTable"
|
|
(pBirthday Birthday { name = required "name"
|
|
, day = required "day" })
|
|
|
|
birthdayQuery :: Query BirthdayColumn
|
|
birthdayQuery = queryTable birthdayTable
|