{-# 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.HyperParameterRanges
-- 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.HyperParameterRanges where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Personalize.Types.CategoricalHyperParameterRange
import Amazonka.Personalize.Types.ContinuousHyperParameterRange
import Amazonka.Personalize.Types.IntegerHyperParameterRange
import qualified Amazonka.Prelude as Prelude

-- | Specifies the hyperparameters and their ranges. Hyperparameters can be
-- categorical, continuous, or integer-valued.
--
-- /See:/ 'newHyperParameterRanges' smart constructor.
data HyperParameterRanges = HyperParameterRanges'
  { -- | The integer-valued hyperparameters and their ranges.
    HyperParameterRanges -> Maybe [IntegerHyperParameterRange]
integerHyperParameterRanges :: Prelude.Maybe [IntegerHyperParameterRange],
    -- | The categorical hyperparameters and their ranges.
    HyperParameterRanges -> Maybe [CategoricalHyperParameterRange]
categoricalHyperParameterRanges :: Prelude.Maybe [CategoricalHyperParameterRange],
    -- | The continuous hyperparameters and their ranges.
    HyperParameterRanges -> Maybe [ContinuousHyperParameterRange]
continuousHyperParameterRanges :: Prelude.Maybe [ContinuousHyperParameterRange]
  }
  deriving (HyperParameterRanges -> HyperParameterRanges -> Bool
(HyperParameterRanges -> HyperParameterRanges -> Bool)
-> (HyperParameterRanges -> HyperParameterRanges -> Bool)
-> Eq HyperParameterRanges
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperParameterRanges -> HyperParameterRanges -> Bool
$c/= :: HyperParameterRanges -> HyperParameterRanges -> Bool
== :: HyperParameterRanges -> HyperParameterRanges -> Bool
$c== :: HyperParameterRanges -> HyperParameterRanges -> Bool
Prelude.Eq, ReadPrec [HyperParameterRanges]
ReadPrec HyperParameterRanges
Int -> ReadS HyperParameterRanges
ReadS [HyperParameterRanges]
(Int -> ReadS HyperParameterRanges)
-> ReadS [HyperParameterRanges]
-> ReadPrec HyperParameterRanges
-> ReadPrec [HyperParameterRanges]
-> Read HyperParameterRanges
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HyperParameterRanges]
$creadListPrec :: ReadPrec [HyperParameterRanges]
readPrec :: ReadPrec HyperParameterRanges
$creadPrec :: ReadPrec HyperParameterRanges
readList :: ReadS [HyperParameterRanges]
$creadList :: ReadS [HyperParameterRanges]
readsPrec :: Int -> ReadS HyperParameterRanges
$creadsPrec :: Int -> ReadS HyperParameterRanges
Prelude.Read, Int -> HyperParameterRanges -> ShowS
[HyperParameterRanges] -> ShowS
HyperParameterRanges -> String
(Int -> HyperParameterRanges -> ShowS)
-> (HyperParameterRanges -> String)
-> ([HyperParameterRanges] -> ShowS)
-> Show HyperParameterRanges
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperParameterRanges] -> ShowS
$cshowList :: [HyperParameterRanges] -> ShowS
show :: HyperParameterRanges -> String
$cshow :: HyperParameterRanges -> String
showsPrec :: Int -> HyperParameterRanges -> ShowS
$cshowsPrec :: Int -> HyperParameterRanges -> ShowS
Prelude.Show, (forall x. HyperParameterRanges -> Rep HyperParameterRanges x)
-> (forall x. Rep HyperParameterRanges x -> HyperParameterRanges)
-> Generic HyperParameterRanges
forall x. Rep HyperParameterRanges x -> HyperParameterRanges
forall x. HyperParameterRanges -> Rep HyperParameterRanges x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HyperParameterRanges x -> HyperParameterRanges
$cfrom :: forall x. HyperParameterRanges -> Rep HyperParameterRanges x
Prelude.Generic)

-- |
-- Create a value of 'HyperParameterRanges' 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:
--
-- 'integerHyperParameterRanges', 'hyperParameterRanges_integerHyperParameterRanges' - The integer-valued hyperparameters and their ranges.
--
-- 'categoricalHyperParameterRanges', 'hyperParameterRanges_categoricalHyperParameterRanges' - The categorical hyperparameters and their ranges.
--
-- 'continuousHyperParameterRanges', 'hyperParameterRanges_continuousHyperParameterRanges' - The continuous hyperparameters and their ranges.
newHyperParameterRanges ::
  HyperParameterRanges
newHyperParameterRanges :: HyperParameterRanges
newHyperParameterRanges =
  HyperParameterRanges' :: Maybe [IntegerHyperParameterRange]
-> Maybe [CategoricalHyperParameterRange]
-> Maybe [ContinuousHyperParameterRange]
-> HyperParameterRanges
HyperParameterRanges'
    { $sel:integerHyperParameterRanges:HyperParameterRanges' :: Maybe [IntegerHyperParameterRange]
integerHyperParameterRanges =
        Maybe [IntegerHyperParameterRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:categoricalHyperParameterRanges:HyperParameterRanges' :: Maybe [CategoricalHyperParameterRange]
categoricalHyperParameterRanges = Maybe [CategoricalHyperParameterRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:continuousHyperParameterRanges:HyperParameterRanges' :: Maybe [ContinuousHyperParameterRange]
continuousHyperParameterRanges = Maybe [ContinuousHyperParameterRange]
forall a. Maybe a
Prelude.Nothing
    }

-- | The integer-valued hyperparameters and their ranges.
hyperParameterRanges_integerHyperParameterRanges :: Lens.Lens' HyperParameterRanges (Prelude.Maybe [IntegerHyperParameterRange])
hyperParameterRanges_integerHyperParameterRanges :: (Maybe [IntegerHyperParameterRange]
 -> f (Maybe [IntegerHyperParameterRange]))
-> HyperParameterRanges -> f HyperParameterRanges
hyperParameterRanges_integerHyperParameterRanges = (HyperParameterRanges -> Maybe [IntegerHyperParameterRange])
-> (HyperParameterRanges
    -> Maybe [IntegerHyperParameterRange] -> HyperParameterRanges)
-> Lens
     HyperParameterRanges
     HyperParameterRanges
     (Maybe [IntegerHyperParameterRange])
     (Maybe [IntegerHyperParameterRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterRanges' {Maybe [IntegerHyperParameterRange]
integerHyperParameterRanges :: Maybe [IntegerHyperParameterRange]
$sel:integerHyperParameterRanges:HyperParameterRanges' :: HyperParameterRanges -> Maybe [IntegerHyperParameterRange]
integerHyperParameterRanges} -> Maybe [IntegerHyperParameterRange]
integerHyperParameterRanges) (\s :: HyperParameterRanges
s@HyperParameterRanges' {} Maybe [IntegerHyperParameterRange]
a -> HyperParameterRanges
s {$sel:integerHyperParameterRanges:HyperParameterRanges' :: Maybe [IntegerHyperParameterRange]
integerHyperParameterRanges = Maybe [IntegerHyperParameterRange]
a} :: HyperParameterRanges) ((Maybe [IntegerHyperParameterRange]
  -> f (Maybe [IntegerHyperParameterRange]))
 -> HyperParameterRanges -> f HyperParameterRanges)
-> ((Maybe [IntegerHyperParameterRange]
     -> f (Maybe [IntegerHyperParameterRange]))
    -> Maybe [IntegerHyperParameterRange]
    -> f (Maybe [IntegerHyperParameterRange]))
-> (Maybe [IntegerHyperParameterRange]
    -> f (Maybe [IntegerHyperParameterRange]))
-> HyperParameterRanges
-> f HyperParameterRanges
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [IntegerHyperParameterRange]
  [IntegerHyperParameterRange]
  [IntegerHyperParameterRange]
  [IntegerHyperParameterRange]
-> Iso
     (Maybe [IntegerHyperParameterRange])
     (Maybe [IntegerHyperParameterRange])
     (Maybe [IntegerHyperParameterRange])
     (Maybe [IntegerHyperParameterRange])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [IntegerHyperParameterRange]
  [IntegerHyperParameterRange]
  [IntegerHyperParameterRange]
  [IntegerHyperParameterRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The categorical hyperparameters and their ranges.
hyperParameterRanges_categoricalHyperParameterRanges :: Lens.Lens' HyperParameterRanges (Prelude.Maybe [CategoricalHyperParameterRange])
hyperParameterRanges_categoricalHyperParameterRanges :: (Maybe [CategoricalHyperParameterRange]
 -> f (Maybe [CategoricalHyperParameterRange]))
-> HyperParameterRanges -> f HyperParameterRanges
hyperParameterRanges_categoricalHyperParameterRanges = (HyperParameterRanges -> Maybe [CategoricalHyperParameterRange])
-> (HyperParameterRanges
    -> Maybe [CategoricalHyperParameterRange] -> HyperParameterRanges)
-> Lens
     HyperParameterRanges
     HyperParameterRanges
     (Maybe [CategoricalHyperParameterRange])
     (Maybe [CategoricalHyperParameterRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterRanges' {Maybe [CategoricalHyperParameterRange]
categoricalHyperParameterRanges :: Maybe [CategoricalHyperParameterRange]
$sel:categoricalHyperParameterRanges:HyperParameterRanges' :: HyperParameterRanges -> Maybe [CategoricalHyperParameterRange]
categoricalHyperParameterRanges} -> Maybe [CategoricalHyperParameterRange]
categoricalHyperParameterRanges) (\s :: HyperParameterRanges
s@HyperParameterRanges' {} Maybe [CategoricalHyperParameterRange]
a -> HyperParameterRanges
s {$sel:categoricalHyperParameterRanges:HyperParameterRanges' :: Maybe [CategoricalHyperParameterRange]
categoricalHyperParameterRanges = Maybe [CategoricalHyperParameterRange]
a} :: HyperParameterRanges) ((Maybe [CategoricalHyperParameterRange]
  -> f (Maybe [CategoricalHyperParameterRange]))
 -> HyperParameterRanges -> f HyperParameterRanges)
-> ((Maybe [CategoricalHyperParameterRange]
     -> f (Maybe [CategoricalHyperParameterRange]))
    -> Maybe [CategoricalHyperParameterRange]
    -> f (Maybe [CategoricalHyperParameterRange]))
-> (Maybe [CategoricalHyperParameterRange]
    -> f (Maybe [CategoricalHyperParameterRange]))
-> HyperParameterRanges
-> f HyperParameterRanges
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CategoricalHyperParameterRange]
  [CategoricalHyperParameterRange]
  [CategoricalHyperParameterRange]
  [CategoricalHyperParameterRange]
-> Iso
     (Maybe [CategoricalHyperParameterRange])
     (Maybe [CategoricalHyperParameterRange])
     (Maybe [CategoricalHyperParameterRange])
     (Maybe [CategoricalHyperParameterRange])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [CategoricalHyperParameterRange]
  [CategoricalHyperParameterRange]
  [CategoricalHyperParameterRange]
  [CategoricalHyperParameterRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The continuous hyperparameters and their ranges.
hyperParameterRanges_continuousHyperParameterRanges :: Lens.Lens' HyperParameterRanges (Prelude.Maybe [ContinuousHyperParameterRange])
hyperParameterRanges_continuousHyperParameterRanges :: (Maybe [ContinuousHyperParameterRange]
 -> f (Maybe [ContinuousHyperParameterRange]))
-> HyperParameterRanges -> f HyperParameterRanges
hyperParameterRanges_continuousHyperParameterRanges = (HyperParameterRanges -> Maybe [ContinuousHyperParameterRange])
-> (HyperParameterRanges
    -> Maybe [ContinuousHyperParameterRange] -> HyperParameterRanges)
-> Lens
     HyperParameterRanges
     HyperParameterRanges
     (Maybe [ContinuousHyperParameterRange])
     (Maybe [ContinuousHyperParameterRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterRanges' {Maybe [ContinuousHyperParameterRange]
continuousHyperParameterRanges :: Maybe [ContinuousHyperParameterRange]
$sel:continuousHyperParameterRanges:HyperParameterRanges' :: HyperParameterRanges -> Maybe [ContinuousHyperParameterRange]
continuousHyperParameterRanges} -> Maybe [ContinuousHyperParameterRange]
continuousHyperParameterRanges) (\s :: HyperParameterRanges
s@HyperParameterRanges' {} Maybe [ContinuousHyperParameterRange]
a -> HyperParameterRanges
s {$sel:continuousHyperParameterRanges:HyperParameterRanges' :: Maybe [ContinuousHyperParameterRange]
continuousHyperParameterRanges = Maybe [ContinuousHyperParameterRange]
a} :: HyperParameterRanges) ((Maybe [ContinuousHyperParameterRange]
  -> f (Maybe [ContinuousHyperParameterRange]))
 -> HyperParameterRanges -> f HyperParameterRanges)
-> ((Maybe [ContinuousHyperParameterRange]
     -> f (Maybe [ContinuousHyperParameterRange]))
    -> Maybe [ContinuousHyperParameterRange]
    -> f (Maybe [ContinuousHyperParameterRange]))
-> (Maybe [ContinuousHyperParameterRange]
    -> f (Maybe [ContinuousHyperParameterRange]))
-> HyperParameterRanges
-> f HyperParameterRanges
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ContinuousHyperParameterRange]
  [ContinuousHyperParameterRange]
  [ContinuousHyperParameterRange]
  [ContinuousHyperParameterRange]
-> Iso
     (Maybe [ContinuousHyperParameterRange])
     (Maybe [ContinuousHyperParameterRange])
     (Maybe [ContinuousHyperParameterRange])
     (Maybe [ContinuousHyperParameterRange])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ContinuousHyperParameterRange]
  [ContinuousHyperParameterRange]
  [ContinuousHyperParameterRange]
  [ContinuousHyperParameterRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON HyperParameterRanges where
  parseJSON :: Value -> Parser HyperParameterRanges
parseJSON =
    String
-> (Object -> Parser HyperParameterRanges)
-> Value
-> Parser HyperParameterRanges
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HyperParameterRanges"
      ( \Object
x ->
          Maybe [IntegerHyperParameterRange]
-> Maybe [CategoricalHyperParameterRange]
-> Maybe [ContinuousHyperParameterRange]
-> HyperParameterRanges
HyperParameterRanges'
            (Maybe [IntegerHyperParameterRange]
 -> Maybe [CategoricalHyperParameterRange]
 -> Maybe [ContinuousHyperParameterRange]
 -> HyperParameterRanges)
-> Parser (Maybe [IntegerHyperParameterRange])
-> Parser
     (Maybe [CategoricalHyperParameterRange]
      -> Maybe [ContinuousHyperParameterRange] -> HyperParameterRanges)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [IntegerHyperParameterRange]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"integerHyperParameterRanges"
                            Parser (Maybe (Maybe [IntegerHyperParameterRange]))
-> Maybe [IntegerHyperParameterRange]
-> Parser (Maybe [IntegerHyperParameterRange])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [IntegerHyperParameterRange]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [CategoricalHyperParameterRange]
   -> Maybe [ContinuousHyperParameterRange] -> HyperParameterRanges)
-> Parser (Maybe [CategoricalHyperParameterRange])
-> Parser
     (Maybe [ContinuousHyperParameterRange] -> HyperParameterRanges)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [CategoricalHyperParameterRange]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"categoricalHyperParameterRanges"
                            Parser (Maybe (Maybe [CategoricalHyperParameterRange]))
-> Maybe [CategoricalHyperParameterRange]
-> Parser (Maybe [CategoricalHyperParameterRange])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CategoricalHyperParameterRange]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [ContinuousHyperParameterRange] -> HyperParameterRanges)
-> Parser (Maybe [ContinuousHyperParameterRange])
-> Parser HyperParameterRanges
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [ContinuousHyperParameterRange]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"continuousHyperParameterRanges"
                            Parser (Maybe (Maybe [ContinuousHyperParameterRange]))
-> Maybe [ContinuousHyperParameterRange]
-> Parser (Maybe [ContinuousHyperParameterRange])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ContinuousHyperParameterRange]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable HyperParameterRanges

instance Prelude.NFData HyperParameterRanges

instance Core.ToJSON HyperParameterRanges where
  toJSON :: HyperParameterRanges -> Value
toJSON HyperParameterRanges' {Maybe [CategoricalHyperParameterRange]
Maybe [ContinuousHyperParameterRange]
Maybe [IntegerHyperParameterRange]
continuousHyperParameterRanges :: Maybe [ContinuousHyperParameterRange]
categoricalHyperParameterRanges :: Maybe [CategoricalHyperParameterRange]
integerHyperParameterRanges :: Maybe [IntegerHyperParameterRange]
$sel:continuousHyperParameterRanges:HyperParameterRanges' :: HyperParameterRanges -> Maybe [ContinuousHyperParameterRange]
$sel:categoricalHyperParameterRanges:HyperParameterRanges' :: HyperParameterRanges -> Maybe [CategoricalHyperParameterRange]
$sel:integerHyperParameterRanges:HyperParameterRanges' :: HyperParameterRanges -> Maybe [IntegerHyperParameterRange]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"integerHyperParameterRanges" Text -> [IntegerHyperParameterRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([IntegerHyperParameterRange] -> Pair)
-> Maybe [IntegerHyperParameterRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [IntegerHyperParameterRange]
integerHyperParameterRanges,
            (Text
"categoricalHyperParameterRanges" Text -> [CategoricalHyperParameterRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([CategoricalHyperParameterRange] -> Pair)
-> Maybe [CategoricalHyperParameterRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CategoricalHyperParameterRange]
categoricalHyperParameterRanges,
            (Text
"continuousHyperParameterRanges" Text -> [ContinuousHyperParameterRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ContinuousHyperParameterRange] -> Pair)
-> Maybe [ContinuousHyperParameterRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ContinuousHyperParameterRange]
continuousHyperParameterRanges
          ]
      )