packages feed

parameterized-data 0.1.5 → 0.1.6

raw patch · 3 files changed

+28/−11 lines, 3 filesdep ~type-levelnew-uploader

Dependency ranges changed: type-level

Files

README view
@@ -8,7 +8,7 @@  dependent types.   Right now only fixed-sized vectors are provided. A tutorial on how to- use them can be found at http://www.ict.kth.se/org/ict/ecs/sam/projects/forsyde/www/files/tutorial/tutorial.html#FSVec+ use them can be found at https://forsyde.ict.kth.se/trac/wiki/ForSyDe/Haskell/ForSyDeTutorial#FSVec   DEPENDENCIES
parameterized-data.cabal view
@@ -1,6 +1,6 @@ name:           parameterized-data-version:        0.1.5-cabal-version:  >= 1.2+version:        0.1.6+cabal-version:  >= 1.6 build-type:     Simple license:        BSD3 license-file:   LICENSE@@ -18,18 +18,25 @@  This library provides an implementation of parameterized types using  type-level computations to implement the type parameters and emulate  dependent types.-- Right now only fixed-sized vectors are provided. A tutorial on how to use them can be found at <http://www.ict.kth.se/forsyde/files/tutorial/tutorial.html#FSVec>+ .+ Right now only fixed-sized vectors are provided. A tutorial on how to use them can be found at <https://forsyde.ict.kth.se/trac/wiki/ForSyDe/Haskell/ForSyDeTutorial#FSVec>  category:       Data-tested-with:    GHC==6.12.3+tested-with:    GHC==7.10.3 GHC==8.0.1 extra-source-files: LICENSE,                     README  -- depends on ghc due to the use of Template Haskell Library-  build-depends:   base>=4 && <6, type-level, template-haskell > 2.0+  build-depends:   base>=4 && <6, type-level>=0.3.0, template-haskell > 2.0   hs-source-dirs:  src   exposed-modules: Data.Param,                    Data.Param.FSVec   ghc-options:	-Wall +  if impl(ghc >= 8.0) +    ghc-options: -Wno-redundant-constraints++source-repository head+  type:     git+  location: git://github.com/forsyde/parameterized-data.git+
src/Data/Param/FSVec.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE Rank2Types, ScopedTypeVariables,              MultiParamTypeClasses, DeriveDataTypeable, -             GeneralizedNewtypeDeriving, TemplateHaskell, CPP #-}+             GeneralizedNewtypeDeriving, TemplateHaskell, +             TypeOperators, CPP #-} {-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-name-shadowing #-} ----------------------------------------------------------------------------- -- |@@ -15,7 +16,7 @@ -- -- 'FSVec': Fixed sized vectors. Vectors with numerically parameterized size. ----- Tutorial: <http://www.ict.kth.se/forsyde/files/tutorial/tutorial.html#FSVec>+-- Tutorial: <https://forsyde.ict.kth.se/trac/wiki/ForSyDe/Haskell/ForSyDeTutorial#FSVec> ---------------------------------------------------------------------------- module Data.Param.FSVec    (FSVec, empty, (+>), singleton, vectorCPS, vectorTH,@@ -24,7 +25,7 @@ -- #endif    unsafeVector, reallyUnsafeVector, readFSVec, readFSVecCPS, length,    genericLength, lengthT, fromVector, null, (!), replace, head, last,-   init, tail, take, drop, select, group, (<+), (++), map, zipWith,+   init, tail, take, drop, select, group, (<+), (++), map, zipWith, zipWith3,    foldl, foldr, zip, unzip, shiftl, shiftr, rotl, rotr, concat,    reverse, iterate, generate, copy   ) where@@ -38,7 +39,7 @@ import Prelude hiding (               null, length, head, tail, last, init, take, drop,  	      (++), map, foldl, foldr, -	      zipWith, zip, unzip, +	      zipWith, zipWith3, zip, unzip,  	      concat, reverse, iterate) import qualified Data.Foldable  as DF (Foldable, foldr) import qualified Data.Traversable as DT (Traversable(traverse)) @@ -287,6 +288,10 @@ zipWith :: Nat s => (a -> b -> c) -> FSVec s a -> FSVec s b -> FSVec s c zipWith f = liftV2 (P.zipWith f)  +-- | Applies function pairwise on two vectors+zipWith3 :: Nat s => (a -> b -> c -> d) -> FSVec s a -> FSVec s b -> FSVec s c -> FSVec s d+zipWith3 f = liftV3 (P.zipWith3 f)+  -- | Folds a function from the right to the left  over a vector using an --   initial value. foldl :: Nat s => (a -> b -> a) -> a -> FSVec s b -> a @@ -419,6 +424,11 @@ -- note it is unsafe and shouldn't be exported liftV2 :: ([a] -> [b] -> [c]) -> FSVec s1 a -> FSVec s2 b -> FSVec s3 c liftV2 f a b = FSVec (f (unFSVec a) (unFSVec b))+  +-- the FSVec equivalent of liftM+-- note it is unsafe and shouldn't be exported+liftV3 :: ([a] -> [b] -> [c] -> [d]) -> FSVec s1 a -> FSVec s2 b -> FSVec s3 c -> FSVec s4 d+liftV3 f a b c = FSVec (f (unFSVec a) (unFSVec b) (unFSVec c))    -- version of splitAt which checks if the list contains enough elements splitAtM :: Int -> [a] -> Maybe ([a],[a])