mdoc-0.2.0.0: src/Mdoc/Optics.hs
-- |
--
-- Module : Mdoc.Optics
-- Copyright : (c) 2026 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : pbrisbin@gmail.com
-- Stability : experimental
-- Portability : POSIX
module Mdoc.Optics
( field
-- * Missing Optics
, last1
-- * Application
, (%)
, traversed
, to
-- * Access
, (^.)
-- * Updates
, (.~)
, (?~)
, (%~)
, (<>~)
, (<?>~)
-- * Construction
, Lens'
, lens
, Prism'
, prism
) where
import Mdoc.Prelude
import Data.Generics.Product.Fields
import Optics
last1 :: Lens' (NonEmpty a) a
last1 = lens last $ \x y -> init x |: y
(<>~) :: Semigroup b => Lens' a b -> b -> a -> a
l <>~ w = l %~ (<> w)
infixr 4 <>~
(<?>~) :: Semigroup b => Lens' a (Maybe b) -> b -> a -> a
l <?>~ w = l <>~ Just w
infixr 4 <?>~