Permalink
Browse files

repository expanded

  • Loading branch information...
1 parent 2eb5f38 commit af3340325d9b2750b275d8ec955ec787037bf757 @ekmett committed Aug 16, 2012
Showing with 206 additions and 4 deletions.
  1. +1 −0 .ghci
  2. +3 −0 .gitignore
  3. +8 −0 .travis.yml
  4. +21 −0 .vim.custom
  5. +3 −0 CHANGELOG.markdown
  6. +30 −0 LICENSE
  7. +13 −0 README.markdown
  8. +7 −0 Setup.lhs
  9. +16 −0 config
  10. +23 −4 { → src}/Data/Transducer.hs
  11. +28 −0 tests/doctests.hs
  12. +53 −0 transducers.cabal
View
@@ -0,0 +1 @@
+:set -isrc -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
View
@@ -0,0 +1,3 @@
+dist
+TAGS
+tags
View
@@ -0,0 +1,8 @@
+language: haskell
+# Use this when hackage is down.
+# before_install:
+# - mkdir -p ~/.cabal
+# - cp config ~/.cabal/config
+# - cabal update
+notifications:
+ irc: "irc.freenode.org#haskell-lens"
View
@@ -0,0 +1,21 @@
+" 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
+
+syntax on
+set tags=TAGS;/
+set listchars=tab:‗‗,trail:‗
+set list
+
+map <F2> :exec ":!hasktags -x -c --ignore src"<CR><CR>
+
+au BufWritePre *.hs,*.markdown silent! cal StripTrailingWhitespace()
+au BufWritePost *.hs silent! :exec ":!hasktags -x -c --ignore src"
View
@@ -0,0 +1,3 @@
+0.1
+---
+* Initial release
View
@@ -0,0 +1,30 @@
+Copyright 2012 Edward Kmett, Runar Bjarnason, Paul Chiusano
+
+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.
View
@@ -0,0 +1,13 @@
+transducers
+===========
+
+[![Build Status](https://secure.travis-ci.org/ekmett/transducers.png?branch=master)](http://travis-ci.org/ekmett/transducers)
+
+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
View
@@ -0,0 +1,7 @@
+#!/usr/bin/runhaskell
+> module Main (main) where
+
+> import Distribution.Simple
+
+> main :: IO ()
+> main = defaultMain
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 Stegman'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
@@ -1,5 +1,16 @@
-{-# LANGUAGE ConstraintKinds, Rank2Types, GADTs, FlexibleInstances #-}
+{-# LANGUAGE Rank2Types, GADTs, FlexibleInstances #-}
{-# OPTIONS_GHC -Wall #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module : Data.Transducer
+-- Copyright : (C) 2012 Edward Kmett, Runar Bjarnason, Paul Chiusano
+-- License : BSD-style (see the file LICENSE)
+--
+-- Maintainer : Edward Kmett <ekmett@gmail.com>
+-- Stability : provisional
+-- Portability : portable
+--
+----------------------------------------------------------------------------
module Data.Transducer
(
-- * A monad for stream transduction
@@ -33,10 +44,12 @@ module Data.Transducer
, droppingWhile
, takingWhile
, buffered
+
-- * Sources
, Source
, source
, cap
+
-- * Tees
, Fork(..)
, tee
@@ -49,7 +62,7 @@ module Data.Transducer
import Control.Applicative
import Control.Category
import Control.Monad (ap, MonadPlus(..), replicateM_, when)
-import Data.Bifunctor
+-- import Data.Bifunctor
import Data.Foldable
import Prelude hiding ((.),id)
@@ -69,8 +82,8 @@ newtype SM k i o a = SM
instance Functor (SM k i o) where
fmap f (SM m) = SM $ \k -> m (k . f)
-instance Bifunctor (SM k i) where
- bimap f g (SM m) = SM $ \kp ke -> m (kp . g) (ke . f)
+-- instance Bifunctor (SM k i) where
+-- bimap f g (SM m) = SM $ \kp ke -> m (kp . g) (ke . f)
instance Applicative (SM k i o) where
pure a = SM (\kp _ _ _ -> kp a)
@@ -115,6 +128,11 @@ data SF k i o
| forall r. Receive (r -> SF k i o) (k i r) (SF k i o)
| Stop
+instance Functor (SF k i) where
+ fmap f (Emit o xs) = Emit (f o) (fmap f xs)
+ fmap f (Receive k kir e) = Receive (fmap f . k) kir (fmap f e)
+ fmap _ Stop = Stop
+
transform :: (forall a. k i a -> k' i' a) -> SF k i o -> SF k' i' o
transform f (Emit o k) = Emit o (transform f k)
transform _ Stop = Stop
@@ -136,6 +154,7 @@ repeatedly m = r where r = runSM m (const r) Emit (Receive id) Stop
before :: SF k i o -> SM k i o a -> SF k i o
before f m = runSM m (const f) Emit (Receive id) Stop
+
instance Category (SF (->)) where
id = repeatedly $ do
i <- receive
View
@@ -0,0 +1,28 @@
+module Main where
+
+import Test.DocTest
+import System.Directory
+import System.FilePath
+import Control.Applicative
+import Control.Monad
+import Data.List
+
+main :: IO ()
+main = getSources >>= \sources -> doctest $
+ "-isrc"
+ : "-idist/build/autogen"
+ : "-optP-include"
+ : "-optPdist/build/autogen/cabal_macros.h"
+ : sources
+
+getSources :: IO [FilePath]
+getSources = filter (isSuffixOf ".hs") <$> go "src"
+ where
+ go dir = do
+ (dirs, files) <- getFilesAndDirectories dir
+ (files ++) . concat <$> mapM go dirs
+
+getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])
+getFilesAndDirectories dir = do
+ c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir
+ (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c
View
@@ -0,0 +1,53 @@
+name: transducers
+category: Control, Enumerator
+version: 0.1
+license: BSD3
+cabal-version: >= 1.8
+license-file: LICENSE
+author: Edward A. Kmett, Runar Bjarnason, Paul Chuisano
+maintainer: Edward A. Kmett <ekmett@gmail.com>
+stability: provisional
+homepage: http://github.com/ekmett/transducers/
+bug-reports: http://github.com/ekmett/transducers/issues
+copyright: Copyright (C) 2012 Edward A. Kmett
+synopsis: Composable Stream Transducers
+description: Composable Stream Transducers
+build-type: Simple
+tested-with: GHC == 7.4.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/transducers.git
+
+library
+ build-depends: base >= 4.3 && < 5
+
+ exposed-modules: Data.Transducer
+
+ other-extensions:
+ FlexibleInstances
+ GADTs
+ Rank2Types
+
+ ghc-options: -Wall -fwarn-tabs -O2 -fdicts-cheap -funbox-strict-fields
+ hs-source-dirs: src
+
+-- Verify the results of the examples
+test-suite doctests
+ type: exitcode-stdio-1.0
+ main-is: doctests.hs
+ build-depends:
+ base == 4.*,
+ directory >= 1.0 && < 1.2,
+ doctest >= 0.8 && <= 0.9,
+ filepath >= 1.3 && < 1.4
+ ghc-options: -Wall -Werror -threaded
+ hs-source-dirs: tests

0 comments on commit af33403

Please sign in to comment.