Permalink
Browse files

added the big uml diagram to the readme

  • Loading branch information...
1 parent fde6405 commit 0c4742e68281f6e1cd9b5446f72d558d4bbd3107 @ekmett committed Aug 9, 2012
Showing with 19 additions and 15 deletions.
  1. +2 −0 README.markdown
  2. +17 −15 lens.cabal
View
@@ -10,6 +10,8 @@ but they provide a great deal of additional flexibility in their composition.
An overview of the derivation of setters, folds, traversals, getters and lenses can be found on the lens wiki under [Tutorial](https://github.com/ekmett/lens/wiki/Tutorial).
+![Lens Hierarchy](https://github.com/ekmett/lens/wiki/images/Hierarchy-1.8.png)
+
Example
-------
View
@@ -12,22 +12,28 @@ bug-reports: http://github.com/ekmett/lens/issues
copyright: Copyright (C) 2012 Edward A. Kmett
synopsis: Lenses, Folds and Traversals
description:
- This package attempts to come 'Batteries Included' with many useful lenses for the types
- commonly used from the Haskell Platform.
+ 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.
.
More information on the care and feeding of lenses, including a tutorial and motivation
for their types can be found on the lens wiki.
.
- <http://github.com/ekmett/lens/wiki>
+ <https://github.com/ekmett/lens/wiki>
.
- /Lenses, Folds and Traversals/
+ A small game that manages its state using lenses can be found in the example folder.
.
- 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.
+ <https://github.com/ekmett/lens/blob/master/examples/Pong.hs>
+ .
+ /Lenses, Folds and Traversals/
.
The core of this hierarchy looks like:
.
- <<http://github.com/ekmett/lens/wiki/images/Hierarchy-1.8.png>>
+ <<https://github.com/ekmett/lens/wiki/images/Hierarchy-1.8.png>>
.
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 links to above it.
@@ -43,9 +49,9 @@ description:
/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 depdency on this (or any other) lens package at all!
+ can do so without incurring a dependency on this (or any other) lens package at all.
.
- For instance for a data type:
+ e.g. for a data type:
.
> data Foo a = Foo Int Int a
.
@@ -55,17 +61,13 @@ description:
> 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)
.
- > -- baz :: Simple Lens Lens (Foo a) Int
- > baz :: Functor f => (Int -> f Int) -> Foo a -> f (Foo b)
- > baz f (Foo a b c) = fmap (\b' -> Foo a b' c) (f b)
- .
> -- baz :: 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!
+ without the need to use any type that isn't already defined in the @Prelude@.
.
- And you can define a traversal of multiple fields, in this case bar and baz, by using 'Applicative'.
+ And you can define a traversal of multiple fields with 'Control.Applicative.Applicative':
.
> -- traverseBarAndBaz :: Simple Traversal (Foo a) Int
> traverseBarAndBaz :: Applicative f => (Int -> f Int) -> Foo a -> f (Foo a)

0 comments on commit 0c4742e

Please sign in to comment.