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


import Control.Lens

import Data.Text (Text)
import Data.Text.Encoding.Base32.Error (Base32Error(..))


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