-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Partial isomorphisms. -- -- Partial isomorphisms as described in the paper: -- -- Tillmann Rendel and Klaus Ostermann. Invertible Syntax Descriptions: -- Unifying Parsing and Pretty Printing. In Proc. of Haskell -- Symposium, 2010. -- -- The paper also describes invertible syntax descriptions as a common -- interface for parsers and pretty printers. These are distributed -- separately in the invertible-syntax package. @package partial-isomorphisms @version 0.2 module Control.Isomorphism.Partial.Unsafe data Iso alpha beta Iso :: (alpha -> Maybe beta) -> (beta -> Maybe alpha) -> Iso alpha beta module Control.Isomorphism.Partial.TH -- | Construct a partial isomorphism expression for a constructor, given -- the constructor's name. constructorIso :: Name -> ExpQ -- | Construct partial isomorphism definitions for all constructors of a -- datatype, given the datatype's name. The names of the partial -- isomorphisms are constructed by spelling the constructor names with an -- initial lower-case letter. defineIsomorphisms :: Name -> Q [Dec] module Control.Isomorphism.Partial.Constructors nil :: Iso () [alpha] cons :: Iso (alpha, [alpha]) [alpha] listCases :: Iso (Either () (alpha, [alpha])) [alpha] left :: Iso a (Either a b) right :: Iso b (Either a b) nothing :: Iso () (Maybe a) just :: Iso a (Maybe a) module Control.Isomorphism.Partial.Prim data Iso alpha beta inverse :: Iso alpha beta -> Iso beta alpha apply :: Iso alpha beta -> alpha -> Maybe beta unapply :: Iso alpha beta -> beta -> Maybe alpha class IsoFunctor f (<$>) :: IsoFunctor f => Iso alpha beta -> (f alpha -> f beta) ignore :: alpha -> Iso alpha () -- | the product type constructor `(,)` is a bifunctor from Iso -- $times$ Iso to Iso, so that we have the bifunctorial map -- *** which allows two separate isomorphisms to work on the two -- components of a tuple. (***) :: Iso alpha beta -> Iso gamma delta -> Iso (alpha, gamma) (beta, delta) -- | The mediating arrow for sums constructed with Either. This is -- not a proper partial isomorphism because of mplus. (|||) :: Iso alpha gamma -> Iso beta gamma -> Iso (Either alpha beta) gamma -- | Nested products associate. associate :: Iso (alpha, (beta, gamma)) ((alpha, beta), gamma) -- | Products commute. commute :: Iso (alpha, beta) (beta, alpha) -- | `()` is the unit element for products. unit :: Iso alpha (alpha, ()) -- | `element x` is the partial isomorphism between `()` and the singleton -- set which contains just x. element :: Eq alpha => alpha -> Iso () alpha -- | For a predicate p, `subset p` is the identity isomorphism -- restricted to elements matching the predicate. subset :: (alpha -> Bool) -> Iso alpha alpha iterate :: Iso alpha alpha -> Iso alpha alpha -- | Products distribute over sums. distribute :: Iso (alpha, Either beta gamma) (Either (alpha, beta) (alpha, gamma)) instance Category Iso module Control.Isomorphism.Partial.Derived foldl :: Iso (alpha, beta) alpha -> Iso (alpha, [beta]) alpha module Control.Isomorphism.Partial