1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
|
name: lens
category: Data, Lenses, Generics
version: 4.14
license: BSD3
cabal-version: >= 1.8
license-file: LICENSE
author: Edward A. Kmett
maintainer: Edward A. Kmett <ekmett@gmail.com>
stability: provisional
homepage: http://github.com/ekmett/lens/
bug-reports: http://github.com/ekmett/lens/issues
copyright: Copyright (C) 2012-2016 Edward A. Kmett
build-type: Custom
-- build-tools: cpphs
tested-with: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1, GHC == 7.10.2, GHC == 8.0.1
synopsis: Lenses, Folds and Traversals
description:
This package comes \"Batteries Included\" with many useful lenses for the types
commonly used from the Haskell Platform, and with tools for automatically
generating lenses and isomorphisms for user-supplied data types.
.
The combinators in @Control.Lens@ provide a highly generic toolbox for composing
families of getters, folds, isomorphisms, traversals, setters and lenses and their
indexed variants.
.
An overview, with a large number of examples can be found in the <https://github.com/ekmett/lens#lens-lenses-folds-and-traversals README>.
.
An introductory video on the style of code used in this library by Simon Peyton Jones is available from <http://skillsmatter.com/podcast/scala/lenses-compositional-data-access-and-manipulation Skills Matter>.
.
A video on how to use lenses and how they are constructed is available on <http://youtu.be/cefnmjtAolY?hd=1 youtube>.
.
Slides for that second talk can be obtained from <http://comonad.com/haskell/Lenses-Folds-and-Traversals-NYC.pdf comonad.com>.
.
More information on the care and feeding of lenses, including a brief tutorial and motivation
for their types can be found on the <https://github.com/ekmett/lens/wiki lens wiki>.
.
A small game of @pong@ and other more complex examples that manage their state using lenses can be found in the <https://github.com/ekmett/lens/blob/master/examples/ example folder>.
.
/Lenses, Folds and Traversals/
.
With some signatures simplified, the core of the hierarchy of lens-like constructions looks like:
.
.
<<http://i.imgur.com/ALlbPRa.png>>
.
<Hierarchy.png (Local Copy)>
.
You can compose any two elements of the hierarchy above using @(.)@ from the @Prelude@, and you can
use any element of the hierarchy as any type it linked to above it.
.
The result is their lowest upper bound in the hierarchy (or an error if that bound doesn't exist).
.
For instance:
.
* You can use any 'Traversal' as a 'Fold' or as a 'Setter'.
.
* The composition of a 'Traversal' and a 'Getter' yields a 'Fold'.
.
/Minimizing Dependencies/
.
If you want to provide lenses and traversals for your own types in your own libraries, then you
can do so without incurring a dependency on this (or any other) lens package at all.
.
/e.g./ for a data type:
.
> data Foo a = Foo Int Int a
.
You can define lenses such as
.
> -- bar :: Lens' (Foo a) Int
> bar :: Functor f => (Int -> f Int) -> Foo a -> f (Foo a)
> bar f (Foo a b c) = fmap (\a' -> Foo a' b c) (f a)
.
> -- quux :: Lens (Foo a) (Foo b) a b
> quux :: Functor f => (a -> f b) -> Foo a -> f (Foo b)
> quux f (Foo a b c) = fmap (Foo a b) (f c)
.
without the need to use any type that isn't already defined in the @Prelude@.
.
And you can define a traversal of multiple fields with 'Control.Applicative.Applicative':
.
> -- traverseBarAndBaz :: Traversal' (Foo a) Int
> traverseBarAndBaz :: Applicative f => (Int -> f Int) -> Foo a -> f (Foo a)
> traverseBarAndBaz f (Foo a b c) = Foo <$> f a <*> f b <*> pure c
.
What is provided in this library is a number of stock lenses and traversals for
common haskell types, a wide array of combinators for working them, and more
exotic functionality, (/e.g./ getters, setters, indexed folds, isomorphisms).
extra-source-files:
.travis.yml
.gitignore
.vim.custom
cabal.project
examples/LICENSE
examples/lens-examples.cabal
examples/*.hs
examples/*.lhs
images/*.png
lens-properties/CHANGELOG.markdown
lens-properties/LICENSE
lens-properties/Setup.hs
travis/cabal-apt-install
travis/config
HLint.hs
AUTHORS.markdown
CHANGELOG.markdown
README.markdown
SUPPORT.markdown
source-repository head
type: git
location: https://github.com/ekmett/lens.git
-- Enable benchmarking against Neil Mitchell's uniplate library for comparative performance analysis. Defaults to being turned off to avoid
-- the extra dependency.
--
-- > cabal configure --enable-benchmarks -fbenchmark-uniplate && cabal build && cabal bench
flag benchmark-uniplate
default: False
manual: True
-- Generate inline pragmas when using template-haskell. This defaults to enabled, but you can
--
-- > cabal install lens -f-inlining
--
-- to shut it off to benchmark the relative performance impact, or as last ditch effort to address compile
-- errors resulting from the myriad versions of template-haskell that all purport to be 2.8.
flag inlining
manual: True
default: True
-- Some 7.6.1-rc1 users report their TH still uses old style inline pragmas. This lets them turn on inlining.
flag old-inline-pragmas
default: False
manual: True
-- Make the test suites dump their template-haskell splices.
flag dump-splices
default: False
manual: True
-- You can disable the hlint test suite with -f-test-hlint
flag test-hlint
default: True
manual: True
-- You can disable the templates test suite with -f-test-templates
flag test-templates
default: True
manual: True
-- You can disable the doctests test suite with -f-test-doctests
flag test-doctests
default: True
manual: True
-- You can disable the hunit test suite with -f-test-hunit
flag test-hunit
default: True
manual: True
-- Build the properties test if we're building tests
flag test-properties
default: True
manual: True
flag test-templates
default: True
manual: True
-- Disallow unsafeCoerce
flag safe
default: False
manual: True
-- Assert that we are trustworthy when we can
flag trustworthy
default: True
manual: True
-- Attempt a parallel build with GHC 7.8
flag j
default: False
manual: True
library
build-depends:
array >= 0.3.0.2 && < 0.6,
base >= 4.5 && < 5,
base-orphans >= 0.3 && < 1,
bifunctors >= 5 && < 6,
bytestring >= 0.9.1.10 && < 0.11,
comonad >= 4 && < 6,
contravariant >= 1.3 && < 2,
containers >= 0.4.0 && < 0.6,
distributive >= 0.3 && < 1,
filepath >= 1.2.0.0 && < 1.5,
free >= 4 && < 5,
ghc-prim,
hashable >= 1.1.2.3 && < 1.3,
kan-extensions >= 5 && < 6,
exceptions >= 0.1.1 && < 1,
mtl >= 2.0.1 && < 2.3,
parallel >= 3.1.0.1 && < 3.3,
profunctors >= 5 && < 6,
reflection >= 2.1 && < 3,
semigroupoids >= 5 && < 6,
semigroups >= 0.8.4 && < 1,
tagged >= 0.4.4 && < 1,
template-haskell >= 2.4 && < 2.12,
text >= 0.11 && < 1.3,
transformers >= 0.2 && < 0.6,
transformers-compat >= 0.4 && < 1,
unordered-containers >= 0.2.4 && < 0.3,
vector >= 0.9 && < 0.12,
void >= 0.5 && < 1
exposed-modules:
Control.Exception.Lens
Control.Lens
Control.Lens.At
Control.Lens.Combinators
Control.Lens.Cons
Control.Lens.Each
Control.Lens.Empty
Control.Lens.Equality
Control.Lens.Extras
Control.Lens.Fold
Control.Lens.Getter
Control.Lens.Indexed
Control.Lens.Internal
Control.Lens.Internal.Bazaar
Control.Lens.Internal.ByteString
Control.Lens.Internal.Coerce
Control.Lens.Internal.Context
Control.Lens.Internal.Deque
Control.Lens.Internal.Exception
Control.Lens.Internal.FieldTH
Control.Lens.Internal.PrismTH
Control.Lens.Internal.Fold
Control.Lens.Internal.Getter
Control.Lens.Internal.Indexed
Control.Lens.Internal.Instances
Control.Lens.Internal.Iso
Control.Lens.Internal.Level
Control.Lens.Internal.List
Control.Lens.Internal.Magma
Control.Lens.Internal.Prism
Control.Lens.Internal.Review
Control.Lens.Internal.Setter
Control.Lens.Internal.TH
Control.Lens.Internal.Zoom
Control.Lens.Iso
Control.Lens.Lens
Control.Lens.Level
Control.Lens.Operators
Control.Lens.Plated
Control.Lens.Prism
Control.Lens.Reified
Control.Lens.Review
Control.Lens.Setter
Control.Lens.TH
Control.Lens.Traversal
Control.Lens.Tuple
Control.Lens.Type
Control.Lens.Wrapped
Control.Lens.Zoom
Control.Monad.Error.Lens
Control.Parallel.Strategies.Lens
Control.Seq.Lens
Data.Array.Lens
Data.Bits.Lens
Data.ByteString.Lens
Data.ByteString.Strict.Lens
Data.ByteString.Lazy.Lens
Data.Complex.Lens
Data.Data.Lens
Data.Dynamic.Lens
Data.HashSet.Lens
Data.IntSet.Lens
Data.List.Lens
Data.Map.Lens
Data.Sequence.Lens
Data.Set.Lens
Data.Text.Lens
Data.Text.Strict.Lens
Data.Text.Lazy.Lens
Data.Tree.Lens
Data.Typeable.Lens
Data.Vector.Lens
Data.Vector.Generic.Lens
Generics.Deriving.Lens
GHC.Generics.Lens
System.Exit.Lens
System.FilePath.Lens
System.IO.Error.Lens
Language.Haskell.TH.Lens
Numeric.Lens
other-modules:
Paths_lens
cpp-options: -traditional
if flag(safe)
cpp-options: -DSAFE=1
if flag(trustworthy) && impl(ghc>=7.2)
other-extensions: Trustworthy
cpp-options: -DTRUSTWORTHY=1
if flag(old-inline-pragmas) && impl(ghc>=7.6.0.20120810)
cpp-options: -DOLD_INLINE_PRAGMAS=1
if flag(inlining)
cpp-options: -DINLINING
if impl(ghc<7.4)
ghc-options: -fno-spec-constr-count
-- hack around the buggy unused matches check for class associated types in ghc 8 rc1
if impl(ghc >= 8)
ghc-options: -Wno-missing-pattern-synonym-signatures -Wno-unused-matches
if flag(j) && impl(ghc>=7.8)
ghc-options: -j4
ghc-options: -Wall -fwarn-tabs -O2 -fdicts-cheap -funbox-strict-fields -fmax-simplifier-iterations=10
hs-source-dirs: src
-- Verify that Template Haskell expansion works
test-suite templates
type: exitcode-stdio-1.0
main-is: templates.hs
ghc-options: -Wall -threaded
hs-source-dirs: tests
if !flag(test-templates)
buildable: False
if flag(dump-splices)
ghc-options: -ddump-splices
if !flag(test-templates)
buildable: False
else
build-depends: base, lens
-- Verify the properties of lenses with QuickCheck
test-suite properties
type: exitcode-stdio-1.0
main-is: properties.hs
other-modules:
Control.Lens.Properties
ghc-options: -w -threaded -rtsopts -with-rtsopts=-N
hs-source-dirs:
tests
lens-properties/src
if !flag(test-properties)
buildable: False
else
build-depends:
base,
lens,
QuickCheck >= 2.4,
test-framework >= 0.6,
test-framework-quickcheck2 >= 0.2,
test-framework-th >= 0.2,
transformers
test-suite hunit
type: exitcode-stdio-1.0
main-is: hunit.hs
ghc-options: -w -threaded -rtsopts -with-rtsopts=-N
hs-source-dirs: tests
if !flag(test-hunit)
buildable: False
else
build-depends:
base,
containers,
HUnit >= 1.2,
lens,
mtl,
test-framework >= 0.6,
test-framework-hunit >= 0.2,
test-framework-th >= 0.2
-- Verify the results of the examples
test-suite doctests
type: exitcode-stdio-1.0
main-is: doctests.hs
ghc-options: -Wall -threaded
hs-source-dirs: tests
if flag(trustworthy) && impl(ghc>=7.2)
other-extensions: Trustworthy
cpp-options: -DTRUSTWORTHY=1
if !flag(test-doctests) || impl(ghc>=8)
buildable: False
else
build-depends:
base,
bytestring,
containers,
directory >= 1.0,
deepseq,
doctest >= 0.9.1,
filepath,
generic-deriving,
mtl,
nats,
parallel,
semigroups >= 0.9,
simple-reflect >= 0.3.1,
text,
unordered-containers,
vector
test-suite hlint
type: exitcode-stdio-1.0
main-is: hlint.hs
ghc-options: -w -threaded -rtsopts -with-rtsopts=-N
hs-source-dirs: tests
if !flag(test-hlint)
buildable: False
else
build-depends:
base,
hlint >= 1.9.27
-- Basic benchmarks for the uniplate-style combinators
benchmark plated
type: exitcode-stdio-1.0
main-is: plated.hs
ghc-options: -Wall -O2 -threaded -fdicts-cheap -funbox-strict-fields
hs-source-dirs: benchmarks
build-depends:
base,
comonad,
criterion,
deepseq,
generic-deriving,
lens,
transformers
if flag(benchmark-uniplate)
build-depends: uniplate >= 1.6.7 && < 1.7
cpp-options: -DBENCHMARK_UNIPLATE
-- Benchmarking alongside variants
benchmark alongside
type: exitcode-stdio-1.0
main-is: alongside.hs
ghc-options: -w -O2 -threaded -fdicts-cheap -funbox-strict-fields
hs-source-dirs: benchmarks
build-depends:
base,
comonad >= 4,
criterion,
deepseq,
lens,
transformers
-- Benchmarking folds
benchmark folds
type: exitcode-stdio-1.0
main-is: folds.hs
ghc-options: -w -O2 -threaded -fdicts-cheap -funbox-strict-fields
hs-source-dirs: benchmarks
build-depends:
base,
criterion,
containers,
bytestring,
unordered-containers,
vector,
lens
-- Benchmarking traversals
benchmark traversals
type: exitcode-stdio-1.0
main-is: traversals.hs
ghc-options: -w -O2 -threaded -fdicts-cheap -funbox-strict-fields
hs-source-dirs: benchmarks
build-depends:
base,
criterion,
containers,
bytestring,
unordered-containers,
vector,
lens
-- Benchmarking unsafe implementation strategies
benchmark unsafe
type: exitcode-stdio-1.0
main-is: unsafe.hs
ghc-options: -w -O2 -threaded -fdicts-cheap -funbox-strict-fields
hs-source-dirs: benchmarks
build-depends:
base,
comonad >= 4,
criterion >= 1,
deepseq,
generic-deriving,
lens,
transformers
|