packages feed

th-lift-instances 0.1.1 → 0.1.2

raw patch · 5 files changed

+63/−17 lines, 5 files

Files

.travis.yml view
@@ -1,7 +1,8 @@ env:  - GHCVER=7.4.2 CABALVER=1.16  - GHCVER=7.6.3 CABALVER=1.18- - GHCVER=head CABALVER=1.18 + - GHCVER=7.8.2 CABALVER=1.20+ - GHCVER=head CABALVER=1.20  before_install:  - sudo add-apt-repository -y ppa:hvr/ghc@@ -20,5 +21,5 @@  matrix:   allow_failures:-   - env: GHCVER=head CABALVER=1.18+   - env: GHCVER=head CABALVER=1.20   fast_finish: true
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2014 Benno Fünfstück+Copyright 2013-2014 Benno Fünfstück  All rights reserved. 
src/Instances/TH/Lift.hs view
@@ -1,8 +1,8 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE TemplateHaskell #-}-module Instances.TH.Lift +module Instances.TH.Lift   ( -- | This module provides orphan instances for the 'Language.Haskell.TH.Syntax.Lift' class from template-haskell. Following is a list of the provided instances.-    -- +    --     -- Lift instances are useful to precompute values at compile time using template haskell. For example, if you write the following code,     -- you can make sure that @3 * 10@ is really computed at compile time:     --@@ -14,6 +14,8 @@     -- > expensiveComputation = $(lift $ 3 * 10) -- This will computed at compile time     --     -- This uses the Lift instance for Word32.+    --+    -- The following instances are provided by this package:      -- * Base     -- |  * 'Word8', 'Word16', 'Word32', 'Word64'@@ -22,11 +24,11 @@      -- * Containers (both strict/lazy)     -- |  * 'Data.IntMap.IntMap'-    -- +    --     --    * 'Data.IntSet.IntSet'-    --    +    --     --    * 'Data.Map.Map'-    -- +    --     --    * 'Data.Set.Set'     --     --    * 'Data.Tree.Tree'@@ -34,10 +36,14 @@     --    * 'Data.Sequence.Seq'      -- * ByteString (both strict/lazy)-    -- |  * 'Data.ByteString'-    +    -- |  * 'Data.ByteString.ByteString'+     -- * Text (both strict/lazy)-    -- |  * 'Data.Text'+    -- |  * 'Data.Text.Text'++    -- * Vector (Boxed, Unboxed, Storable, Primitive)+    -- |  * 'Data.Vector.Vector'+   ) where  import Language.Haskell.TH@@ -64,6 +70,12 @@ -- ByteString import qualified Data.ByteString as ByteString import qualified Data.ByteString.Lazy as ByteString.Lazy++-- Vector+import qualified Data.Vector as Vector.Boxed+import qualified Data.Vector.Primitive as Vector.Primitive+import qualified Data.Vector.Storable as Vector.Storable+import qualified Data.Vector.Unboxed as Vector.Unboxed --------------------------------------------------------------------------------  --------------------------------------------------------------------------------@@ -104,7 +116,7 @@   lift m = [| IntMap.fromList $(lift $ IntMap.toList m) |]  instance Lift IntSet.IntSet where-  lift s = [| IntSet.fromList $(lift $ IntSet.toList s) |] +  lift s = [| IntSet.fromList $(lift $ IntSet.toList s) |]  instance (Lift k, Lift v) => Lift (Map.Map k v) where   lift m = [| Map.fromList $(lift $ Map.toList m) |]@@ -132,3 +144,17 @@  instance Lift ByteString.Lazy.ByteString where   lift b = [| ByteString.Lazy.pack $(lift $ ByteString.Lazy.unpack b) |]++--------------------------------------------------------------------------------+-- Vector+instance (Vector.Primitive.Prim a, Lift a) => Lift (Vector.Primitive.Vector a) where+  lift v = [| Vector.Primitive.fromList $(lift $ Vector.Primitive.toList v) |]++instance (Vector.Storable.Storable a, Lift a) => Lift (Vector.Storable.Vector a) where+  lift v = [| Vector.Storable.fromList $(lift $ Vector.Storable.toList v) |]++instance (Vector.Unboxed.Unbox a, Lift a) => Lift (Vector.Unboxed.Vector a) where+  lift v = [| Vector.Unboxed.fromList $(lift $ Vector.Unboxed.toList v) |]++instance Lift a => Lift (Vector.Boxed.Vector a) where+  lift v = [| Vector.Boxed.fromList $(lift $ Vector.Boxed.toList v) |]
tests/Main.hs view
@@ -23,6 +23,11 @@ import qualified Data.ByteString as ByteString import qualified Data.ByteString.Lazy as ByteString.Lazy +import qualified Data.Vector as Vector.Boxed+import qualified Data.Vector.Primitive as Vector.Primitive+import qualified Data.Vector.Storable as Vector.Storable+import qualified Data.Vector.Unboxed as Vector.Unboxed+ -------------------------------------------------------------------------------- -- Base prop_word8 :: Bool@@ -91,7 +96,21 @@ prop_lazy_bytestring :: Bool prop_lazy_bytestring = $(lift $ ByteString.Lazy.pack bytedata) == ByteString.Lazy.pack bytedata +--------------------------------------------------------------------------------+-- Vector+prop_boxed_vector :: Bool+prop_boxed_vector = $(lift $ Vector.Boxed.fromList bytedata) == Vector.Boxed.fromList bytedata++prop_unboxed_vector :: Bool+prop_unboxed_vector = $(lift $ Vector.Unboxed.fromList bytedata) == Vector.Unboxed.fromList bytedata++prop_primitive_vector :: Bool+prop_primitive_vector = $(lift $ Vector.Primitive.fromList bytedata) == Vector.Primitive.fromList bytedata++prop_storable_vector :: Bool+prop_storable_vector = $(lift $ Vector.Storable.fromList bytedata) == Vector.Storable.fromList bytedata+ main :: IO ()-main = do +main = do   success <- $quickCheckAll   unless success exitFailure
th-lift-instances.cabal view
@@ -1,5 +1,5 @@ name:          th-lift-instances-version:       0.1.1+version:       0.1.2 license:       BSD3 cabal-version: >= 1.10 license-file:  LICENSE@@ -8,10 +8,10 @@ stability:     experimental homepage:      http://github.com/bennofs/th-lift-instances/ bug-reports:   http://github.com/bennofs/th-lift-instances/issues-copyright:     Copyright (C) 2013 Benno Fünfstück-synopsis:      Lift instances for template-hasell for common data types.+copyright:     Copyright (C) 2013-2014 Benno Fünfstück+synopsis:      Lift instances for template-haskell for common data types. description:   Most data types in haskell platform do not have Lift instances. This package provides orphan instances-	       for containers, text and bytestring.+	       for containers, text, bytestring and vector. build-type:    Custom category:      Template Haskell