{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
#if MIN_VERSION_lens(5,0,0)
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Trustworthy #-}
#endif
-- |
-- Module       : Data.Text.Encoding.Base64.Error.Lens
-- Copyright    : (c) 2019-2021 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.Base64.Error.Base64Error`
-- datatype.
--
module Data.Text.Encoding.Base64.Error.Lens
( -- * Prisms
  _DecodeError
, _ConversionError
) where


import Control.Lens

import Data.Text (Text)
import Data.Text.Encoding.Base64.Error (Base64Error(..))


-- | A 'Prism'' into the 'DecodeError' case of a 'Base64Error'
--
_DecodeError :: Prism' (Base64Error err) Text
_DecodeError :: p Text (f Text) -> p (Base64Error err) (f (Base64Error err))
_DecodeError = (Text -> Base64Error err)
-> (Base64Error err -> Maybe Text)
-> Prism (Base64Error err) (Base64Error err) Text Text
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' Text -> Base64Error err
forall e. Text -> Base64Error e
DecodeError ((Base64Error err -> Maybe Text)
 -> Prism (Base64Error err) (Base64Error err) Text Text)
-> (Base64Error err -> Maybe Text)
-> Prism (Base64Error err) (Base64Error 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 'Base64Error'
--
_ConversionError :: Prism' (Base64Error err) err
_ConversionError :: p err (f err) -> p (Base64Error err) (f (Base64Error err))
_ConversionError = (err -> Base64Error err)
-> (Base64Error err -> Maybe err)
-> Prism (Base64Error err) (Base64Error err) err err
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' err -> Base64Error err
forall e. e -> Base64Error e
ConversionError ((Base64Error err -> Maybe err)
 -> Prism (Base64Error err) (Base64Error err) err err)
-> (Base64Error err -> Maybe err)
-> Prism (Base64Error err) (Base64Error 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