{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Personalize.Types.ContinuousHyperParameterRange
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Personalize.Types.ContinuousHyperParameterRange where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Provides the name and range of a continuous hyperparameter.
--
-- /See:/ 'newContinuousHyperParameterRange' smart constructor.
data ContinuousHyperParameterRange = ContinuousHyperParameterRange'
  { -- | The maximum allowable value for the hyperparameter.
    ContinuousHyperParameterRange -> Maybe Double
maxValue :: Prelude.Maybe Prelude.Double,
    -- | The minimum allowable value for the hyperparameter.
    ContinuousHyperParameterRange -> Maybe Double
minValue :: Prelude.Maybe Prelude.Double,
    -- | The name of the hyperparameter.
    ContinuousHyperParameterRange -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ContinuousHyperParameterRange
-> ContinuousHyperParameterRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContinuousHyperParameterRange
-> ContinuousHyperParameterRange -> Bool
$c/= :: ContinuousHyperParameterRange
-> ContinuousHyperParameterRange -> Bool
== :: ContinuousHyperParameterRange
-> ContinuousHyperParameterRange -> Bool
$c== :: ContinuousHyperParameterRange
-> ContinuousHyperParameterRange -> Bool
Prelude.Eq, ReadPrec [ContinuousHyperParameterRange]
ReadPrec ContinuousHyperParameterRange
Int -> ReadS ContinuousHyperParameterRange
ReadS [ContinuousHyperParameterRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContinuousHyperParameterRange]
$creadListPrec :: ReadPrec [ContinuousHyperParameterRange]
readPrec :: ReadPrec ContinuousHyperParameterRange
$creadPrec :: ReadPrec ContinuousHyperParameterRange
readList :: ReadS [ContinuousHyperParameterRange]
$creadList :: ReadS [ContinuousHyperParameterRange]
readsPrec :: Int -> ReadS ContinuousHyperParameterRange
$creadsPrec :: Int -> ReadS ContinuousHyperParameterRange
Prelude.Read, Int -> ContinuousHyperParameterRange -> ShowS
[ContinuousHyperParameterRange] -> ShowS
ContinuousHyperParameterRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContinuousHyperParameterRange] -> ShowS
$cshowList :: [ContinuousHyperParameterRange] -> ShowS
show :: ContinuousHyperParameterRange -> String
$cshow :: ContinuousHyperParameterRange -> String
showsPrec :: Int -> ContinuousHyperParameterRange -> ShowS
$cshowsPrec :: Int -> ContinuousHyperParameterRange -> ShowS
Prelude.Show, forall x.
Rep ContinuousHyperParameterRange x
-> ContinuousHyperParameterRange
forall x.
ContinuousHyperParameterRange
-> Rep ContinuousHyperParameterRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContinuousHyperParameterRange x
-> ContinuousHyperParameterRange
$cfrom :: forall x.
ContinuousHyperParameterRange
-> Rep ContinuousHyperParameterRange x
Prelude.Generic)

-- |
-- Create a value of 'ContinuousHyperParameterRange' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maxValue', 'continuousHyperParameterRange_maxValue' - The maximum allowable value for the hyperparameter.
--
-- 'minValue', 'continuousHyperParameterRange_minValue' - The minimum allowable value for the hyperparameter.
--
-- 'name', 'continuousHyperParameterRange_name' - The name of the hyperparameter.
newContinuousHyperParameterRange ::
  ContinuousHyperParameterRange
newContinuousHyperParameterRange :: ContinuousHyperParameterRange
newContinuousHyperParameterRange =
  ContinuousHyperParameterRange'
    { $sel:maxValue:ContinuousHyperParameterRange' :: Maybe Double
maxValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:minValue:ContinuousHyperParameterRange' :: Maybe Double
minValue = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ContinuousHyperParameterRange' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum allowable value for the hyperparameter.
continuousHyperParameterRange_maxValue :: Lens.Lens' ContinuousHyperParameterRange (Prelude.Maybe Prelude.Double)
continuousHyperParameterRange_maxValue :: Lens' ContinuousHyperParameterRange (Maybe Double)
continuousHyperParameterRange_maxValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousHyperParameterRange' {Maybe Double
maxValue :: Maybe Double
$sel:maxValue:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Double
maxValue} -> Maybe Double
maxValue) (\s :: ContinuousHyperParameterRange
s@ContinuousHyperParameterRange' {} Maybe Double
a -> ContinuousHyperParameterRange
s {$sel:maxValue:ContinuousHyperParameterRange' :: Maybe Double
maxValue = Maybe Double
a} :: ContinuousHyperParameterRange)

-- | The minimum allowable value for the hyperparameter.
continuousHyperParameterRange_minValue :: Lens.Lens' ContinuousHyperParameterRange (Prelude.Maybe Prelude.Double)
continuousHyperParameterRange_minValue :: Lens' ContinuousHyperParameterRange (Maybe Double)
continuousHyperParameterRange_minValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousHyperParameterRange' {Maybe Double
minValue :: Maybe Double
$sel:minValue:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Double
minValue} -> Maybe Double
minValue) (\s :: ContinuousHyperParameterRange
s@ContinuousHyperParameterRange' {} Maybe Double
a -> ContinuousHyperParameterRange
s {$sel:minValue:ContinuousHyperParameterRange' :: Maybe Double
minValue = Maybe Double
a} :: ContinuousHyperParameterRange)

-- | The name of the hyperparameter.
continuousHyperParameterRange_name :: Lens.Lens' ContinuousHyperParameterRange (Prelude.Maybe Prelude.Text)
continuousHyperParameterRange_name :: Lens' ContinuousHyperParameterRange (Maybe Text)
continuousHyperParameterRange_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousHyperParameterRange' {Maybe Text
name :: Maybe Text
$sel:name:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Text
name} -> Maybe Text
name) (\s :: ContinuousHyperParameterRange
s@ContinuousHyperParameterRange' {} Maybe Text
a -> ContinuousHyperParameterRange
s {$sel:name:ContinuousHyperParameterRange' :: Maybe Text
name = Maybe Text
a} :: ContinuousHyperParameterRange)

instance Data.FromJSON ContinuousHyperParameterRange where
  parseJSON :: Value -> Parser ContinuousHyperParameterRange
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContinuousHyperParameterRange"
      ( \Object
x ->
          Maybe Double
-> Maybe Double -> Maybe Text -> ContinuousHyperParameterRange
ContinuousHyperParameterRange'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"maxValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"minValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"name")
      )

instance
  Prelude.Hashable
    ContinuousHyperParameterRange
  where
  hashWithSalt :: Int -> ContinuousHyperParameterRange -> Int
hashWithSalt Int
_salt ContinuousHyperParameterRange' {Maybe Double
Maybe Text
name :: Maybe Text
minValue :: Maybe Double
maxValue :: Maybe Double
$sel:name:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Text
$sel:minValue:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Double
$sel:maxValue:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
maxValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
minValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData ContinuousHyperParameterRange where
  rnf :: ContinuousHyperParameterRange -> ()
rnf ContinuousHyperParameterRange' {Maybe Double
Maybe Text
name :: Maybe Text
minValue :: Maybe Double
maxValue :: Maybe Double
$sel:name:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Text
$sel:minValue:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Double
$sel:maxValue:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
maxValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
minValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name

instance Data.ToJSON ContinuousHyperParameterRange where
  toJSON :: ContinuousHyperParameterRange -> Value
toJSON ContinuousHyperParameterRange' {Maybe Double
Maybe Text
name :: Maybe Text
minValue :: Maybe Double
maxValue :: Maybe Double
$sel:name:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Text
$sel:minValue:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Double
$sel:maxValue:ContinuousHyperParameterRange' :: ContinuousHyperParameterRange -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
maxValue,
            (Key
"minValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
minValue,
            (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name
          ]
      )