lens-accelerate 0.1.0.0 → 0.2.0.0
raw patch · 7 files changed
+140/−12 lines, 7 filesdep ~acceleratedep ~base
Dependency ranges changed: accelerate, base
Files
- CHANGELOG.markdown +19/−1
- README.markdown +1/−0
- lens-accelerate.cabal +12/−7
- src/Data/Array/Accelerate/Control/Lens.hs +6/−2
- src/Data/Array/Accelerate/Control/Lens/Each.hs +3/−1
- src/Data/Array/Accelerate/Control/Lens/Lift.hs +4/−1
- src/Data/Array/Accelerate/Control/Lens/Shape.hs +95/−0
CHANGELOG.markdown view
@@ -1,4 +1,22 @@-0.1.0.0+# Change Log +Notable changes to the project will be documented in this file.++The format is based on [Keep a Changelog](http://keepachangelog.com/) and the+project adheres to the [Haskell Package Versioning+Policy (PVP)](https://pvp.haskell.org)++## [0.2.0.0] - 2018-04-03+### Added+ * `Field` instances for `Shape`s, where `_1` is the right-most component of+ the shape (x-coordinate), `_2` is the next component (y-coordinate), etc.++### Changed+ * updates for accelerate-1.2++## 0.1.0.0 - 2017-03-31+ * Initial release++[0.2.0.0]: https://github.com/tmcdonell/lens-accelerate/compare/0.1.0.0...0.2.0.0
README.markdown view
@@ -2,6 +2,7 @@ =============== [](https://travis-ci.org/tmcdonell/lens-accelerate)+[](https://hackage.haskell.org/package/lens-accelerate) Instances to mix [lens][lens] with [accelerate][accelerate].
lens-accelerate.cabal view
@@ -1,5 +1,5 @@ name: lens-accelerate-version: 0.1.0.0+version: 0.2.0.0 synopsis: Instances to mix lens with accelerate description: Instances to mix lens with accelerate homepage: https://github.com/tmcdonell/lens-accelerate@@ -20,29 +20,34 @@ exposed-modules: Data.Array.Accelerate.Control.Lens Data.Array.Accelerate.Control.Lens.Each+ Data.Array.Accelerate.Control.Lens.Shape Data.Array.Accelerate.Control.Lens.Tuple other-modules: Data.Array.Accelerate.Control.Lens.Lift build-depends:- base >= 4.7 && < 4.10- , accelerate >= 0.15+ base >= 4.7 && < 4.12+ , accelerate >= 1.0 , lens == 4.* - ghc-options: -Wall+ ghc-options:+ -Wall - hs-source-dirs: src- default-language: Haskell2010+ hs-source-dirs:+ src + default-language:+ Haskell2010 + source-repository head Type: git Location: git://github.com/tmcdonell/lens-accelerate.git source-repository this Type: git- Tag: 0.1.0.0+ Tag: 0.2.0.0 Location: git://github.com/tmcdonell/lens-accelerate.git -- vim: nospell
src/Data/Array/Accelerate/Control/Lens.hs view
@@ -12,11 +12,15 @@ module Data.Array.Accelerate.Control.Lens ( - module Control.Lens+ module Control.Lens,+ liftLens, ) where import Control.Lens-import Data.Array.Accelerate.Control.Lens.Tuple ()+import Data.Array.Accelerate.Control.Lens.Lift+ import Data.Array.Accelerate.Control.Lens.Each ()+import Data.Array.Accelerate.Control.Lens.Shape ()+import Data.Array.Accelerate.Control.Lens.Tuple ()
src/Data/Array/Accelerate/Control/Lens/Each.hs view
@@ -1,4 +1,6 @@+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -----------------------------------------------------------------------------@@ -26,7 +28,7 @@ import Data.Array.Accelerate.Control.Lens.Lift -instance (Elt a, Elt b) => Each (Exp (Complex a)) (Exp (Complex b)) (Exp a) (Exp b) where+instance (Elt a, Elt b, Elt (Complex a), Elt (Complex b)) => Each (Exp (Complex a)) (Exp (Complex b)) (Exp a) (Exp b) where each = liftLens (each :: Traversal (Complex (Exp a)) (Complex (Exp b)) (Exp a) (Exp b)) instance (Elt a, Elt b) => Each (Exp (a,a)) (Exp (b,b)) (Exp a) (Exp b) where
src/Data/Array/Accelerate/Control/Lens/Lift.hs view
@@ -30,7 +30,10 @@ #endif --- Lift a 'Lens' into Accelerate terms+-- | Lift a 'Lens' into a lens on the equivalent Accelerate term.+--+-- The instances exported by this package are all defined in terms of this+-- function, using the definitions from the base @lens@ package. -- liftLens :: (Functor f, Unlift box s, Unlift box t, Unlift box b, Lift box a)
+ src/Data/Array/Accelerate/Control/Lens/Shape.hs view
@@ -0,0 +1,95 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeOperators #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++-----------------------------------------------------------------------------+-- |+-- Module : Data.Array.Accelerate.Control.Lens.Shape+-- Copyright : 2015 Trevor L. McDonell+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>+-- Stability : experimental+-- Portability : non-portable+--+----------------------------------------------------------------------------++module Data.Array.Accelerate.Control.Lens.Shape (++ module Control.Lens.Tuple++) where++import Control.Lens+import Control.Lens.Tuple+import Data.Array.Accelerate+++instance (Slice sh, Elt a, Elt a')+ => Field1 (Exp (sh :. a)) (Exp (sh :. a')) (Exp a) (Exp a') where+ _1 = lens indexHead (\sh b -> lift (indexTail sh :. b))++instance (Slice sh, Elt a, Elt b, Elt b', Slice (sh :. b), Slice (sh :. b'))+ => Field2 (Exp (sh :. b :. a)) (Exp (sh :. b' :. a)) (Exp b) (Exp b') where+ _2 = lens (\s -> let _ :. b :. _ = unlift s :: Exp sh :. Exp b :. Exp a in b)+ (\s b -> let sh :. _ :. a = unlift s :: Exp sh :. Exp b :. Exp a in lift (sh :. b :. a))++instance ( Slice sh, Elt a, Elt b, Elt c, Elt c'+ , Slice (sh :. c), Slice (sh :. c :. b)+ , Slice (sh :. c'), Slice (sh :. c' :. b)+ )+ => Field3 (Exp (sh :. c :. b :. a)) (Exp (sh :. c' :. b :. a)) (Exp c) (Exp c') where+ _3 = lens (\s -> let _ :. c :. _ :. _ = unlift s :: Exp sh :. Exp c :. Exp b :. Exp a in c)+ (\s c -> let sh :. _ :. b :. a = unlift s :: Exp sh :. Exp c :. Exp b :. Exp a in lift (sh :. c :. b :. a))++instance ( Slice sh, Elt a, Elt b, Elt c, Elt d, Elt d'+ , Slice (sh :. d), Slice (sh :. d :. c), Slice (sh :. d :. c :. b)+ , Slice (sh :. d'), Slice (sh :. d' :. c), Slice (sh :. d' :. c :. b)+ )+ => Field4 (Exp (sh :. d :. c :. b :. a)) (Exp (sh :. d' :. c :. b :. a)) (Exp d) (Exp d') where+ _4 = lens (\s -> let _ :. d :. _ :. _ :. _ = unlift s :: Exp sh :. Exp d :. Exp c :. Exp b :. Exp a in d)+ (\s d -> let sh :. _ :. c :. b :. a = unlift s :: Exp sh :. Exp d :. Exp c :. Exp b :. Exp a in lift (sh :. d :. c :. b :. a))++instance ( Slice sh, Elt a, Elt b, Elt c, Elt d, Elt e, Elt e'+ , Slice (sh :. e), Slice (sh :. e :. d), Slice (sh :. e :. d :. c), Slice (sh :. e :. d :. c :. b)+ , Slice (sh :. e'), Slice (sh :. e' :. d), Slice (sh :. e' :. d :. c), Slice (sh :. e' :. d :. c :. b)+ )+ => Field5 (Exp (sh :. e :. d :. c :. b :. a)) (Exp (sh :. e' :. d :. c :. b :. a)) (Exp e) (Exp e') where+ _5 = lens (\s -> let _ :. e :. _ :. _ :. _ :. _ = unlift s :: Exp sh :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in e)+ (\s e -> let sh :. _ :. d :. c :. b :. a = unlift s :: Exp sh :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in lift (sh :. e :. d :. c :. b :. a))++instance ( Slice sh, Elt a, Elt b, Elt c, Elt d, Elt e, Elt f, Elt f'+ , Slice (sh :. f), Slice (sh :. f :. e), Slice (sh :. f :. e :. d), Slice (sh :. f :. e :. d :. c), Slice (sh :. f :. e :. d :. c :. b)+ , Slice (sh :. f'), Slice (sh :. f' :. e), Slice (sh :. f' :. e :. d), Slice (sh :. f' :. e :. d :. c), Slice (sh :. f' :. e :. d :. c :. b)+ )+ => Field6 (Exp (sh :. f :. e :. d :. c :. b :. a)) (Exp (sh :. f' :. e :. d :. c :. b :. a)) (Exp f) (Exp f') where+ _6 = lens (\s -> let _ :. f :. _ :. _ :. _ :. _ :. _ = unlift s :: Exp sh :. Exp f :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in f)+ (\s f -> let sh :. _ :. e :. d :. c :. b :. a = unlift s :: Exp sh :. Exp f :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in lift (sh :. f :. e :. d :. c :. b :. a))++instance ( Slice sh , Elt a, Elt b, Elt c, Elt d, Elt e, Elt f, Elt g, Elt g'+ , Slice (sh :. g), Slice (sh :. g :. f), Slice (sh :. g :. f :. e), Slice (sh :. g :. f :. e :. d), Slice (sh :. g :. f :. e :. d :. c), Slice (sh :. g :. f :. e :. d :. c :. b)+ , Slice (sh :. g'), Slice (sh :. g' :. f), Slice (sh :. g' :. f :. e), Slice (sh :. g' :. f :. e :. d), Slice (sh :. g' :. f :. e :. d :. c), Slice (sh :. g' :. f :. e :. d :. c :. b)+ )+ => Field7 (Exp (sh :. g :. f :. e :. d :. c :. b :. a)) (Exp (sh :. g' :. f :. e :. d :. c :. b :. a)) (Exp g) (Exp g') where+ _7 = lens (\s -> let _ :. g :. _ :. _ :. _ :. _ :. _ :. _ = unlift s :: Exp sh :. Exp g :. Exp f :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in g)+ (\s g -> let sh :. _ :. f :. e :. d :. c :. b :. a = unlift s :: Exp sh :. Exp g :. Exp f :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in lift (sh :. g :. f :. e :. d :. c :. b :. a))++instance ( Slice sh, Elt a, Elt b, Elt c, Elt d, Elt e, Elt f, Elt g, Elt h, Elt h'+ , Slice (sh :. h), Slice (sh :. h :. g), Slice (sh :. h :. g :. f), Slice (sh :. h :. g :. f :. e), Slice (sh :. h :. g :. f :. e :. d), Slice (sh :. h :. g :. f :. e :. d :. c), Slice (sh :. h :. g :. f :. e :. d :. c :. b)+ , Slice (sh :. h'), Slice (sh :. h' :. g), Slice (sh :. h' :. g :. f), Slice (sh :. h' :. g :. f :. e), Slice (sh :. h' :. g :. f :. e :. d), Slice (sh :. h' :. g :. f :. e :. d :. c), Slice (sh :. h' :. g :. f :. e :. d :. c :. b)+ )+ => Field8 (Exp (sh :. h :. g :. f :. e :. d :. c :. b :. a)) (Exp (sh :. h' :. g :. f :. e :. d :. c :. b :. a)) (Exp h) (Exp h') where+ _8 = lens (\s -> let _ :. h :. _ :. _ :. _ :. _ :. _ :. _ :. _ = unlift s :: Exp sh :. Exp h :. Exp g :. Exp f :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in h)+ (\s h -> let sh :. _ :. g :. f :. e :. d :. c :. b :. a = unlift s :: Exp sh :. Exp h :. Exp g :. Exp f :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in lift (sh :. h :. g :. f :. e :. d :. c :. b :. a))++instance ( Slice sh, Elt a, Elt b, Elt c, Elt d, Elt e, Elt f, Elt g, Elt h, Elt i, Elt i'+ , Slice (sh :. i), Slice (sh :. i :. h), Slice (sh :. i :. h :. g), Slice (sh :. i :. h :. g :. f), Slice (sh :. i :. h :. g :. f :. e), Slice (sh :. i :. h :. g :. f :. e :. d), Slice (sh :. i :. h :. g :. f :. e :. d :. c), Slice (sh :. i :. h :. g :. f :. e :. d :. c :. b)+ , Slice (sh :. i'), Slice (sh :. i' :. h), Slice (sh :. i' :. h :. g), Slice (sh :. i' :. h :. g :. f), Slice (sh :. i' :. h :. g :. f :. e), Slice (sh :. i' :. h :. g :. f :. e :. d), Slice (sh :. i' :. h :. g :. f :. e :. d :. c), Slice (sh :. i' :. h :. g :. f :. e :. d :. c :. b)+ )+ => Field9 (Exp (sh :. i :. h :. g :. f :. e :. d :. c :. b :. a)) (Exp (sh :. i' :. h :. g :. f :. e :. d :. c :. b :. a)) (Exp i) (Exp i') where+ _9 = lens (\s -> let _ :. i :. _ :. _ :. _ :. _ :. _ :. _ :. _ :. _ = unlift s :: Exp sh :. Exp i :. Exp h :. Exp g :. Exp f :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in i)+ (\s i -> let sh :. _ :. h :. g :. f :. e :. d :. c :. b :. a = unlift s :: Exp sh :. Exp i :. Exp h :. Exp g :. Exp f :. Exp e :. Exp d :. Exp c :. Exp b :. Exp a in lift (sh :. i :. h :. g :. f :. e :. d :. c :. b :. a))+