{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE CPP #-}
#if MIN_VERSION_lens(5,0,0)
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Trustworthy #-}
#endif
-- |
-- Module       : Data.Text.Encoding.Base16.Error.Lens
-- Copyright    : (c) 2019-2020 Emily Pillmore
-- License      : BSD-style
--
-- Maintainer   : Emily Pillmore <emilypi@cohomolo.gy>
-- Stability    : Experimental
-- Portability  : non-portable
--
-- This module contains 'Prism''s for the `Data.Text.Encoding.Base16.Error.Base16Error`
-- datatype.
--
module Data.Text.Encoding.Base16.Error.Lens
( -- * Prisms
  _DecodeError
, _ConversionError
) where


import Control.Lens

import Data.Text (Text)
import Data.Text.Encoding.Base16.Error (Base16Error(..))


-- | A 'Prism'' into the 'DecodeError' case of a 'Base16Error'
--
_DecodeError :: Prism' (Base16Error err) Text
_DecodeError :: p Text (f Text) -> p (Base16Error err) (f (Base16Error err))
_DecodeError = (Text -> Base16Error err)
-> (Base16Error err -> Maybe Text)
-> Prism (Base16Error err) (Base16Error err) Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' Text -> Base16Error err
forall e. Text -> Base16Error e
DecodeError ((Base16Error err -> Maybe Text)
 -> Prism (Base16Error err) (Base16Error err) Text Text)
-> (Base16Error err -> Maybe Text)
-> Prism (Base16Error err) (Base16Error err) Text Text
forall a b. (a -> b) -> a -> b
$ \case
    DecodeError Text
t -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
t
    ConversionError{} -> Maybe Text
forall a. Maybe a
Nothing

-- | A 'Prism'' into the 'ConversionError' case of a 'Base16Error'
--
_ConversionError :: Prism' (Base16Error err) err
_ConversionError :: p err (f err) -> p (Base16Error err) (f (Base16Error err))
_ConversionError = (err -> Base16Error err)
-> (Base16Error err -> Maybe err)
-> Prism (Base16Error err) (Base16Error err) err err
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' err -> Base16Error err
forall e. e -> Base16Error e
ConversionError ((Base16Error err -> Maybe err)
 -> Prism (Base16Error err) (Base16Error err) err err)
-> (Base16Error err -> Maybe err)
-> Prism (Base16Error err) (Base16Error err) err err
forall a b. (a -> b) -> a -> b
$ \case
    ConversionError err
err -> err -> Maybe err
forall a. a -> Maybe a
Just err
err
    DecodeError{} -> Maybe err
forall a. Maybe a
Nothing