packages feed

VKHS 0.1.4 → 0.1.5

raw patch · 8 files changed

+44/−269 lines, 8 filesdep ~containersdep ~template-haskell

Dependency ranges changed: containers, template-haskell

Files

VKHS.cabal view
@@ -1,6 +1,6 @@  name:                VKHS-version:             0.1.4+version:             0.1.5 synopsis:            Provides access to Vkontakte social network, popular in Russia description:     Provides access to Vkontakte API methods. Library requires no interaction@@ -32,7 +32,7 @@    build-depends:     base >=4.5 && <5,                      json ==0.5.*,-                     containers ==0.4.*,+                     containers ==0.5.*,                      tagsoup-parsec ==0.0.*,                      tagsoup ==0.12.*,                      mtl ==2.1.*,@@ -44,6 +44,6 @@                      split ==0.2.*,                      utf8-string ==0.3.*,                      bimap ==0.2.*,-                     template-haskell ==2.7.*,+                     template-haskell ==2.8.*,                      transformers ==0.3.* 
src/Data/Label.hs view
@@ -1,33 +1,3 @@-{--Copyright (c) Erik Hesselink & Sebastiaan Visser 2008--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions-are met:-1. Redistributions of source code must retain the above copyright-   notice, this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright-   notice, this list of conditions and the following disclaimer in the-   documentation and/or other materials provided with the distribution.-3. Neither the name of the author nor the names of his contributors-   may be used to endorse or promote products derived from this software-   without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-SUCH DAMAGE.--}- {-# LANGUAGE TypeOperators #-} {- | This package provides first class labels that can act as bidirectional record@@ -116,8 +86,6 @@ , get , set , modify--- , glue-, fmapL  -- * Views using @Applicative@. @@ -168,7 +136,7 @@ -- the following: --  -- > ageAsString :: Person :-> String--- > ageAsString = (Bij show read) `iso` age+-- > ageAsString = Bij show read `iso` age  , Bijection (..) , Iso (..)
src/Data/Label/Abstract.hs view
@@ -1,32 +1,3 @@-{--Copyright (c) Erik Hesselink & Sebastiaan Visser 2008--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions-are met:-1. Redistributions of source code must retain the above copyright-   notice, this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright-   notice, this list of conditions and the following disclaimer in the-   documentation and/or other materials provided with the distribution.-3. Neither the name of the author nor the names of his contributors-   may be used to endorse or promote products derived from this software-   without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-SUCH DAMAGE.--} {-# LANGUAGE     TypeOperators   , Arrows@@ -53,55 +24,55 @@ -- | Abstract Point datatype. The getter and setter functions work in some -- arrow. -data Point (~>) f i o = Point-  { _get :: f ~> o-  , _set :: (i, f) ~> f+data Point arr f i o = Point+  { _get :: f `arr` o+  , _set :: (i, f) `arr` f   }  -- | Modification as a compositon of a getter and setter. Unfortunately, -- `ArrowApply' is needed for this composition. -_modify :: ArrowApply (~>) => Point (~>) f i o -> (o ~> i, f) ~> f+_modify :: ArrowApply arr => Point arr f i o -> (o `arr` i, f) `arr` f _modify l = proc (m, f) -> do i <- m . _get l -<< f; _set l -< (i, f)  -- | Abstract Lens datatype. The getter and setter functions work in some -- arrow. Arrows allow for effectful lenses, for example, lenses that might -- fail or use state. -newtype Lens (~>) f a = Lens { unLens :: Point (~>) f a a }+newtype Lens arr f a = Lens { unLens :: Point arr f a a }  -- | Create a lens out of a getter and setter. -lens :: (f ~> a) -> ((a, f) ~> f) -> Lens (~>) f a+lens :: (f `arr` a) -> ((a, f) `arr` f) -> Lens arr f a lens g s = Lens (Point g s)  -- | Get the getter arrow from a lens. -get :: Arrow (~>) => Lens (~>) f a -> f ~> a+get :: Arrow arr => Lens arr f a -> f `arr` a get = _get . unLens  -- | Get the setter arrow from a lens. -set :: Arrow (~>) => Lens (~>) f a -> (a, f) ~> f+set :: Arrow arr => Lens arr f a -> (a, f) `arr` f set = _set . unLens  -- | Get the modifier arrow from a lens. -modify :: ArrowApply (~>) => Lens (~>) f o -> (o ~> o, f) ~> f+modify :: ArrowApply arr => Lens arr f o -> (o `arr` o, f) `arr` f modify = _modify . unLens -instance ArrowApply (~>) => Category (Lens (~>)) where+instance ArrowApply arr => Category (Lens arr) where   id = lens id (arr fst)   Lens a . Lens b = lens (_get a . _get b) (_modify b . first (curryA (_set a)))     where curryA f = arr (\i -> f . arr (i,))   {-# INLINE id #-}   {-# INLINE (.) #-} -instance Arrow (~>) => Functor (Point (~>) f i) where+instance Arrow arr => Functor (Point arr f i) where   fmap f x = Point (arr f . _get x) (_set x)   {-# INLINE fmap #-} -instance Arrow (~>) => Applicative (Point (~>) f i) where+instance Arrow arr => Applicative (Point arr f i) where   pure a  = Point (arr (const a)) (arr snd)   a <*> b = Point (arr app . (_get a &&& _get b)) (_set b . (arr fst &&& _set a))   {-# INLINE pure #-}@@ -109,54 +80,54 @@  -- | Make a 'Point' diverge in two directions. -bimap :: Arrow (~>) => (o' ~> o) -> (i ~> i') -> Point (~>) f i' o' -> Point (~>) f i o+bimap :: Arrow arr => (o' `arr` o) -> (i `arr` i') -> Point arr f i' o' -> Point arr f i o bimap f g l = Point (f . _get l) (_set l . first g)  infix 8 `for` -for :: Arrow (~>) => (i ~> o) -> Lens (~>) f o -> Point (~>) f i o+for :: Arrow arr => (i `arr` o) -> Lens arr f o -> Point arr f i o for p = bimap id p . unLens  -- | The bijections datatype, an arrow that works in two directions.  -data Bijection (~>) a b = Bij { fw :: a ~> b, bw :: b ~> a }+infix 8 `Bij` +data Bijection arr a b = Bij { fw :: a `arr` b, bw :: b `arr` a }+ -- | Bijections as categories. -instance Category (~>) => Category (Bijection (~>)) where+instance Category arr => Category (Bijection arr) where   id = Bij id id-  Bij a b . Bij c d = Bij (a . c) (d . b)+  Bij a b . Bij c d = a . c `Bij` d . b   {-# INLINE id #-}   {-# INLINE (.) #-}  -- | Lifting 'Bijection's.  liftBij :: Functor f => Bijection (->) a b -> Bijection (->) (f a) (f b)-liftBij a = Bij (fmap (fw a)) (fmap (bw a))---- | Apply Bijection to Lens---- mapBij :: Bijection (->) b c -> Lens (->) a b -> Lens (->) a c--- mapBij b l = lens g s where---    g x = fw b (get l x)---    s (a,x) = set l ((bw b a),x)+liftBij a = fmap (fw a) `Bij` fmap (bw a)  -- | The isomorphism type class is like a `Functor' but works in two directions.  infixr 8 `iso` -class Iso (~>) f where-  iso :: Bijection (~>) a b -> f a ~> f b+class Iso arr f where+  iso :: Bijection arr a b -> f a `arr` f b +-- | Flipped isomorphism.++osi :: Iso arr f => Bijection arr b a -> f a `arr` f b+osi (Bij a b) = iso (Bij b a)+ -- | We can diverge 'Lens'es using an isomorphism. -instance Arrow (~>) => Iso (~>) (Lens (~>) f) where+instance Arrow arr => Iso arr (Lens arr f) where   iso bi = arr ((\a -> lens (fw bi . _get a) (_set a . first (bw bi))) . unLens)   {-# INLINE iso #-}  -- | We can diverge 'Bijection's using an isomorphism. -instance Arrow (~>) => Iso (~>) (Bijection (~>) a) where+instance Arrow arr => Iso arr (Bijection arr a) where   iso = arr . (.)   {-# INLINE iso #-} 
src/Data/Label/Derive.hs view
@@ -1,32 +1,3 @@-{--Copyright (c) Erik Hesselink & Sebastiaan Visser 2008--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions-are met:-1. Redistributions of source code must retain the above copyright-   notice, this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright-   notice, this list of conditions and the following disclaimer in the-   documentation and/or other materials provided with the distribution.-3. Neither the name of the author nor the names of his contributors-   may be used to endorse or promote products derived from this software-   without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-SUCH DAMAGE.--} {-# OPTIONS -fno-warn-orphans #-} {-# LANGUAGE     TemplateHaskell@@ -34,6 +5,7 @@   , FlexibleContexts   , FlexibleInstances   , TypeOperators+  , CPP   #-} module Data.Label.Derive ( mkLabels@@ -151,7 +123,13 @@   where      -- Generate an inline declaration for the label.+    --+    -- Type of InlineSpec removed in TH-2.8.0 (GHC 7.6)+#if MIN_VERSION_template_haskell(2,8,0)+    inline = PragmaD (InlineP labelName Inline FunLike (FromPhase 0))+#else     inline = PragmaD (InlineP labelName (InlineSpec True True (Just (True, 0))))+#endif     labelName = mkName (makeLabel (nameBase field))      -- Build a single record label definition for labels that might fail.@@ -185,13 +163,13 @@     inputType = return $ foldr (flip AppT) (ConT tyname) (map tvToVarT (reverse prettyVars))      -- Convert a type variable binder to a regular type variable.-    tvToVarT (PlainTV tv) = VarT tv-    tvToVarT _            = fclError "No support for special-kinded type variables."+    tvToVarT (PlainTV  tv     ) = VarT tv+    tvToVarT (KindedTV tv kind) = SigT (VarT tv) kind      -- Prettify type variables.-    arrow          = varT (mkName "~>")+    arrow          = varT (mkName "arr")     prettyVars     = map prettyTyVar vars-    forallVars     = PlainTV (mkName "~>") : prettyVars+    forallVars     = PlainTV (mkName "arr") : prettyVars     prettyFieldtyp = prettyType fieldtyp      -- Q style record updating.
src/Data/Label/Maybe.hs view
@@ -1,32 +1,3 @@-{--Copyright (c) Erik Hesselink & Sebastiaan Visser 2008--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions-are met:-1. Redistributions of source code must retain the above copyright-   notice, this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright-   notice, this list of conditions and the following disclaimer in the-   documentation and/or other materials provided with the distribution.-3. Neither the name of the author nor the names of his contributors-   may be used to endorse or promote products derived from this software-   without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-SUCH DAMAGE.--} {-# LANGUAGE TypeOperators, TupleSections #-} module Data.Label.Maybe ( (:~>)@@ -37,7 +8,6 @@ , modify , modify' , embed-, lift ) where @@ -102,10 +72,4 @@  embed :: A.Lens (->) f (Maybe a) -> f :~> a embed l = lens (A.get l) (\a f -> Just (A.set l (Just a, f)))---lift :: A.Lens(->) f a -> f :~> a-lift l = lens (\f -> Just $ A.get l f) (\a f -> Just $ A.set l (a,f))-- 
src/Data/Label/MaybeM.hs view
@@ -1,32 +1,3 @@-{--Copyright (c) Erik Hesselink & Sebastiaan Visser 2008--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions-are met:-1. Redistributions of source code must retain the above copyright-   notice, this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright-   notice, this list of conditions and the following disclaimer in the-   documentation and/or other materials provided with the distribution.-3. Neither the name of the author nor the names of his contributors-   may be used to endorse or promote products derived from this software-   without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-SUCH DAMAGE.--} {-# LANGUAGE TypeOperators #-} module Data.Label.MaybeM (
src/Data/Label/Pure.hs view
@@ -1,32 +1,3 @@-{--Copyright (c) Erik Hesselink & Sebastiaan Visser 2008--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions-are met:-1. Redistributions of source code must retain the above copyright-   notice, this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright-   notice, this list of conditions and the following disclaimer in the-   documentation and/or other materials provided with the distribution.-3. Neither the name of the author nor the names of his contributors-   may be used to endorse or promote products derived from this software-   without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-SUCH DAMAGE.--} {-# LANGUAGE TypeOperators #-} module Data.Label.Pure ( (:->)@@ -34,13 +5,10 @@ , get , set , modify--- , glue-, fmapL ) where  import qualified Data.Label.Abstract as A-import Control.Applicative  type PureLens f a = A.Lens (->) f a @@ -75,20 +43,4 @@  modify :: (f :-> a) -> (a -> a) -> f -> f modify = curry . A.modify---fmapL :: (Alternative f) => (a :-> b) -> (f a :-> f b)-fmapL (A.Lens (A.Point g' s')) = lens g s where-    g a = fmap g' a-    s fb fa = ((\b a->s' (b,a)) <$> fb <*> fa) <|> fa---- glue :: (Alternative f) => (o :-> f a) -> (a :-> b) -> (o :-> f b)--- glue l1 l@(A.Lens (A.Point g2 s2)) = lens g s where---     g o = fmap g2 (get l1 o)---     s fb o = set l1 (set ll fb fa) o where---         fa = get l1 o---         ll = fmapL l---- glue2 :: (Alternative f) => (o :-> f a) -> (a :-> f b) -> (o :-> f b)--- glue2 l1 l2 = lens g s where 
src/Data/Label/PureM.hs view
@@ -1,32 +1,3 @@-{--Copyright (c) Erik Hesselink & Sebastiaan Visser 2008--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions-are met:-1. Redistributions of source code must retain the above copyright-   notice, this list of conditions and the following disclaimer.-2. Redistributions in binary form must reproduce the above copyright-   notice, this list of conditions and the following disclaimer in the-   documentation and/or other materials provided with the distribution.-3. Neither the name of the author nor the names of his contributors-   may be used to endorse or promote products derived from this software-   without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-SUCH DAMAGE.--} {-# LANGUAGE TypeOperators  #-} module Data.Label.PureM (