{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Personalize.Types.ContinuousHyperParameterRange where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 name of the hyperparameter.
    ContinuousHyperParameterRange -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The minimum allowable value for the hyperparameter.
    ContinuousHyperParameterRange -> Maybe Double
minValue :: Prelude.Maybe Prelude.Double
  }
  deriving (ContinuousHyperParameterRange
-> ContinuousHyperParameterRange -> Bool
(ContinuousHyperParameterRange
 -> ContinuousHyperParameterRange -> Bool)
-> (ContinuousHyperParameterRange
    -> ContinuousHyperParameterRange -> Bool)
-> Eq ContinuousHyperParameterRange
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]
(Int -> ReadS ContinuousHyperParameterRange)
-> ReadS [ContinuousHyperParameterRange]
-> ReadPrec ContinuousHyperParameterRange
-> ReadPrec [ContinuousHyperParameterRange]
-> Read 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
(Int -> ContinuousHyperParameterRange -> ShowS)
-> (ContinuousHyperParameterRange -> String)
-> ([ContinuousHyperParameterRange] -> ShowS)
-> Show ContinuousHyperParameterRange
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.
 ContinuousHyperParameterRange
 -> Rep ContinuousHyperParameterRange x)
-> (forall x.
    Rep ContinuousHyperParameterRange x
    -> ContinuousHyperParameterRange)
-> Generic ContinuousHyperParameterRange
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.
--
-- 'name', 'continuousHyperParameterRange_name' - The name of the hyperparameter.
--
-- 'minValue', 'continuousHyperParameterRange_minValue' - The minimum allowable value for the hyperparameter.
newContinuousHyperParameterRange ::
  ContinuousHyperParameterRange
newContinuousHyperParameterRange :: ContinuousHyperParameterRange
newContinuousHyperParameterRange =
  ContinuousHyperParameterRange' :: Maybe Double
-> Maybe Text -> Maybe Double -> ContinuousHyperParameterRange
ContinuousHyperParameterRange'
    { $sel:maxValue:ContinuousHyperParameterRange' :: Maybe Double
maxValue =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ContinuousHyperParameterRange' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:minValue:ContinuousHyperParameterRange' :: Maybe Double
minValue = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum allowable value for the hyperparameter.
continuousHyperParameterRange_maxValue :: Lens.Lens' ContinuousHyperParameterRange (Prelude.Maybe Prelude.Double)
continuousHyperParameterRange_maxValue :: (Maybe Double -> f (Maybe Double))
-> ContinuousHyperParameterRange -> f ContinuousHyperParameterRange
continuousHyperParameterRange_maxValue = (ContinuousHyperParameterRange -> Maybe Double)
-> (ContinuousHyperParameterRange
    -> Maybe Double -> ContinuousHyperParameterRange)
-> Lens
     ContinuousHyperParameterRange
     ContinuousHyperParameterRange
     (Maybe Double)
     (Maybe Double)
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 name of the hyperparameter.
continuousHyperParameterRange_name :: Lens.Lens' ContinuousHyperParameterRange (Prelude.Maybe Prelude.Text)
continuousHyperParameterRange_name :: (Maybe Text -> f (Maybe Text))
-> ContinuousHyperParameterRange -> f ContinuousHyperParameterRange
continuousHyperParameterRange_name = (ContinuousHyperParameterRange -> Maybe Text)
-> (ContinuousHyperParameterRange
    -> Maybe Text -> ContinuousHyperParameterRange)
-> Lens
     ContinuousHyperParameterRange
     ContinuousHyperParameterRange
     (Maybe Text)
     (Maybe Text)
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)

-- | The minimum allowable value for the hyperparameter.
continuousHyperParameterRange_minValue :: Lens.Lens' ContinuousHyperParameterRange (Prelude.Maybe Prelude.Double)
continuousHyperParameterRange_minValue :: (Maybe Double -> f (Maybe Double))
-> ContinuousHyperParameterRange -> f ContinuousHyperParameterRange
continuousHyperParameterRange_minValue = (ContinuousHyperParameterRange -> Maybe Double)
-> (ContinuousHyperParameterRange
    -> Maybe Double -> ContinuousHyperParameterRange)
-> Lens
     ContinuousHyperParameterRange
     ContinuousHyperParameterRange
     (Maybe Double)
     (Maybe Double)
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)

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

instance
  Prelude.Hashable
    ContinuousHyperParameterRange

instance Prelude.NFData ContinuousHyperParameterRange

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