Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prettier docs, trustworthy Language.Haskell.TH.Lens

  • Loading branch information...
commit fde64050e8d524b153757e450ee372ff582cfb34 1 parent 2f021f9
@ekmett authored
Showing with 40 additions and 29 deletions.
  1. +15 −5 lens.cabal
  2. +21 −24 src/Control/Lens.hs
  3. +4 −0 src/Language/Haskell/TH/Lens.hs
View
20 lens.cabal
@@ -12,9 +12,6 @@ bug-reports: http://github.com/ekmett/lens/issues
copyright: Copyright (C) 2012 Edward A. Kmett
synopsis: Lenses, Folds and Traversals
description:
- 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.
- .
This package attempts to come 'Batteries Included' with many useful lenses for the types
commonly used from the Haskell Platform.
.
@@ -23,12 +20,25 @@ description:
.
<http://github.com/ekmett/lens/wiki>
.
+ /Lenses, Folds and Traversals/
+ .
+ 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.
+ .
+ The core of this hierarchy looks like:
+ .
<<http://github.com/ekmett/lens/wiki/images/Hierarchy-1.8.png>>
.
- You can compose any two elements of the hierarchy above using (.) from the Prelude.
+ 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.
+ .
The result is their lowest upper bound in the hierarchy (or an error f that bound doesn't exist).
.
- e.g. You can use any Traversal as a Fold or as a Setter.
+ 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/
.
View
45 src/Control/Lens.hs
@@ -12,39 +12,36 @@
-- Stability : provisional
-- Portability : Rank2Types
--
--- This package provides lens families, setters, getters, traversals,
--- isomorphisms, and folds that can all be composed automatically with
--- each other (and other lenses from other van Laarhoven lens libraries)
--- using @(.)@ from Prelude, while reducing the complexity of the API.
---
--- For a longer description and motivation of why you should care about lens families,
--- see <http://comonad.com/reader/2012/mirrored-lenses/>.
---
--- Note: If you merely want your library to /provide/ lenses you may not
--- have to actually import /any/ lens library. For, say, a
--- @'Simple' 'Lens' Bar Foo@, just export a function with the signature:
---
--- > foo :: Functor f => (Foo -> f Foo) -> Bar -> f Bar
---
--- and then you can compose it with other lenses with @(.)@ without needing
--- anything from this library at all.
---
-- Usage:
--
-- You can derive lenses automatically for many data types:
--
--- > import Control.Lens
--- > data Foo a = Foo { _fooArgs :: [String], _fooValue :: a }
--- > makeLenses ''Foo
+-- @
+-- import Control.Lens
+-- data Foo a = Foo { _fooArgs :: ['String'], _fooValue :: a }
+-- 'makeLenses' ''Foo
+-- @
--
-- This defines the following lenses:
--
--- > fooArgs :: Simple Lens (Foo a) [String]
--- > fooValue :: Lens (Foo a) (Foo b) a b
+-- @
+-- fooArgs :: 'Simple' 'Lens' (Foo a) ['String']
+-- fooValue :: 'Lens' (Foo a) (Foo b) a b
+-- @
+--
+-- You can then access the value with ('^.') and set the value of the field
+-- with ('.~') and can use almost any other combinator that is re-exported here
+-- on those fields.
--
-- The combinators here have unusually specific type signatures, so for
--- particularly tricky ones, I've tried to list the simpler type signatures
--- you might want to pretend the combinators have.
+-- particularly tricky ones, the simpler type signatures you might want to
+-- pretend the combinators have are specified as well.
+--
+-- More information on how to use lenses is available on the lens wiki:
+--
+-- <http://github.com/ekmett/lens/wiki>
+--
+-- <<http://github.com/ekmett/lens/wiki/images/Hierarchy-1.8.png>>
----------------------------------------------------------------------------
module Control.Lens
( module Control.Lens.Type
View
4 src/Language/Haskell/TH/Lens.hs
@@ -1,4 +1,8 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 704
+{-# LANGUAGE Trustworthy #-}
+#endif
-----------------------------------------------------------------------------
-- |
-- Module : Language.Haskell.TH.Lens
Please sign in to comment.
Something went wrong with that request. Please try again.