    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE PatternSynonyms #-}
    {-# LANGUAGE ViewPatterns #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  Data.Dynamic.Lens
    -- Copyright   :  (C) 2012-2016 Edward Kmett
    -- License     :  BSD-style (see the file LICENSE)
    -- Maintainer  :  Edward Kmett <ekmett@gmail.com>
    -- Stability   :  experimental
    -- Portability :  non-portable
    --
    ----------------------------------------------------------------------------
    module Data.Dynamic.Lens
      ( AsDynamic(..)
      , pattern Data.Dynamic.Lens.Dynamic
      ) where

    import Control.Exception
    import Control.Exception.Lens
    import Control.Lens
    import Data.Dynamic

    -- | Any t'Dynamic' can be thrown as an t'Exception'
    class AsDynamic t where
      -- | This t'Prism' allows you to traverse the typed value contained in a
      -- t'Dynamic' where the type required by your function matches that
      -- of the contents of the t'Dynamic', or construct a t'Dynamic' value
      -- out of whole cloth. It can also be used to catch or throw a t'Dynamic'
      -- value as 'SomeException'.
      --
      -- @
      -- '_Dynamic' :: 'Typeable' a => 'Prism'' t'Dynamic'      a
      -- '_Dynamic' :: 'Typeable' a => 'Prism'' 'SomeException' a
      -- @
      _Dynamic :: Typeable a => Prism' t a

    instance AsDynamic Dynamic where
      _Dynamic :: forall a. Typeable a => Prism' Dynamic a
    _Dynamic = (a -> Dynamic) -> (Dynamic -> Maybe a) -> Prism Dynamic Dynamic a a
    forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
    prism' a -> Dynamic
    forall a. Typeable a => a -> Dynamic
    toDyn Dynamic -> Maybe a
    forall a. Typeable a => Dynamic -> Maybe a
    fromDynamic
      {-# INLINE _Dynamic #-}

    instance AsDynamic SomeException where
      _Dynamic :: forall a. Typeable a => Prism' SomeException a
    _Dynamic = p Dynamic (f Dynamic) -> p SomeException (f SomeException)
    forall a. Exception a => Prism' SomeException a
    Prism' SomeException Dynamic
    exception(p Dynamic (f Dynamic) -> p SomeException (f SomeException))
    -> (p a (f a) -> p Dynamic (f Dynamic))
    -> p a (f a)
    -> p SomeException (f SomeException)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .(a -> Dynamic) -> (Dynamic -> Maybe a) -> Prism Dynamic Dynamic a a
    forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
    prism' a -> Dynamic
    forall a. Typeable a => a -> Dynamic
    toDyn Dynamic -> Maybe a
    forall a. Typeable a => Dynamic -> Maybe a
    fromDynamic
      {-# INLINE _Dynamic #-}

    pattern Dynamic :: (AsDynamic s, Typeable a) => a -> s
    pattern $mDynamic :: forall {r} {s} {a}.
    (AsDynamic s, Typeable a) =>
    s -> (a -> r) -> ((# #) -> r) -> r
    $bDynamic :: forall s a. (AsDynamic s, Typeable a) => a -> s
    Dynamic a <- (preview _Dynamic -> Just a) where
      Dynamic a
    a = AReview s a -> a -> s
    forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
    review AReview s a
    forall a. Typeable a => Prism' s a
    forall t a. (AsDynamic t, Typeable a) => Prism' t a
    Prism' s a
    _Dynamic a
    a