2 Module : Gargantext.Database.Types
3 Description : Specific Types to manage core Gargantext type with database
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 {-# LANGUAGE TemplateHaskell #-}
14 module Gargantext.Database.Types
17 import Data.Hashable (Hashable)
18 import Gargantext.Core.Text (HasText(..))
19 import Gargantext.Database.Schema.Prelude
20 import Gargantext.Prelude
21 import qualified Database.PostgreSQL.Simple as PGS
24 -- | Index memory of any type in Gargantext
26 Indexed { _index :: !i
29 deriving (Show, Generic, Eq, Ord)
33 ----------------------------------------------------------------------
35 instance (FromField i, FromField a) => PGS.FromRow (Indexed i a) where
36 fromRow = Indexed <$> field <*> field
38 instance HasText a => HasText (Indexed i a)
40 hasText (Indexed _ a) = hasText a
42 instance (Hashable a, Hashable b) => Hashable (Indexed a b)