packages feed

vector-instances (empty) → 0.0.1

raw patch · 4 files changed

+130/−0 lines, 4 filesdep +basedep +vectorsetup-changed

Dependencies added: base, vector

Files

+ Data/Vector/Instances.hs view
@@ -0,0 +1,80 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Data.Vector.Instances+-- Copyright   :  (c) Edward Kmett 2010+-- License     :  BSD3+-- Maintainer  :  ekmett@gmail.com+-- Stability   :  experimental+-- Portability :  portable+--+-----------------------------------------------------------------------------++module Data.Vector.Instances () where++import Prelude hiding ((++))+import Control.Applicative+import Control.Monad+import Data.Foldable (Foldable(..))+import Data.Traversable (Traversable(..))+import Data.Monoid+import qualified Data.Vector as Vector+import qualified Data.Vector.Generic as G+import qualified Data.Vector.Fusion.Stream as Stream+import Data.Vector.Fusion.Stream.Size+import Data.Vector (Vector, (++))++instance Functor Vector where+    fmap = Vector.map+    {-# INLINE fmap #-}++instance Monad Vector where+    return = Vector.singleton+    {-# INLINE return #-}+    v >>= f = Vector.concatMap f v+    {-# INLINE (>>=) #-}+    fail _ = Vector.empty+    {-# INLINE fail #-}++instance MonadPlus Vector where+    mzero = Vector.empty+    {-# INLINE mzero #-}+    mplus = (++)+    {-# INLINE mplus #-}++instance Monoid (Vector a) where+    mempty = Vector.empty+    {-# INLINE mempty #-}+    mappend = (++)+    {-# INLINE mappend #-}++instance Applicative Vector where+    pure = Vector.singleton+    {-# INLINE pure #-}+    fs <*> as =+        G.unstream $ Stream.sized results (Exact n)+        where+            n = Vector.length fs * Vector.length as+            results = Stream.concatMap body $ G.stream fs+            body f = Stream.map f $ G.stream as+    {-# INLINE (<*>) #-}++instance Alternative Vector where+    (<|>) = (++)+    {-# INLINE (<|>) #-}+    empty = Vector.empty+    {-# INLINE empty #-}++instance Foldable Vector where+    foldl = Vector.foldl+    {-# INLINE foldl #-}+    foldr = Vector.foldr+    {-# INLINE foldr #-}+    foldl1 = Vector.foldl1+    {-# INLINE foldl1 #-}+    foldr1 = Vector.foldr1+    {-# INLINE foldr1 #-}++instance Traversable Vector where+    traverse f v+        = Vector.fromListN (Vector.length v) <$> traverse f (Vector.toList v)+    {-# INLINE traverse #-}
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2010, 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:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * 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.++    * Neither the name of Edward Kmett nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT+OWNER 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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ vector-instances.cabal view
@@ -0,0 +1,18 @@+Name:                vector-instances+Version:             0.0.1+Synopsis:            Orphan Instances for 'Data.Vector'+Homepage:            http://patch-tag.com/r/ekmett/vector-instances+License:             BSD3+License-file:        LICENSE+Author:              Edward Kmett+Maintainer:          ekmett@gmail.com+Category:            Data, Data Structures+Build-type:          Simple+Cabal-version:       >=1.2++Library+  Exposed-modules:     Data.Vector.Instances++  Build-depends:+    base >= 4 && < 5,+    vector >= 0.6.0.1 && < 7