{-# LANGUAGE UndecidableInstances #-}

module Hasura.LogicalModel.IR
  ( LogicalModel (..),
  )
where

import Data.HashMap.Strict.InsOrd qualified as InsOrdHashMap
import Hasura.LogicalModel.Types (LogicalModelField, LogicalModelName)
import Hasura.Prelude hiding (first)
import Hasura.RQL.Types.Backend (Backend (..))
import Hasura.RQL.Types.BackendType (BackendType)

-- | Description of a logical model for use in IR
data LogicalModel (b :: BackendType) = LogicalModel
  { forall (b :: BackendType). LogicalModel b -> LogicalModelName
lmName :: LogicalModelName,
    forall (b :: BackendType).
LogicalModel b -> InsOrdHashMap (Column b) (LogicalModelField b)
lmFields :: InsOrdHashMap.InsOrdHashMap (Column b) (LogicalModelField b)
  }
  deriving ((forall x. LogicalModel b -> Rep (LogicalModel b) x)
-> (forall x. Rep (LogicalModel b) x -> LogicalModel b)
-> Generic (LogicalModel b)
forall x. Rep (LogicalModel b) x -> LogicalModel b
forall x. LogicalModel b -> Rep (LogicalModel b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (b :: BackendType) x.
Rep (LogicalModel b) x -> LogicalModel b
forall (b :: BackendType) x.
LogicalModel b -> Rep (LogicalModel b) x
$cfrom :: forall (b :: BackendType) x.
LogicalModel b -> Rep (LogicalModel b) x
from :: forall x. LogicalModel b -> Rep (LogicalModel b) x
$cto :: forall (b :: BackendType) x.
Rep (LogicalModel b) x -> LogicalModel b
to :: forall x. Rep (LogicalModel b) x -> LogicalModel b
Generic)

deriving instance (Backend b) => Eq (LogicalModel b)

deriving instance (Backend b) => Show (LogicalModel b)