ModuleCabal-syntax-3.12.1.0Haskell2010
Distribution.Compat.Lens
This module provides very basic lens functionality, without extra dependencies.
For the documentation of the combinators see lens package. This module uses the same vocabulary.
- 12 types
- 23 values
- PackageCabal-syntax-3.12.1.0
- Exports35
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceLens.hs
Types
4 declarationsLensLike
rank-1 types
Getter
3 declarations(3 :: Int) ^. getting (+2) . getting show"5"
Setter
2 declarationsFold
3 declarationsLens
2 declarationsCommon lenses
2 declarationsOperators
11 declarations& is a reverse application operator
Internal Comonads
1 declarationlens variant is also parametrised by profunctor.
Constructors
PretextrunPretext :: forall (f :: Type -> Type). Functor f => (a -> f b) -> f t
Cabal developer info
0 declarationsWe cannot depend on template-haskell, because Cabal is a boot library.
This fact makes defining optics a manual task. Here is a small recipe to
make the process less tedious.
First start a repl
cabal new-repl Cabal-tests:hackage-testsBecause --extra-package isn't yet implemented, we use a test-suite
with generics-sop dependency.
In the repl, we load a helper script:
:l ../generics-sop-lens.hsNow we are set up to derive lenses!
:m +Distribution.Types.SourceRepo
putStr $ genericLenses (Proxy :: Proxy SourceRepo)repoKind :: Lens' SourceRepo RepoKind
repoKind f s = fmap (\x -> s { T.repoKind = x }) (f (T.repoKind s))
{-# INLINE repoKind #-}
...
Note: You may need to adjust type-aliases, e.g. String to FilePath.