------------------------------------------------------------------------------- |-- Module : Control.Lens.Internal-- Copyright : (C) 2012 Edward Kmett-- License : BSD-style (see the file LICENSE)-- Maintainer : Edward Kmett <ekmett@gmail.com>-- Stability : provisional-- Portability : Rank2Types---- These are some of the explicit Functor instances that leak into the-- type signatures of Control.Lens. You shouldn't need to import this-- module directly, unless you are coming up with a whole new kind of-- \"Family\" and need to add instances.------------------------------------------------------------------------------moduleControl.Lens.Internal(-- * Implementation detailsIndexedStore(..),Focusing(..),Traversed(..),Action(..),AppliedState(..),Min(..),getMin,Max(..),getMax)whereimportControl.ApplicativeimportControl.CategoryimportPreludehiding((.),id)importData.Monoid------------------------------------------------------------------------------- Functors------------------------------------------------------------------------------- | Used by 'Focus'newtypeFocusingmca=Focusing{unfocusing::m(c,a)}instanceMonadm=>Functor(Focusingmc)wherefmapf(Focusingm)=Focusing$do(c,a)<-mreturn(c,fa)instance(Monadm,Monoidc)=>Applicative(Focusingmc)wherepurea=Focusing(return(mempty,a))Focusingmf<*>Focusingma=Focusing$do(c,f)<-mf(d,a)<-mareturn(mappendcd,fa)-- | The indexed store can be used to characterize a 'LensFamily'-- and is used by 'clone'dataIndexedStorecda=IndexedStore(d->a)cinstanceFunctor(IndexedStorecd)wherefmapf(IndexedStoregc)=IndexedStore(f.g)c-- | Applicative composition of @State Int@ with a 'Functor', used-- by 'elementOf', 'elementsOf', 'traverseElement', 'traverseElementsOf'newtypeAppliedStatefa=AppliedState{runAppliedState::Int->(fa,Int)}instanceFunctorf=>Functor(AppliedStatef)wherefmapf(AppliedStatem)=AppliedState$\i->casemiof(fa,j)->(fmapffa,j)instanceApplicativef=>Applicative(AppliedStatef)wherepurea=AppliedState(\i->(purea,i))AppliedStatemf<*>AppliedStatema=AppliedState$\i->casemfiof(ff,j)->casemajof(fa,k)->(ff<*>fa,k)-- | Used internally by 'traverseOf_', 'mapM_' and the like.newtypeTraversedf=Traversed{getTraversed::f()}instanceApplicativef=>Monoid(Traversedf)wheremempty=Traversed(pure())Traversedma`mappend`Traversedmb=Traversed(ma*>mb)-- | Used internally by 'mapM_' and the like.newtypeActionm=Action{getAction::m()}instanceMonadm=>Monoid(Actionm)wheremempty=Action(return())Actionma`mappend`Actionmb=Action(ma>>mb)-- | Used for 'minimumOf'dataMina=NoMin|MinainstanceOrda=>Monoid(Mina)wheremempty=NoMinmappendNoMinm=mmappendmNoMin=mmappend(Mina)(Minb)=Min(minab)-- | Obtain the minimumgetMin::Mina->MaybeagetMinNoMin=NothinggetMin(Mina)=Justa-- | Used for 'maximumOf'dataMaxa=NoMax|MaxainstanceOrda=>Monoid(Maxa)wheremempty=NoMaxmappendNoMaxm=mmappendmNoMax=mmappend(Maxa)(Maxb)=Max(maxab)-- | Obtain the maximumgetMax::Maxa->MaybeagetMaxNoMax=NothinggetMax(Maxa)=Justa