{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Waargonaut.Types.CommaSep.Elem
(
Elem (..)
, HasElem (..)
, Comma (Comma)
, _ElemTrailingIso
, parseComma
, parseCommaTrailingMaybe
) where
import Prelude (Eq, Show (showsPrec), showString,
shows, (&&), (==))
import Control.Applicative (Applicative (..), liftA2, pure, (<*>))
import Control.Category (id, (.))
import Control.Lens (Iso, Iso', Lens', from, iso, (^.))
import Data.Bifoldable (Bifoldable (bifoldMap))
import Data.Bifunctor (Bifunctor (bimap))
import Data.Bitraversable (Bitraversable (bitraverse))
import Data.Foldable (Foldable, foldMap)
import Data.Functor (Functor, fmap, (<$), (<$>))
import Data.Functor.Classes (Eq1, Show1, eq1, showsPrec1)
import Data.Maybe (Maybe (..), fromMaybe)
import Data.Monoid (Monoid (..), mempty)
import Data.Traversable (Traversable, traverse)
import Data.Functor.Identity (Identity (..))
import Text.Parser.Char (CharParsing)
import qualified Text.Parser.Char as C
import qualified Text.Parser.Combinators as C
data Comma = Comma
deriving (Comma -> Comma -> Bool
(Comma -> Comma -> Bool) -> (Comma -> Comma -> Bool) -> Eq Comma
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Comma -> Comma -> Bool
$c/= :: Comma -> Comma -> Bool
== :: Comma -> Comma -> Bool
$c== :: Comma -> Comma -> Bool
Eq, Int -> Comma -> ShowS
[Comma] -> ShowS
Comma -> String
(Int -> Comma -> ShowS)
-> (Comma -> String) -> ([Comma] -> ShowS) -> Show Comma
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Comma] -> ShowS
$cshowList :: [Comma] -> ShowS
show :: Comma -> String
$cshow :: Comma -> String
showsPrec :: Int -> Comma -> ShowS
$cshowsPrec :: Int -> Comma -> ShowS
Show)
parseComma :: CharParsing f => f Comma
parseComma :: f Comma
parseComma = Comma
Comma Comma -> f Char -> f Comma
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> f Char
forall (m :: * -> *). CharParsing m => Char -> m Char
C.char Char
','
{-# INLINE parseComma #-}
parseCommaTrailingMaybe
:: CharParsing f
=> f ws
-> f (Maybe (Comma, ws))
parseCommaTrailingMaybe :: f ws -> f (Maybe (Comma, ws))
parseCommaTrailingMaybe =
f (Comma, ws) -> f (Maybe (Comma, ws))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
C.optional (f (Comma, ws) -> f (Maybe (Comma, ws)))
-> (f ws -> f (Comma, ws)) -> f ws -> f (Maybe (Comma, ws))
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Comma -> ws -> (Comma, ws)) -> f Comma -> f ws -> f (Comma, ws)
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (,) f Comma
forall (f :: * -> *). CharParsing f => f Comma
parseComma
data Elem f ws a = Elem
{ Elem f ws a -> a
_elemVal :: a
, Elem f ws a -> f (Comma, ws)
_elemTrailing :: f (Comma, ws)
}
deriving (a -> Elem f ws b -> Elem f ws a
(a -> b) -> Elem f ws a -> Elem f ws b
(forall a b. (a -> b) -> Elem f ws a -> Elem f ws b)
-> (forall a b. a -> Elem f ws b -> Elem f ws a)
-> Functor (Elem f ws)
forall a b. a -> Elem f ws b -> Elem f ws a
forall a b. (a -> b) -> Elem f ws a -> Elem f ws b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (f :: * -> *) ws a b. a -> Elem f ws b -> Elem f ws a
forall (f :: * -> *) ws a b. (a -> b) -> Elem f ws a -> Elem f ws b
<$ :: a -> Elem f ws b -> Elem f ws a
$c<$ :: forall (f :: * -> *) ws a b. a -> Elem f ws b -> Elem f ws a
fmap :: (a -> b) -> Elem f ws a -> Elem f ws b
$cfmap :: forall (f :: * -> *) ws a b. (a -> b) -> Elem f ws a -> Elem f ws b
Functor, Elem f ws a -> Bool
(a -> m) -> Elem f ws a -> m
(a -> b -> b) -> b -> Elem f ws a -> b
(forall m. Monoid m => Elem f ws m -> m)
-> (forall m a. Monoid m => (a -> m) -> Elem f ws a -> m)
-> (forall m a. Monoid m => (a -> m) -> Elem f ws a -> m)
-> (forall a b. (a -> b -> b) -> b -> Elem f ws a -> b)
-> (forall a b. (a -> b -> b) -> b -> Elem f ws a -> b)
-> (forall b a. (b -> a -> b) -> b -> Elem f ws a -> b)
-> (forall b a. (b -> a -> b) -> b -> Elem f ws a -> b)
-> (forall a. (a -> a -> a) -> Elem f ws a -> a)
-> (forall a. (a -> a -> a) -> Elem f ws a -> a)
-> (forall a. Elem f ws a -> [a])
-> (forall a. Elem f ws a -> Bool)
-> (forall a. Elem f ws a -> Int)
-> (forall a. Eq a => a -> Elem f ws a -> Bool)
-> (forall a. Ord a => Elem f ws a -> a)
-> (forall a. Ord a => Elem f ws a -> a)
-> (forall a. Num a => Elem f ws a -> a)
-> (forall a. Num a => Elem f ws a -> a)
-> Foldable (Elem f ws)
forall a. Eq a => a -> Elem f ws a -> Bool
forall a. Num a => Elem f ws a -> a
forall a. Ord a => Elem f ws a -> a
forall m. Monoid m => Elem f ws m -> m
forall a. Elem f ws a -> Bool
forall a. Elem f ws a -> Int
forall a. Elem f ws a -> [a]
forall a. (a -> a -> a) -> Elem f ws a -> a
forall m a. Monoid m => (a -> m) -> Elem f ws a -> m
forall b a. (b -> a -> b) -> b -> Elem f ws a -> b
forall a b. (a -> b -> b) -> b -> Elem f ws a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
forall (f :: * -> *) ws a. Eq a => a -> Elem f ws a -> Bool
forall (f :: * -> *) ws a. Num a => Elem f ws a -> a
forall (f :: * -> *) ws a. Ord a => Elem f ws a -> a
forall (f :: * -> *) ws m. Monoid m => Elem f ws m -> m
forall (f :: * -> *) ws a. Elem f ws a -> Bool
forall (f :: * -> *) ws a. Elem f ws a -> Int
forall (f :: * -> *) ws a. Elem f ws a -> [a]
forall (f :: * -> *) ws a. (a -> a -> a) -> Elem f ws a -> a
forall (f :: * -> *) ws m a.
Monoid m =>
(a -> m) -> Elem f ws a -> m
forall (f :: * -> *) ws b a. (b -> a -> b) -> b -> Elem f ws a -> b
forall (f :: * -> *) ws a b. (a -> b -> b) -> b -> Elem f ws a -> b
product :: Elem f ws a -> a
$cproduct :: forall (f :: * -> *) ws a. Num a => Elem f ws a -> a
sum :: Elem f ws a -> a
$csum :: forall (f :: * -> *) ws a. Num a => Elem f ws a -> a
minimum :: Elem f ws a -> a
$cminimum :: forall (f :: * -> *) ws a. Ord a => Elem f ws a -> a
maximum :: Elem f ws a -> a
$cmaximum :: forall (f :: * -> *) ws a. Ord a => Elem f ws a -> a
elem :: a -> Elem f ws a -> Bool
$celem :: forall (f :: * -> *) ws a. Eq a => a -> Elem f ws a -> Bool
length :: Elem f ws a -> Int
$clength :: forall (f :: * -> *) ws a. Elem f ws a -> Int
null :: Elem f ws a -> Bool
$cnull :: forall (f :: * -> *) ws a. Elem f ws a -> Bool
toList :: Elem f ws a -> [a]
$ctoList :: forall (f :: * -> *) ws a. Elem f ws a -> [a]
foldl1 :: (a -> a -> a) -> Elem f ws a -> a
$cfoldl1 :: forall (f :: * -> *) ws a. (a -> a -> a) -> Elem f ws a -> a
foldr1 :: (a -> a -> a) -> Elem f ws a -> a
$cfoldr1 :: forall (f :: * -> *) ws a. (a -> a -> a) -> Elem f ws a -> a
foldl' :: (b -> a -> b) -> b -> Elem f ws a -> b
$cfoldl' :: forall (f :: * -> *) ws b a. (b -> a -> b) -> b -> Elem f ws a -> b
foldl :: (b -> a -> b) -> b -> Elem f ws a -> b
$cfoldl :: forall (f :: * -> *) ws b a. (b -> a -> b) -> b -> Elem f ws a -> b
foldr' :: (a -> b -> b) -> b -> Elem f ws a -> b
$cfoldr' :: forall (f :: * -> *) ws a b. (a -> b -> b) -> b -> Elem f ws a -> b
foldr :: (a -> b -> b) -> b -> Elem f ws a -> b
$cfoldr :: forall (f :: * -> *) ws a b. (a -> b -> b) -> b -> Elem f ws a -> b
foldMap' :: (a -> m) -> Elem f ws a -> m
$cfoldMap' :: forall (f :: * -> *) ws m a.
Monoid m =>
(a -> m) -> Elem f ws a -> m
foldMap :: (a -> m) -> Elem f ws a -> m
$cfoldMap :: forall (f :: * -> *) ws m a.
Monoid m =>
(a -> m) -> Elem f ws a -> m
fold :: Elem f ws m -> m
$cfold :: forall (f :: * -> *) ws m. Monoid m => Elem f ws m -> m
Foldable, Functor (Elem f ws)
Foldable (Elem f ws)
Functor (Elem f ws)
-> Foldable (Elem f ws)
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Elem f ws a -> f (Elem f ws b))
-> (forall (f :: * -> *) a.
Applicative f =>
Elem f ws (f a) -> f (Elem f ws a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Elem f ws a -> m (Elem f ws b))
-> (forall (m :: * -> *) a.
Monad m =>
Elem f ws (m a) -> m (Elem f ws a))
-> Traversable (Elem f ws)
(a -> f b) -> Elem f ws a -> f (Elem f ws b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) ws. Functor (Elem f ws)
forall (f :: * -> *) ws. Foldable (Elem f ws)
forall (m :: * -> *) a.
Monad m =>
Elem f ws (m a) -> m (Elem f ws a)
forall (f :: * -> *) a.
Applicative f =>
Elem f ws (f a) -> f (Elem f ws a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Elem f ws a -> m (Elem f ws b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Elem f ws a -> f (Elem f ws b)
forall (f :: * -> *) ws (m :: * -> *) a.
Monad m =>
Elem f ws (m a) -> m (Elem f ws a)
forall (f :: * -> *) ws (f :: * -> *) a.
Applicative f =>
Elem f ws (f a) -> f (Elem f ws a)
forall (f :: * -> *) ws (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Elem f ws a -> m (Elem f ws b)
forall (f :: * -> *) ws (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Elem f ws a -> f (Elem f ws b)
sequence :: Elem f ws (m a) -> m (Elem f ws a)
$csequence :: forall (f :: * -> *) ws (m :: * -> *) a.
Monad m =>
Elem f ws (m a) -> m (Elem f ws a)
mapM :: (a -> m b) -> Elem f ws a -> m (Elem f ws b)
$cmapM :: forall (f :: * -> *) ws (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Elem f ws a -> m (Elem f ws b)
sequenceA :: Elem f ws (f a) -> f (Elem f ws a)
$csequenceA :: forall (f :: * -> *) ws (f :: * -> *) a.
Applicative f =>
Elem f ws (f a) -> f (Elem f ws a)
traverse :: (a -> f b) -> Elem f ws a -> f (Elem f ws b)
$ctraverse :: forall (f :: * -> *) ws (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Elem f ws a -> f (Elem f ws b)
$cp2Traversable :: forall (f :: * -> *) ws. Foldable (Elem f ws)
$cp1Traversable :: forall (f :: * -> *) ws. Functor (Elem f ws)
Traversable)
instance (Monoid ws, Applicative f) => Applicative (Elem f ws) where
pure :: a -> Elem f ws a
pure a
a = a -> f (Comma, ws) -> Elem f ws a
forall (f :: * -> *) ws a. a -> f (Comma, ws) -> Elem f ws a
Elem a
a ((Comma, ws) -> f (Comma, ws)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Comma
Comma, ws
forall a. Monoid a => a
mempty))
(Elem a -> b
atob f (Comma, ws)
_) <*> :: Elem f ws (a -> b) -> Elem f ws a -> Elem f ws b
<*> (Elem a
a f (Comma, ws)
t') = b -> f (Comma, ws) -> Elem f ws b
forall (f :: * -> *) ws a. a -> f (Comma, ws) -> Elem f ws a
Elem (a -> b
atob a
a) f (Comma, ws)
t'
instance Functor f => Bifunctor (Elem f) where
bimap :: (a -> b) -> (c -> d) -> Elem f a c -> Elem f b d
bimap a -> b
f c -> d
g (Elem c
a f (Comma, a)
t) = d -> f (Comma, b) -> Elem f b d
forall (f :: * -> *) ws a. a -> f (Comma, ws) -> Elem f ws a
Elem (c -> d
g c
a) (((Comma, a) -> (Comma, b)) -> f (Comma, a) -> f (Comma, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> (Comma, a) -> (Comma, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) f (Comma, a)
t)
instance Foldable f => Bifoldable (Elem f) where
bifoldMap :: (a -> m) -> (b -> m) -> Elem f a b -> m
bifoldMap a -> m
f b -> m
g (Elem b
a f (Comma, a)
t) = b -> m
g b
a m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` ((Comma, a) -> m) -> f (Comma, a) -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap ((a -> m) -> (Comma, a) -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f) f (Comma, a)
t
instance Traversable f => Bitraversable (Elem f) where
bitraverse :: (a -> f c) -> (b -> f d) -> Elem f a b -> f (Elem f c d)
bitraverse a -> f c
f b -> f d
g (Elem b
a f (Comma, a)
t) = d -> f (Comma, c) -> Elem f c d
forall (f :: * -> *) ws a. a -> f (Comma, ws) -> Elem f ws a
Elem (d -> f (Comma, c) -> Elem f c d)
-> f d -> f (f (Comma, c) -> Elem f c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> b -> f d
g b
a f (f (Comma, c) -> Elem f c d)
-> f (f (Comma, c)) -> f (Elem f c d)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((Comma, a) -> f (Comma, c)) -> f (Comma, a) -> f (f (Comma, c))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((a -> f c) -> (Comma, a) -> f (Comma, c)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f c
f) f (Comma, a)
t
class HasElem c f ws a | c -> f ws a where
elem :: Lens' c (Elem f ws a)
elemTrailing :: Lens' c (f (Comma, ws))
{-# INLINE elemTrailing #-}
elemVal :: Lens' c a
{-# INLINE elemVal #-}
elemTrailing = (Elem f ws a -> f (Elem f ws a)) -> c -> f c
forall c (f :: * -> *) ws a.
HasElem c f ws a =>
Lens' c (Elem f ws a)
elem ((Elem f ws a -> f (Elem f ws a)) -> c -> f c)
-> ((f (Comma, ws) -> f (f (Comma, ws)))
-> Elem f ws a -> f (Elem f ws a))
-> (f (Comma, ws) -> f (f (Comma, ws)))
-> c
-> f c
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (f (Comma, ws) -> f (f (Comma, ws)))
-> Elem f ws a -> f (Elem f ws a)
forall c (f :: * -> *) ws a.
HasElem c f ws a =>
Lens' c (f (Comma, ws))
elemTrailing
elemVal = (Elem f ws a -> f (Elem f ws a)) -> c -> f c
forall c (f :: * -> *) ws a.
HasElem c f ws a =>
Lens' c (Elem f ws a)
elem ((Elem f ws a -> f (Elem f ws a)) -> c -> f c)
-> ((a -> f a) -> Elem f ws a -> f (Elem f ws a))
-> (a -> f a)
-> c
-> f c
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (a -> f a) -> Elem f ws a -> f (Elem f ws a)
forall c (f :: * -> *) ws a. HasElem c f ws a => Lens' c a
elemVal
instance HasElem (Elem f ws a) f ws a where
{-# INLINE elemTrailing #-}
{-# INLINE elemVal #-}
elem :: (Elem f ws a -> f (Elem f ws a)) -> Elem f ws a -> f (Elem f ws a)
elem = (Elem f ws a -> f (Elem f ws a)) -> Elem f ws a -> f (Elem f ws a)
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
elemTrailing :: (f (Comma, ws) -> f (f (Comma, ws)))
-> Elem f ws a -> f (Elem f ws a)
elemTrailing f (Comma, ws) -> f (f (Comma, ws))
f (Elem a
x1 f (Comma, ws)
x2) = a -> f (Comma, ws) -> Elem f ws a
forall (f :: * -> *) ws a. a -> f (Comma, ws) -> Elem f ws a
Elem a
x1 (f (Comma, ws) -> Elem f ws a)
-> f (f (Comma, ws)) -> f (Elem f ws a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (Comma, ws) -> f (f (Comma, ws))
f f (Comma, ws)
x2
elemVal :: (a -> f a) -> Elem f ws a -> f (Elem f ws a)
elemVal a -> f a
f (Elem a
x1 f (Comma, ws)
x2) = (a -> f (Comma, ws) -> Elem f ws a
forall (f :: * -> *) ws a. a -> f (Comma, ws) -> Elem f ws a
`Elem` f (Comma, ws)
x2) (a -> Elem f ws a) -> f a -> f (Elem f ws a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
f a
x1
instance (Show1 f, Show ws, Show a) => Show (Elem f ws a) where
showsPrec :: Int -> Elem f ws a -> ShowS
showsPrec Int
_ (Elem a
v f (Comma, ws)
t) =
String -> ShowS
showString String
"Elem {_elemVal = " ShowS -> ShowS -> ShowS
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> ShowS
forall a. Show a => a -> ShowS
shows a
v ShowS -> ShowS -> ShowS
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
.
String -> ShowS
showString String
", _elemTrailing = " ShowS -> ShowS -> ShowS
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Int -> f (Comma, ws) -> ShowS
forall (f :: * -> *) a. (Show1 f, Show a) => Int -> f a -> ShowS
showsPrec1 Int
0 f (Comma, ws)
t ShowS -> ShowS -> ShowS
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ShowS
showString String
"}"
instance (Eq1 f, Eq ws, Eq a) => Eq (Elem f ws a) where
Elem a
v1 f (Comma, ws)
t1 == :: Elem f ws a -> Elem f ws a -> Bool
== Elem a
v2 f (Comma, ws)
t2 = a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
v2 Bool -> Bool -> Bool
&& f (Comma, ws) -> f (Comma, ws) -> Bool
forall (f :: * -> *) a. (Eq1 f, Eq a) => f a -> f a -> Bool
eq1 f (Comma, ws)
t1 f (Comma, ws)
t2
floopId :: Monoid ws => Iso' (Identity (Comma,ws)) (Maybe (Comma,ws))
floopId :: Iso' (Identity (Comma, ws)) (Maybe (Comma, ws))
floopId = (Identity (Comma, ws) -> Maybe (Comma, ws))
-> (Maybe (Comma, ws) -> Identity (Comma, ws))
-> Iso' (Identity (Comma, ws)) (Maybe (Comma, ws))
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso ((Comma, ws) -> Maybe (Comma, ws)
forall a. a -> Maybe a
Just ((Comma, ws) -> Maybe (Comma, ws))
-> (Identity (Comma, ws) -> (Comma, ws))
-> Identity (Comma, ws)
-> Maybe (Comma, ws)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Identity (Comma, ws) -> (Comma, ws)
forall a. Identity a -> a
runIdentity) ((Comma, ws) -> Identity (Comma, ws)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Comma, ws) -> Identity (Comma, ws))
-> (Maybe (Comma, ws) -> (Comma, ws))
-> Maybe (Comma, ws)
-> Identity (Comma, ws)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Comma, ws) -> Maybe (Comma, ws) -> (Comma, ws)
forall a. a -> Maybe a -> a
fromMaybe (Comma
Comma, ws
forall a. Monoid a => a
mempty))
_ElemTrailingIso
:: ( Monoid ws
, Monoid ws'
)
=> Iso (Elem Identity ws a) (Elem Identity ws' a') (Elem Maybe ws a) (Elem Maybe ws' a')
_ElemTrailingIso :: Iso
(Elem Identity ws a)
(Elem Identity ws' a')
(Elem Maybe ws a)
(Elem Maybe ws' a')
_ElemTrailingIso = (Elem Identity ws a -> Elem Maybe ws a)
-> (Elem Maybe ws' a' -> Elem Identity ws' a')
-> Iso
(Elem Identity ws a)
(Elem Identity ws' a')
(Elem Maybe ws a)
(Elem Maybe ws' a')
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
(\(Elem a
a Identity (Comma, ws)
t) -> a -> Maybe (Comma, ws) -> Elem Maybe ws a
forall (f :: * -> *) ws a. a -> f (Comma, ws) -> Elem f ws a
Elem a
a (Identity (Comma, ws)
t Identity (Comma, ws)
-> Getting
(Maybe (Comma, ws)) (Identity (Comma, ws)) (Maybe (Comma, ws))
-> Maybe (Comma, ws)
forall s a. s -> Getting a s a -> a
^. Getting
(Maybe (Comma, ws)) (Identity (Comma, ws)) (Maybe (Comma, ws))
forall ws.
Monoid ws =>
Iso' (Identity (Comma, ws)) (Maybe (Comma, ws))
floopId))
(\(Elem a'
a Maybe (Comma, ws')
t) -> a' -> Identity (Comma, ws') -> Elem Identity ws' a'
forall (f :: * -> *) ws a. a -> f (Comma, ws) -> Elem f ws a
Elem a'
a (Maybe (Comma, ws')
t Maybe (Comma, ws')
-> Getting
(Identity (Comma, ws'))
(Maybe (Comma, ws'))
(Identity (Comma, ws'))
-> Identity (Comma, ws')
forall s a. s -> Getting a s a -> a
^. AnIso
(Identity (Comma, ws'))
(Identity (Comma, ws'))
(Maybe (Comma, ws'))
(Maybe (Comma, ws'))
-> Iso
(Maybe (Comma, ws'))
(Maybe (Comma, ws'))
(Identity (Comma, ws'))
(Identity (Comma, ws'))
forall s t a b. AnIso s t a b -> Iso b a t s
from AnIso
(Identity (Comma, ws'))
(Identity (Comma, ws'))
(Maybe (Comma, ws'))
(Maybe (Comma, ws'))
forall ws.
Monoid ws =>
Iso' (Identity (Comma, ws)) (Maybe (Comma, ws))
floopId))