2021-12-22 03:10:28 +03:00
|
|
|
{-# LANGUAGE DeriveAnyClass #-}
|
|
|
|
|
2022-02-25 19:08:18 +03:00
|
|
|
module Hasura.Backends.DataWrapper.IR.Scalar.Value
|
2021-12-22 03:10:28 +03:00
|
|
|
( Value (..),
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
import Data.Aeson (FromJSON, ToJSON)
|
2022-03-16 07:12:15 +03:00
|
|
|
import Hasura.Backends.DataWrapper.API qualified as API
|
2021-12-22 03:10:28 +03:00
|
|
|
import Hasura.Incremental (Cacheable)
|
|
|
|
import Hasura.Prelude
|
2022-03-16 07:12:15 +03:00
|
|
|
import Witch
|
2021-12-22 03:10:28 +03:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- | Literal scalar values that can appear as leaf nodes in expressions
|
|
|
|
--
|
2022-02-25 19:08:18 +03:00
|
|
|
-- NOTE: This type shouldn't _need_ ser/de instances, but they're imposed by
|
|
|
|
-- the 'Backend' class.
|
2021-12-22 03:10:28 +03:00
|
|
|
data Value
|
|
|
|
= String Text
|
|
|
|
| Number Double
|
|
|
|
| Boolean Bool
|
|
|
|
| Null
|
|
|
|
deriving stock (Data, Eq, Generic, Ord, Show)
|
|
|
|
deriving anyclass (Cacheable, FromJSON, Hashable, NFData, ToJSON)
|
2022-03-16 07:12:15 +03:00
|
|
|
|
|
|
|
instance From API.Value Value where
|
|
|
|
from = \case
|
|
|
|
API.String txt -> String txt
|
|
|
|
API.Number x -> Number x
|
|
|
|
API.Boolean p -> Boolean p
|
|
|
|
API.Null -> Null
|