packages feed

transformers-compat (empty) → 0.1

raw patch · 13 files changed

+381/−0 lines, 13 filesdep +basedep +transformerssetup-changed

Dependencies added: base, transformers

Files

+ .ghci view
@@ -0,0 +1,1 @@+:set -isrc -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
+ .gitignore view
@@ -0,0 +1,9 @@+dist+docs+wiki+TAGS+tags+wip+.DS_Store+.*.swp+.*.swo
+ .travis.yml view
@@ -0,0 +1,28 @@+language: haskell+before_install:+  # Uncomment whenever hackage is down.+  # - mkdir -p ~/.cabal && cp config ~/.cabal/config && cabal update++  # Try installing some of the build-deps with apt-get for speed.+  - ./travis-cabal-apt-install --only-dependencies --force-reinstall $mode++  - sudo apt-get -q -y install hlint || cabal install hlint++install:+  - cabal configure $mode+  - cabal build++script:+  - $script+  - hlint src --cpp-define HLINT++notifications:+  irc:+    channels:+      - "irc.freenode.org#haskell-lens"+    skip_join: true+    template:+      - "\x0313transformers-compat\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"++env:+  - mode="--enable-tests" script="cabal test"
+ .vim.custom view
@@ -0,0 +1,31 @@+" Add the following to your .vimrc to automatically load this on startup++" if filereadable(".vim.custom")+"     so .vim.custom+" endif++function StripTrailingWhitespace()+  let myline=line(".")+  let mycolumn = col(".")+  silent %s/  *$//+  call cursor(myline, mycolumn)+endfunction++" enable syntax highlighting+syntax on++" search for the tags file anywhere between here and /+set tags=TAGS;/++" highlight tabs and trailing spaces+set listchars=tab:‗‗,trail:‗+set list++" f2 runs hasktags+map <F2> :exec ":!hasktags -x -c --ignore src"<CR><CR>++" strip trailing whitespace before saving+" au BufWritePre *.hs,*.markdown silent! cal StripTrailingWhitespace()++" rebuild hasktags after saving+au BufWritePost *.hs silent! :exec ":!hasktags -x -c --ignore src"
+ CHANGELOG.markdown view
@@ -0,0 +1,3 @@+0.1+---+* Repository initialized by pulling the `transformers-0.2` compatibility layer out of `lens`.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright 2012 Edward Kmett++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 AUTHORS ``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.
+ README.markdown view
@@ -0,0 +1,17 @@+transformers-compat+===================++[![Build Status](https://secure.travis-ci.org/ekmett/transformers-compat.png?branch=master)](http://travis-ci.org/ekmett/transformers-compat)++This provides a thin compatibility shim on top of transformers-0.2 to add the types that were added in transformers-0.3.++This enables users to maintain haskell-platform compatibility, while still gaining access ot the new functionality.++Contact Information+-------------------++Contributions and bug reports are welcome!++Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.++-Edward Kmett
+ Setup.lhs view
@@ -0,0 +1,7 @@+#!/usr/bin/runhaskell+> module Main (main) where++> import Distribution.Simple++> main :: IO ()+> main = defaultMain
+ config view
@@ -0,0 +1,16 @@+-- This provides a custom ~/.cabal/config file for use when hackage is down that should work on unix+--+-- This is particularly useful for travis-ci to get it to stop complaining+-- about a broken build when everything is still correct on our end.+--+-- This uses Luite Stegeman's mirror of hackage provided by his 'hdiff' site instead+--+-- To enable this, uncomment the before_script in .travis.yml++remote-repo: hdiff.luite.com:http://hdiff.luite.com/packages/archive+remote-repo-cache: ~/.cabal/packages+world-file: ~/.cabal/world+build-summary: ~/.cabal/logs/build.log+remote-build-reporting: anonymous+install-dirs user+install-dirs global
+ src/Control/Applicative/Backwards.hs view
@@ -0,0 +1,51 @@+-- |+-- Module      :  Control.Applicative.Backwards+-- Copyright   :  (c) Russell O'Connor 2009+-- License     :  BSD-style (see the file LICENSE)+--+-- Maintainer  :  libraries@haskell.org+-- Stability   :  experimental+-- Portability :  portable+--+-- Making functors with an 'Applicative' instance that performs actions+-- in the reverse order.+--+-- NB: This module is only included in @lens@ for backwards compatibility with+-- @transformers@ versions before 3.0.+module Control.Applicative.Backwards where++import Prelude hiding (foldr, foldr1, foldl, foldl1)+import Control.Applicative+import Data.Foldable+import Data.Traversable++-- | The same functor, but with an 'Applicative' instance that performs+-- actions in the reverse order.+newtype Backwards f a = Backwards { forwards :: f a }++-- | Derived instance.+instance (Functor f) => Functor (Backwards f) where+    fmap f (Backwards a) = Backwards (fmap f a)++-- | Apply @f@-actions in the reverse order.+instance (Applicative f) => Applicative (Backwards f) where+    pure a = Backwards (pure a)+    Backwards f <*> Backwards a = Backwards (a <**> f)++-- | Try alternatives in the same order as @f@.+instance (Alternative f) => Alternative (Backwards f) where+    empty = Backwards empty+    Backwards x <|> Backwards y = Backwards (x <|> y)++-- | Derived instance.+instance (Foldable f) => Foldable (Backwards f) where+    foldMap f (Backwards t) = foldMap f t+    foldr f z (Backwards t) = foldr f z t+    foldl f z (Backwards t) = foldl f z t+    foldr1 f (Backwards t) = foldl1 f t+    foldl1 f (Backwards t) = foldr1 f t++-- | Derived instance.+instance (Traversable f) => Traversable (Backwards f) where+    traverse f (Backwards t) = fmap Backwards (traverse f t)+    sequenceA (Backwards t) = fmap Backwards (sequenceA t)
+ src/Control/Applicative/Lift.hs view
@@ -0,0 +1,71 @@+-- |+-- Module      :  Control.Applicative.Lift+-- Copyright   :  (c) Ross Paterson 2010+-- License     :  BSD-style (see the file LICENSE)+--+-- Maintainer  :  ross@soi.city.ac.uk+-- Stability   :  experimental+-- Portability :  portable+--+-- Adding a new kind of pure computation to an applicative functor.+--+-- NB: This module is only included in @lens@ for backwards compatibility with+-- @transformers@ versions before 3.0.++module Control.Applicative.Lift (+    Lift(..), unLift,+    -- * Collecting errors+    Errors, failure+  ) where++import Control.Applicative+import Data.Foldable (Foldable(foldMap))+import Data.Functor.Constant+import Data.Monoid+import Data.Traversable (Traversable(traverse))++-- | Applicative functor formed by adding pure computations to a given+-- applicative functor.+data Lift f a = Pure a | Other (f a)++instance (Functor f) => Functor (Lift f) where+    fmap f (Pure x) = Pure (f x)+    fmap f (Other y) = Other (fmap f y)++instance (Foldable f) => Foldable (Lift f) where+    foldMap f (Pure x) = f x+    foldMap f (Other y) = foldMap f y++instance (Traversable f) => Traversable (Lift f) where+    traverse f (Pure x) = Pure <$> f x+    traverse f (Other y) = Other <$> traverse f y++-- | A combination is 'Pure' only if both parts are.+instance (Applicative f) => Applicative (Lift f) where+    pure = Pure+    Pure f <*> Pure x = Pure (f x)+    Pure f <*> Other y = Other (f <$> y)+    Other f <*> Pure x = Other (($ x) <$> f)+    Other f <*> Other y = Other (f <*> y)++-- | A combination is 'Pure' only either part is.+instance Alternative f => Alternative (Lift f) where+    empty = Other empty+    Pure x <|> _ = Pure x+    Other _ <|> Pure y = Pure y+    Other x <|> Other y = Other (x <|> y)++-- | Projection to the other functor.+unLift :: Applicative f => Lift f a -> f a+unLift (Pure x) = pure x+unLift (Other e) = e++-- | An applicative functor that collects a monoid (e.g. lists) of errors.+-- A sequence of computations fails if any of its components do, but+-- unlike monads made with 'ErrorT' from "Control.Monad.Trans.Error",+-- these computations continue after an error, collecting all the errors.+type Errors e = Lift (Constant e)++-- | Report an error.+failure :: Monoid e => e -> Errors e a+failure e = Other (Constant e)
+ src/Data/Functor/Reverse.hs view
@@ -0,0 +1,57 @@+-- |+-- Module      :  Data.Functor.Reverse+-- Copyright   :  (c) Russell O'Connor 2009+-- License     :  BSD-style (see the file LICENSE)+--+-- Maintainer  :  libraries@haskell.org+-- Stability   :  experimental+-- Portability :  portable+--+-- Making functors whose elements are notionally in the reverse order+-- from the original functor.+--+-- /NB:/ Note this module is only included in @lens@ for backwards+-- compatibility with older @containers@ versions.++module Data.Functor.Reverse where++import Control.Applicative.Backwards++import Prelude hiding (foldr, foldr1, foldl, foldl1)+import Control.Applicative+import Data.Foldable+import Data.Traversable+import Data.Monoid++-- | The same functor, but with 'Foldable' and 'Traversable' instances+-- that process the elements in the reverse order.+newtype Reverse f a = Reverse { getReverse :: f a }++-- | Derived instance.+instance (Functor f) => Functor (Reverse f) where+    fmap f (Reverse a) = Reverse (fmap f a)++-- | Derived instance.+instance (Applicative f) => Applicative (Reverse f) where+    pure a = Reverse (pure a)+    Reverse f <*> Reverse a = Reverse (f <*> a)++-- | Derived instance.+instance (Alternative f) => Alternative (Reverse f) where+    empty = Reverse empty+    Reverse x <|> Reverse y = Reverse (x <|> y)++-- | Fold from right to left.+instance (Foldable f) => Foldable (Reverse f) where+    foldMap f (Reverse t) = getDual (foldMap (Dual . f) t)+    foldr f z (Reverse t) = foldl (flip f) z t+    foldl f z (Reverse t) = foldr (flip f) z t+    foldr1 f (Reverse t) = foldl1 (flip f) t+    foldl1 f (Reverse t) = foldr1 (flip f) t++-- | Traverse from right to left.+instance (Traversable f) => Traversable (Reverse f) where+    traverse f (Reverse t) =+        fmap Reverse . forwards $ traverse (Backwards . f) t+    sequenceA (Reverse t) =+        fmap Reverse . forwards $ sequenceA (fmap Backwards t)
+ transformers-compat.cabal view
@@ -0,0 +1,60 @@+name:          transformers-compat+category:      Compatibility+version:       0.1+license:       BSD3+cabal-version: >= 1.8+license-file:  LICENSE+author:        Edward A. Kmett+maintainer:    Edward A. Kmett <ekmett@gmail.com>+stability:     provisional+homepage:      http://github.com/ekmett/transformers-compat/+bug-reports:   http://github.com/ekmett/transformers-compat/issues+copyright:     Copyright (C) 2012 Edward A. Kmett+synopsis:      Lenses, Folds and Traversals+description:+  This package includes backported versions of types that were added+  to transformers in transformers 0.3 for users who need strict+  transformers 0.2 compatibility to run on old versions of the+  platform, but also need those types.+  .+  Those users should be able to just depend on @transformers >= 0.2@+  and @transformers-compat@.+  .+  Note: missing methods are not supplied+  but this at least permits the types to be used.++build-type:    Simple+tested-with:   GHC == 7.0.4, GHC == 7.4.1, GHC == 7.4.2, GHC == 7.6.1+extra-source-files:+  .travis.yml+  .ghci+  .gitignore+  .vim.custom+  config+  README.markdown+  CHANGELOG.markdown++source-repository head+  type: git+  location: git://github.com/ekmett/transformers-compat.git++flag transformers2+  default: False+  manual: False++library+  build-depends:+    base >= 4.3 && < 5++  hs-source-dirs: src++  if flag(transformers2)+    build-depends:+      transformers >= 0.2 && < 0.3+    exposed-modules:+      Control.Applicative.Backwards+      Control.Applicative.Lift+      Data.Functor.Reverse+  else+    build-depends:+      transformers >= 0.3 && < 0.4