{-# LANGUAGE Rank2Types #-}
module Lens.Family2 (
to, LF.view, (LF.^.)
, folding, LF.views, (^..), (^?)
, toListOf, allOf, anyOf, firstOf, lastOf, sumOf, productOf
, lengthOf, nullOf
, LF.backwards
, over, (%~), set, (.~)
, (LF.&)
, (+~), (*~), (-~), (//~), (&&~), (||~), (<>~)
, Lens, Lens'
, Traversal, Traversal'
, Setter, Setter'
, Getter, Getter'
, Fold, Fold'
, LF.LensLike, LF.LensLike'
, LF.FoldLike, LF.FoldLike'
, LF.Constant
, LF.Phantom
, Identical
, Applicative, Foldable, Monoid
, LF.Backwards
) where
import Control.Applicative (Applicative)
import Data.Foldable (Foldable)
import Data.Monoid (Monoid)
import qualified Lens.Family as LF
import Lens.Family2.Unchecked ( Lens, Lens'
, Traversal, Traversal'
, Setter, Setter', Identical
)
type Fold a a' b b' = forall f. (LF.Phantom f, Applicative f) => LF.LensLike f a a' b b'
type Fold' a b = forall f. (LF.Phantom f, Applicative f) => LF.LensLike' f a b
type Getter a a' b b' = forall f. LF.Phantom f => LF.LensLike f a a' b b'
type Getter' a b = forall f. LF.Phantom f=> LF.LensLike' f a b
to :: (a -> b) -> Getter a a' b b'
to = LF.to
folding :: Foldable f => (a -> f b) -> Fold a a' b b'
folding = LF.folding
toListOf :: Fold a a' b b' -> a -> [b]
toListOf l = LF.toListOf l
allOf :: Fold a a' b b' -> (b -> Bool) -> a -> Bool
allOf l = LF.allOf l
anyOf :: Fold a a' b b' -> (b -> Bool) -> a -> Bool
anyOf l = LF.anyOf l
firstOf :: Fold a a' b b' -> a -> Maybe b
firstOf l = LF.firstOf l
lastOf :: Fold a a' b b' -> a -> Maybe b
lastOf l = LF.lastOf l
sumOf :: Num b => Fold a a' b b' -> a -> b
sumOf l = LF.sumOf l
productOf :: Num b => Fold a a' b b' -> a -> b
productOf l = LF.productOf l
lengthOf :: Num r => Fold a a' b b' -> a -> r
lengthOf l = LF.lengthOf l
nullOf :: Fold a a' b b' -> a -> Bool
nullOf l = LF.nullOf l
infixr 8 ^..
(^..) :: a -> Fold a a' b b' -> [b]
x^..l = x LF.^.. l
infixr 8 ^?
(^?) :: a -> Fold a a' b b' -> Maybe b
x^?l = x LF.^? l
over :: Setter a a' b b' -> (b -> b') -> a -> a'
over l = LF.over l
infixr 4 %~
(%~) :: Setter a a' b b' -> (b -> b') -> a -> a'
l %~ f = l LF.%~ f
infixr 4 .~
(.~) :: Setter a a' b b' -> b' -> a -> a'
l .~ b = l LF..~ b
set :: Setter a a' b b' -> b' -> a -> a'
set l = LF.set l
infixr 4 +~, -~, *~
(+~), (-~), (*~) :: Num b => Setter' a b -> b -> a -> a
f +~ b = f LF.+~ b
f -~ b = f LF.-~ b
f *~ b = f LF.*~ b
infixr 4 //~
(//~) :: Fractional b => Setter' a b -> b -> a -> a
f //~ b = f LF.//~ b
infixr 4 &&~, ||~
(&&~), (||~) :: Setter' a Bool -> Bool -> a -> a
f &&~ b = f LF.&&~ b
f ||~ b = f LF.||~ b
infixr 4 <>~
(<>~) :: (Monoid o) => Setter' a o -> o -> a -> a
f <>~ o = f LF.<>~ o