@@ -1,11 +1,50 @@
11name: semi-iso
22version: 1.0.0.0
3−synopsis: Weakened partial isomorphisms that work with lenses.
3+synopsis: Weakened partial isomorphisms, reversible computations.
44description: Semi-isomorphisms are partial isomorphisms with weakened iso laws.
5− And they work with Iso and Prism from @lens@!
6− .
7− See first "Control.Lens.SemiIso" for semi-isomoprhisms.
8− After that have a look at "Control.SIArrow".
5+ And they work with Iso and Prism from @lens@!
6+ .
7+ The module "Control.Lens.SemiIso" defines semi-isomorphisms and provides some
8+ basic semi-isos and combinators. A @SemiIso' a b@ can be applied in both directions
9+ to get a @a -> Either String b@ and @b -> Either String a@. SemiIsos can be composed
10+ with Isos and Prisms (to get another SemiIso). Isos and Prisms can be directly
11+ used as SemiIsos.
12+ .
13+ Semi-isomorphisms obey weaker laws then isomorphisms. We require only
14+ .
15+ > apply f >=> unapply f >=> apply f = apply f
16+ > unapply f >=> apply f >=> unapply f = unapply f
17+ .
18+ instead of
19+ .
20+ > apply f >=> unapply f = f
21+ > unapply f >=> apply f = f
22+ .
23+ Modules "Control.SIArrow" and "Control.Category.Structures" define an @Arrow@-like class
24+ hierarchy. Unfortunately "Control.Arrow" cannot be used, as it is too restrictive (the
25+ dreaded @arr@).
26+
27+ SIArrow abstracts categories of reversible computations (with reversible side effects). In
28+ the case of parsing and pretty-printing using the "syntax" library if we have an arrow
29+ @SIArrow cat => cat a b@ then we can:
30+ .
31+ * Evaluate it from left to right, turning a value of type @a@ into a value of type @b@,
32+ with the side effect of consuming a sequence. (Parsing)
33+ .
34+ * Evaluate it from right to left, turning a value of type @b@ into a value of type @a@,
35+ with the side effect of generating a sequence. (Pretty-printing)
36+ .
37+ In the particular case of parsing/pretty-printing the type @a@ will be usually @()@, e.g.
38+ we just produce a value during parsing and just consume a value during pretty-printing.
39+ To support this style we define a functor and applicative structure on @cat () b@, for example
40+ '/*/' (equivalent of '<*>') has type @(\/*\/) :: SIArrow cat => cat () a -> cat () b -> cat () (a, b)@.
41+ .
42+ When more power then applicative is needed - for example when the syntax depends on the
43+ parsed value - we turn back to arrow composition.
44+ .
45+ Module "Control.Category.Reader" defines a Reader category transformer. It is like a monad
46+ transformer, but for categories. The next version will include some more transformers and
47+ mtl-style classes.
948license: MIT
1049license-file: LICENSE
1150author: Paweł Nowak
@@ -24,6 +63,7 @@ library
2463 Control.Lens.Internal.SemiIso
2564 Control.SIArrow
2665 Control.Category.Reader
66+ Control.Category.Structures
2767 Data.Profunctor.Exposed
2868 build-depends: base >= 4 && < 5, profunctors, transformers, lens, tuple-morph
2969 default-language: Haskell2010