packages feed

vector-th-unbox 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+18/−17 lines, 2 filesdep ~basedep ~template-haskelldep ~vectorPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, template-haskell, vector

API changes (from Hackage documentation)

Files

Data/Vector/Unboxed/Deriving.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE Trustworthy #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS -Wall #-}@@ -12,10 +13,10 @@ Stability:   experimental Portability: non-portable -Writing Unbox instances for new data types is tedious and formulaic. More+Writing @Unbox@ instances for new data types is tedious and formulaic. More often than not, there is a straightforward mapping of the new type onto some-existing one already imbued with an Unbox instance. The example from the-vector package represents @Complex a@ as pairs @(a, a)@. (See+existing one already imbued with an @Unbox@ instance. The example from the+@vector@ package represents @Complex a@ as pairs @(a, a)@. (See <http://hackage.haskell.org/packages/archive/vector/latest/doc/html/Data-Vector-Unboxed.html>.) Using 'derivingUnbox', we can define the same instances much more succinctly:@@ -26,10 +27,7 @@ >    [| \ (r, i) -> r :+ i |]  Requires the @MultiParamTypeClasses@, @TemplateHaskell@ and @TypeFamilies@-LANGUAGE extensions.--The dummy 'Unbox'' class provides a convenient way to pass in the source-and representation types, along with any requisite constraints.+@LANGUAGE@ extensions.  -} @@ -45,27 +43,30 @@ import Data.Vector.Unboxed.Base (MVector (..), Vector (..), Unbox) import Language.Haskell.TH --- | A dummy class for passing arguments to 'derivingUnbox'.+-- | A dummy class providing a convenient way to pass in the source and+-- representation types, along with any requisite constraints and (implicit)+-- type variable introductions. class Unbox' src rep --- Create a Pat bound to the given name and an Exp for said binding.+-- Create a @Pat@ bound to the given name and an @Exp@ for said binding. newPatExp :: String -> Q (Pat, Exp) newPatExp = fmap (VarP &&& VarE) . newName  -- Create a wrapper for the given function with the same 'nameBase', given -- a list of argument bindings and expressions in terms of said bindings.--- Complimentary INLINE pragma included.+-- A final coercion (@Exp -> Exp@) is applied to the body of the function.+-- Complimentary @INLINE@ pragma included. wrap :: Name -> [(Pat, Exp)] -> (Exp -> Exp) -> [Dec] wrap fun (unzip -> (pats, exps)) coerce = [inline, method] where     base = mkName (nameBase fun)-    inline = PragmaD (InlineP base (InlineSpec True False Nothing))+    inline = PragmaD (InlineP base Inline FunLike AllPhases)     body = coerce $ foldl AppE (VarE fun) exps     method = FunD base [Clause pats (NormalB body) []]  {-| Let's consider a more complex example: suppose we want an @Unbox@ instance for @Maybe a@. We can encode this using the pair @(Bool, a)@, with the boolean indicating whether we have @Nothing@ or @Just@ something. This-encoding requires a dummy value in the Nothing case, necessitating an+encoding requires a dummy value in the @Nothing@ case, necessitating an additional @Default@ (see the @data-default@ package) constraint. Thus:  >derivingUnbox "Maybe"
vector-th-unbox.cabal view
@@ -1,6 +1,6 @@ name:           vector-th-unbox-version:        0.1.0.0-synopsis:       Deriver for unboxed vectors using Template Haskell+version:        0.1.0.1+synopsis:       Deriver for Data.Vector.Unboxed using Template Haskell description:     A Template Haskell deriver for unboxed vectors, given a pair of coercion     functions to and from some existing type with an Unbox instance.@@ -24,9 +24,9 @@         Data.Vector.Unboxed.Deriving      build-depends:-        base >= 4.3 && < 5,-        template-haskell >= 2.5,-        vector >= 0.7+        base >= 4.5 && < 5,+        template-haskell >= 2.8,+        vector >= 0.9  -- vim: et sw=4 ts=4 sts=4: