1 {-# LANGUAGE TemplateHaskell, TypeFamilies, OverloadedStrings #-}
    2 module Model.Category.Types
    3   ( Category(..)
    4   ) where
    5 
    6 import Data.Function (on)
    7 import Data.Int (Int16)
    8 import qualified Data.Text as T
    9 import Instances.TH.Lift ()
   10 import Language.Haskell.TH.Lift (deriveLift)
   11 
   12 import Model.Kind
   13 import Model.Id.Types
   14 
   15 type instance IdType Category = Int16
   16 
   17 data Category = Category
   18   { categoryId :: !(Id Category)
   19   , categoryName :: !T.Text
   20   , categoryDescription :: !(Maybe T.Text)
   21   } deriving (Show)
   22 
   23 instance Kinded Category where
   24   kindOf _ = "category"
   25 
   26 instance Eq Category where
   27   (==) = on (==) categoryId
   28   (/=) = on (/=) categoryId
   29 
   30 deriveLift ''Category