{-# 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.AppSync.Types.CodeErrorLocation
-- 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.AppSync.Types.CodeErrorLocation 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

-- | Describes the location of the error in a code sample.
--
-- /See:/ 'newCodeErrorLocation' smart constructor.
data CodeErrorLocation = CodeErrorLocation'
  { -- | The column number in the code. Defaults to @0@ if unknown.
    CodeErrorLocation -> Maybe Int
column :: Prelude.Maybe Prelude.Int,
    -- | The line number in the code. Defaults to @0@ if unknown.
    CodeErrorLocation -> Maybe Int
line :: Prelude.Maybe Prelude.Int,
    -- | The span\/length of the error. Defaults to @-1@ if unknown.
    CodeErrorLocation -> Maybe Int
span :: Prelude.Maybe Prelude.Int
  }
  deriving (CodeErrorLocation -> CodeErrorLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeErrorLocation -> CodeErrorLocation -> Bool
$c/= :: CodeErrorLocation -> CodeErrorLocation -> Bool
== :: CodeErrorLocation -> CodeErrorLocation -> Bool
$c== :: CodeErrorLocation -> CodeErrorLocation -> Bool
Prelude.Eq, ReadPrec [CodeErrorLocation]
ReadPrec CodeErrorLocation
Int -> ReadS CodeErrorLocation
ReadS [CodeErrorLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeErrorLocation]
$creadListPrec :: ReadPrec [CodeErrorLocation]
readPrec :: ReadPrec CodeErrorLocation
$creadPrec :: ReadPrec CodeErrorLocation
readList :: ReadS [CodeErrorLocation]
$creadList :: ReadS [CodeErrorLocation]
readsPrec :: Int -> ReadS CodeErrorLocation
$creadsPrec :: Int -> ReadS CodeErrorLocation
Prelude.Read, Int -> CodeErrorLocation -> ShowS
[CodeErrorLocation] -> ShowS
CodeErrorLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeErrorLocation] -> ShowS
$cshowList :: [CodeErrorLocation] -> ShowS
show :: CodeErrorLocation -> String
$cshow :: CodeErrorLocation -> String
showsPrec :: Int -> CodeErrorLocation -> ShowS
$cshowsPrec :: Int -> CodeErrorLocation -> ShowS
Prelude.Show, forall x. Rep CodeErrorLocation x -> CodeErrorLocation
forall x. CodeErrorLocation -> Rep CodeErrorLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeErrorLocation x -> CodeErrorLocation
$cfrom :: forall x. CodeErrorLocation -> Rep CodeErrorLocation x
Prelude.Generic)

-- |
-- Create a value of 'CodeErrorLocation' 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:
--
-- 'column', 'codeErrorLocation_column' - The column number in the code. Defaults to @0@ if unknown.
--
-- 'line', 'codeErrorLocation_line' - The line number in the code. Defaults to @0@ if unknown.
--
-- 'span', 'codeErrorLocation_span' - The span\/length of the error. Defaults to @-1@ if unknown.
newCodeErrorLocation ::
  CodeErrorLocation
newCodeErrorLocation :: CodeErrorLocation
newCodeErrorLocation =
  CodeErrorLocation'
    { $sel:column:CodeErrorLocation' :: Maybe Int
column = forall a. Maybe a
Prelude.Nothing,
      $sel:line:CodeErrorLocation' :: Maybe Int
line = forall a. Maybe a
Prelude.Nothing,
      $sel:span:CodeErrorLocation' :: Maybe Int
span = forall a. Maybe a
Prelude.Nothing
    }

-- | The column number in the code. Defaults to @0@ if unknown.
codeErrorLocation_column :: Lens.Lens' CodeErrorLocation (Prelude.Maybe Prelude.Int)
codeErrorLocation_column :: Lens' CodeErrorLocation (Maybe Int)
codeErrorLocation_column = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeErrorLocation' {Maybe Int
column :: Maybe Int
$sel:column:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
column} -> Maybe Int
column) (\s :: CodeErrorLocation
s@CodeErrorLocation' {} Maybe Int
a -> CodeErrorLocation
s {$sel:column:CodeErrorLocation' :: Maybe Int
column = Maybe Int
a} :: CodeErrorLocation)

-- | The line number in the code. Defaults to @0@ if unknown.
codeErrorLocation_line :: Lens.Lens' CodeErrorLocation (Prelude.Maybe Prelude.Int)
codeErrorLocation_line :: Lens' CodeErrorLocation (Maybe Int)
codeErrorLocation_line = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeErrorLocation' {Maybe Int
line :: Maybe Int
$sel:line:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
line} -> Maybe Int
line) (\s :: CodeErrorLocation
s@CodeErrorLocation' {} Maybe Int
a -> CodeErrorLocation
s {$sel:line:CodeErrorLocation' :: Maybe Int
line = Maybe Int
a} :: CodeErrorLocation)

-- | The span\/length of the error. Defaults to @-1@ if unknown.
codeErrorLocation_span :: Lens.Lens' CodeErrorLocation (Prelude.Maybe Prelude.Int)
codeErrorLocation_span :: Lens' CodeErrorLocation (Maybe Int)
codeErrorLocation_span = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeErrorLocation' {Maybe Int
span :: Maybe Int
$sel:span:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
span} -> Maybe Int
span) (\s :: CodeErrorLocation
s@CodeErrorLocation' {} Maybe Int
a -> CodeErrorLocation
s {$sel:span:CodeErrorLocation' :: Maybe Int
span = Maybe Int
a} :: CodeErrorLocation)

instance Data.FromJSON CodeErrorLocation where
  parseJSON :: Value -> Parser CodeErrorLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CodeErrorLocation"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> Maybe Int -> CodeErrorLocation
CodeErrorLocation'
            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
"column")
            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
"line")
            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
"span")
      )

instance Prelude.Hashable CodeErrorLocation where
  hashWithSalt :: Int -> CodeErrorLocation -> Int
hashWithSalt Int
_salt CodeErrorLocation' {Maybe Int
span :: Maybe Int
line :: Maybe Int
column :: Maybe Int
$sel:span:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
$sel:line:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
$sel:column:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
column
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
line
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
span

instance Prelude.NFData CodeErrorLocation where
  rnf :: CodeErrorLocation -> ()
rnf CodeErrorLocation' {Maybe Int
span :: Maybe Int
line :: Maybe Int
column :: Maybe Int
$sel:span:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
$sel:line:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
$sel:column:CodeErrorLocation' :: CodeErrorLocation -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
column
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
line
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
span