diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) [2007..2012] The Accelerate Team.  All rights reserved.
+Copyright (c) [2007..2020] The Accelerate Team.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -7,8 +7,8 @@
     * 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 names of the contributors nor of their affiliations may 
-      be used to endorse or promote products derived from this software 
+    * Neither the names of the contributors nor of their affiliations 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 ''AS IS'' AND ANY
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,19 +1,27 @@
-Examples programs using Accelerate
-==================================
+<div align="center">
+<img width="450" src="https://github.com/AccelerateHS/accelerate/raw/master/images/accelerate-logo-text-v.png?raw=true" alt="henlo, my name is Theia"/>
 
-[![Build Status](https://travis-ci.org/AccelerateHS/accelerate-examples.svg?branch=master)](https://travis-ci.org/AccelerateHS/accelerate-examples)
+# Example programs using Accelerate
+
+[![GitHub CI](https://github.com/tmcdonell/accelerate-examples/workflows/CI/badge.svg)](https://github.com/tmcdonell/accelerate-examples/actions)
+[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/AccelerateHS/Lobby)
+<br>
+[![Stackage LTS](https://stackage.org/package/accelerate-examples/badge/lts)](https://stackage.org/lts/package/accelerate-examples)
+[![Stackage Nightly](https://stackage.org/package/accelerate-examples/badge/nightly)](https://stackage.org/nightly/package/accelerate-examples)
 [![Hackage](https://img.shields.io/hackage/v/accelerate-examples.svg)](https://hackage.haskell.org/package/accelerate-examples)
+<br>
 [![Docker Automated build](https://img.shields.io/docker/automated/tmcdonell/accelerate-examples.svg)](https://hub.docker.com/r/tmcdonell/accelerate-examples/)
 [![Docker status](https://images.microbadger.com/badges/image/tmcdonell/accelerate-examples.svg)](https://microbadger.com/images/tmcdonell/accelerate-examples)
 
-Example programs using the Accelerate library. If you add new features to the
-base library or find a bug, please add a test case. The aim is for this program
-to evolve and be useful for both performance and regression testing.
+</div>
 
-If you have found a bug, please report it to:
-https://github.com/AccelerateHS/accelerate/issues
+Example programs using the Accelerate library. The aim is for this package to
+evolve and be useful for both performance and regression testing.
 
+Contributions and bug reports are welcome!<br>
+Please feel free to contact me through [GitHub](https://github.com/AccelerateHS/accelerate/issues) or [gitter.im](https://gitter.im/AccelerateHS/Lobby).
 
+
 Installation
 ------------
 
@@ -24,14 +32,14 @@
 for your system.
 
   * Ubuntu/Debian (apt-get):
-    - llvm-4.0-dev
+    - llvm-9-dev
     - freeglut3-dev
     - libfftw3-dev
 
   * Mac OS ([homebrew](http://brew.sh/index.html))
     - fftw
     - libffi
-    - llvm-hs/homebrew-llvm/llvm-4.0
+    - llvm-hs/homebrew-llvm/llvm-9
 
 If you want to use the CUDA GPU enabled backend
 [`accelerate-llvm-ptx`](https://github.com/AccelerateHS/accelerate-llvm), you
@@ -41,14 +49,14 @@
   * https://developer.nvidia.com/cuda-downloads
 
 
-### stack
+### Building: stack
 
 For development, the recommend build method is via the
 [`stack`](http://haskellstack.org) tool. This will simplify pulling in
-dependencies not yet on Hackage. For example, to build using ghc-8.0:
+dependencies not yet on Hackage. For example, to build using ghc-8.10:
 
 ```bash
-ln -s stack-8.0.yaml stack.yaml     # only once
+ln -s stack-8.10.yaml stack.yaml    # only once
 stack build                         # or, 'stack install' to install the executables globally
 ```
 
@@ -63,5 +71,5 @@
 
 Adding support for new Accelerate backends should require only a few minor
 additions to the cabal file and the module
-'Data.Array.Accelerate.Examples.Internal.Backend'. 
+'Data.Array.Accelerate.Examples.Internal.Backend'.
 
diff --git a/accelerate-examples.cabal b/accelerate-examples.cabal
--- a/accelerate-examples.cabal
+++ b/accelerate-examples.cabal
@@ -1,30 +1,29 @@
-Name:                   accelerate-examples
-Version:                1.2.0.1
-Cabal-version:          >=1.8
-Tested-with:            GHC >= 7.8
-Build-type:             Simple
+name:                   accelerate-examples
+version:                1.3.0.0
+cabal-version:          >=1.10
+tested-with:            GHC >= 8.6
+build-type:             Simple
 
-Synopsis:               Examples using the Accelerate library
-Description:
-  This package demonstrates a number of computation kernels and applications
-  showcasing the /Accelerate/ language and associated backend implementations.
-  It is also used for performance and regression testing.
+synopsis:               Examples using the Accelerate library
+description:
+  Example programs using the Accelerate library. The aim is for this package to
+  evolve and be useful for both performance and regression testing.
   .
   Refer to the main /Accelerate/ package for more information:
   <http://hackage.haskell.org/package/accelerate>
   .
 
-License:                BSD3
-License-file:           LICENSE
-Author:                 The Accelerate Team
-Maintainer:             Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
-Homepage:               https://github.com/AccelerateHS/accelerate-examples
-Bug-reports:            https://github.com/AccelerateHS/accelerate/issues
+license:                BSD3
+license-file:           LICENSE
+author:                 The Accelerate Team
+maintainer:             Trevor L. McDonell <trevor.mcdonell@gmail.com>
+homepage:               https://github.com/AccelerateHS/accelerate-examples
+bug-reports:            https://github.com/AccelerateHS/accelerate/issues
 
-Category:               Compilers/Interpreters, Concurrency, Data, Parallelism
-Stability:              Experimental
+category:               Accelerate
+stability:              Experimental
 
-Extra-source-files:
+extra-source-files:
     README.md
     data/matrices/README.md
     examples/canny/README.md
@@ -37,106 +36,113 @@
 
 -- Flags that control features of the benchmark programs
 --
-Flag gui
-  Description:          Enable gloss-based GUIs, where applicable. If not
+flag gui
+  description:          Enable gloss-based GUIs, where applicable. If not
                         enabled, the application always runs in benchmark mode.
-  Default:              True
+  default:              True
 
-Flag ekg
-  Description:          Enable EKG remote monitoring server at <http://localhost:8000>
-  Default:              True
+flag ekg
+  description:          Enable EKG remote monitoring server at <http://localhost:8000>
+  default:              True
 
-Flag codespeed
-  Description:          Enable upload of results to benchmark server
-  Default:              False
+flag codespeed
+  description:          Enable upload of results to benchmark server
+  default:              False
 
 -- Flags that control which Accelerate backends that are linked against
 --
-Flag llvm-cpu
-  Description:          Enable the LLVM backend for multicore CPUs
-  Default:              True
+flag llvm-cpu
+  description:          Enable the LLVM backend for multicore CPUs
+  default:              True
 
-Flag llvm-ptx
-  Description:          Enable the LLVM PTX backend for NVIDIA GPUs
-  Default:              True
+flag llvm-ptx
+  description:          Enable the LLVM PTX backend for NVIDIA GPUs
+  default:              True
 
 -- Flags to specify which programs to build
 --
-Flag smvm
-  Description:          Sparse-matrix vector multiplication benchmark
-  Default:              True
+flag smvm
+  description:          Sparse-matrix vector multiplication benchmark
+  default:              True
 
-Flag crystal
-  Description:          A visualisation of a sum of waves in a plane
-  Default:              True
+flag crystal
+  description:          A visualisation of a sum of waves in a plane
+  default:              True
 
-Flag tunnel
-  Description:          The slit-scan effect creating a Doctor Who time vortex
-  Default:              True
+flag tunnel
+  description:          The slit-scan effect creating a Doctor Who time vortex
+  default:              True
 
-Flag canny
-  Description:          Canny edge detection benchmark
-  Default:              True
+flag canny
+  description:          Canny edge detection benchmark
+  default:              True
 
-Flag mandelbrot
-  Description:          A Mandelbrot fractal benchmark
-  Default:              True
+flag mandelbrot
+  description:          A Mandelbrot fractal benchmark
+  default:              True
 
-Flag fluid
-  Description:          An interactive particle-based fluid simulation
-  Default:              True
+flag julia
+  description:          An interactive julia-set simulator
+  default:              True
 
-Flag nbody
-  Description:          Simulation of gravitational attraction between solid particles
-  Default:              True
+flag fluid
+  description:          An interactive particle-based fluid simulation
+  default:              True
 
-Flag smoothlife
-  Description:          A cellular automata simulation
-  Default:              True
+flag nbody
+  description:          Simulation of gravitational attraction between solid particles
+  default:              True
 
-Flag hashcat
-  Description:          A "password recovery" application for MD5 cracking
-  Default:              True
+flag smoothlife
+  description:          A cellular automata simulation
+  default:              True
 
-Flag fft
-  Description:          Simple FFT-based high/low-pass image filtering
-  Default:              True
+flag hashcat
+  description:          A "password recovery" application for MD5 cracking
+  default:              True
 
-Flag pagerank
-  Description:          Implementation of the PageRank algorithm
-  Default:              True
+flag fft
+  description:          Simple FFT-based high/low-pass image filtering
+  default:              True
 
-Flag ray
-  Description:          A simple real-time ray tracer
-  Default:              True
+flag pagerank
+  description:          Implementation of the PageRank algorithm
+  default:              True
 
-Flag kmeans
-  Description:          An implementation of k-means clustering in a plane
-  Default:              True
+flag quicksort
+  description:          Implementation of the QuickSort algorithm
+  default:              True
 
+flag ray
+  description:          A simple real-time ray tracer
+  default:              True
 
+flag kmeans
+  description:          An implementation of k-means clustering in a plane
+  default:              True
+
+
 -- Test harness
 -- ------------
 
-Library
+library
+  default-language:     Haskell2010
   hs-source-dirs:       lib
-  Build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+  build-depends:
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , ansi-wl-pprint                  >= 0.6
         , containers                      >= 0.5
         , criterion                       >= 1.0
         , directory                       >= 1.1
         , fclabels                        >= 2.0
         , HUnit                           >= 1.2
-        , linear                          >= 1.1
-        , mwc-random                      >= 0.8
         , QuickCheck                      >= 2.7
         , test-framework                  >= 0.5
         , test-framework-hunit            >= 0.3
         , test-framework-quickcheck2      >= 0.2
 
-  Exposed-modules:
+  exposed-modules:
         Data.Array.Accelerate.Examples.Internal
 
   Other-modules:
@@ -146,9 +152,7 @@
         Data.Array.Accelerate.Examples.Internal.Interactive
         Data.Array.Accelerate.Examples.Internal.Monitoring
         Data.Array.Accelerate.Examples.Internal.ParseArgs
-        Data.Array.Accelerate.Examples.Internal.Random.Array
         Data.Array.Accelerate.Examples.Internal.Report
-        Data.Array.Accelerate.Examples.Internal.Similar
         Data.Array.Accelerate.Examples.Internal.TestFramework
         Data.Array.Accelerate.Examples.Internal.TestFramework.Config
         Data.Array.Accelerate.Examples.Internal.Util
@@ -162,12 +166,12 @@
   if flag(llvm-cpu)
     CPP-options:        -DACCELERATE_LLVM_NATIVE_BACKEND
     build-depends:
-        accelerate-llvm-native            >= 1.2
+        accelerate-llvm-native            >= 1.3
 
   if flag(llvm-ptx)
     CPP-options:        -DACCELERATE_LLVM_PTX_BACKEND
     build-depends:
-        accelerate-llvm-ptx               >= 1.2
+        accelerate-llvm-ptx               >= 1.3
 
   if flag(ekg)
     CPP-options:        -DACCELERATE_ENABLE_EKG
@@ -194,9 +198,10 @@
 -- Sparse matrix vector multiplication
 -- -----------------------------------
 
-Executable accelerate-smvm
+executable accelerate-smvm
+  default-language:     Haskell2010
   hs-source-dirs:       examples/smvm
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:        Config Matrix SMVM
 
   ghc-options:
@@ -221,10 +226,10 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
-        , accelerate-io                   >= 1.1
+        , accelerate-io-vector            >= 0.1
         , fclabels                        >= 2.0
         , matrix-market-attoparsec        >= 0.1
         , mwc-random                      >= 0.8
@@ -236,9 +241,10 @@
 -- A quasicrystal demo as the sum of waves in a plane
 -- --------------------------------------------------
 
-Executable accelerate-crystal
+executable accelerate-crystal
+  default-language:     Haskell2010
   hs-source-dirs:       examples/crystal
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:        Config
 
   ghc-options:
@@ -260,8 +266,8 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
         , colour-accelerate               >= 0.1
         , fclabels                        >= 2.0
@@ -271,9 +277,10 @@
 -- The slit-scan effect creating a Doctor Who time vortex
 -- ------------------------------------------------------
 
-Executable accelerate-tunnel
+executable accelerate-tunnel
+  default-language:     Haskell2010
   hs-source-dirs:       examples/tunnel
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:        Config
 
   ghc-options:
@@ -295,8 +302,8 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
         , fclabels                        >= 2.0
         , gloss-raster-accelerate         >= 2.0
@@ -307,9 +314,10 @@
 -- Image edge detection
 -- --------------------
 
-Executable accelerate-canny
+executable accelerate-canny
+  default-language:     Haskell2010
   hs-source-dirs:       examples/canny/src-acc
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:        Config Canny Wildfire
 
   ghc-options:
@@ -334,10 +342,11 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
-        , accelerate-io                   >= 1.2
+        , accelerate-io-bmp               >= 0.1
+        , accelerate-io-repa              >= 0.1
         , colour-accelerate               >= 0.1
         , fclabels                        >= 2.0
         , repa                            >= 3.1
@@ -348,9 +357,10 @@
 -- A simple mandelbrot generator
 -- -----------------------------
 
-Executable accelerate-mandelbrot
+executable accelerate-mandelbrot
+  default-language:     Haskell2010
   hs-source-dirs:       examples/mandelbrot
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:        Config Mandel World
 
   ghc-options:
@@ -372,22 +382,60 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
-        , accelerate-io                   >= 1.2
+        , accelerate-io-bmp               >= 0.1
         , colour-accelerate               >= 0.1
         , fclabels                        >= 2.0
         , gloss                           >= 1.7
         , gloss-accelerate                >= 2.0
 
 
+-- A julia set generator
+-- ---------------------
+
+executable accelerate-julia
+  default-language:     Haskell2010
+  hs-source-dirs:       examples/julia
+  main-is:              Main.hs
+  other-modules:        Config Julia Palette World
+
+  ghc-options:
+        -Wall
+        -threaded
+        -eventlog
+        -rtsopts
+        -with-rtsopts=-n2M
+        -with-rtsopts=-A64M
+        -with-rtsopts=-qg
+
+  ghc-prof-options:
+        -auto-all
+
+  if flag(ekg)
+    ghc-options:        -with-rtsopts=-T
+
+  if !flag(julia)
+    buildable:          False
+  else
+    build-depends:
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
+        , accelerate-examples
+        , colour-accelerate               >= 0.1
+        , fclabels                        >= 2.0
+        , gloss                           >= 1.7
+        , gloss-accelerate                >= 2.0
+
+
 -- A stable fluid simulation
 -- -------------------------
 
-Executable accelerate-fluid
-  Main-is:              Main.hs
+executable accelerate-fluid
+  default-language:     Haskell2010
   hs-source-dirs:       examples/fluid/src-acc
+  main-is:              Main.hs
   other-modules:        Config Event Fluid Type World
 
   ghc-options:
@@ -409,10 +457,11 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
-        , accelerate-io                   >= 1.2
+        , accelerate-io                   >= 1.3
+        , accelerate-io-bmp               >= 0.1
         , bmp                             >= 1.2
         , colour-accelerate               >= 0.1
         , fclabels                        >= 2.0
@@ -423,9 +472,10 @@
 -- Simulation of gravitational attraction between solid particles
 -- --------------------------------------------------------------
 
-Executable accelerate-nbody
+executable accelerate-nbody
+  default-language:     Haskell2010
   hs-source-dirs:       examples/n-body
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:
         Common.Body
         Common.Tree
@@ -460,22 +510,24 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
         , fclabels                        >= 2.0
         , gloss                           >= 1.7
         , lens-accelerate                 >= 0.1
         , linear-accelerate               >= 0.3
         , mwc-random                      >= 0.8
+        , mwc-random-accelerate           >= 0.1
 
 
 -- A celular automata
 -- ------------------
 
-Executable accelerate-smoothlife
+executable accelerate-smoothlife
+  default-language:     Haskell2010
   hs-source-dirs:       examples/smoothlife
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:
         Config
         Gloss.Draw
@@ -503,23 +555,25 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
-        , accelerate-fft                  >= 1.2
+        , accelerate-fft                  >= 1.3
         , colour-accelerate               >= 0.1
         , fclabels                        >= 2.0
         , gloss                           >= 1.7
         , gloss-accelerate                >= 2.0
         , mwc-random                      >= 0.8
+        , mwc-random-accelerate           >= 0.1
 
 
 -- A "password recovery" tool
 -- --------------------------
 
-Executable accelerate-hashcat
+executable accelerate-hashcat
+  default-language:     Haskell2010
   hs-source-dirs:       examples/hashcat
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:        Config Digest MD5
 
   ghc-options:
@@ -541,8 +595,8 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
         , bytestring                      >= 0.9
         , bytestring-lexing               >= 0.5
@@ -556,8 +610,9 @@
 -- FFT examples
 -- ------------
 
-Executable accelerate-fft
-  Main-is:              Main.hs
+executable accelerate-fft
+  default-language:     Haskell2010
+  main-is:              Main.hs
   hs-source-dirs:       examples/fft/src-acc
   other-modules:        Config HighPass FFT
 
@@ -580,11 +635,11 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
-        , accelerate-fft                  >= 1.2
-        , accelerate-io                   >= 1.2
+        , accelerate-fft                  >= 1.3
+        , accelerate-io-bmp               >= 0.1
         , colour-accelerate               >= 0.1
         , fclabels                        >= 2.0
         , filepath                        >= 1.0
@@ -592,9 +647,10 @@
 -- PageRank
 -- --------
 
-Executable accelerate-pagerank
+executable accelerate-pagerank
+  default-language:     Haskell2010
   hs-source-dirs:       examples/pagerank
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:
         Config
         Count
@@ -623,10 +679,10 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
-        , accelerate-io                   >= 1.2
+        , accelerate-io-vector            >= 0.1
         , bytestring                      >= 0.9.2
         , containers                      >= 0.4.2
         , directory                       >= 1.1
@@ -634,13 +690,50 @@
         , vector                          >= 0.9
         , vector-algorithms               >= 0.5.4
 
+-- QuickSort
+-- ---------
 
+executable accelerate-quicksort
+  default-language:     Haskell2010
+  hs-source-dirs:       examples/quicksort
+  main-is:              Main.hs
+  other-modules:
+        Config
+        QuickSort
+
+  ghc-options:
+        -Wall
+        -threaded
+        -eventlog
+        -rtsopts
+        -with-rtsopts=-n2M
+        -with-rtsopts=-A64M
+        -with-rtsopts=-qg
+
+  ghc-prof-options:
+        -auto-all
+
+  if flag(ekg)
+    ghc-options:        -with-rtsopts=-T
+
+  if !flag(quicksort)
+    buildable:          False
+  else
+    build-depends:
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
+        , accelerate-examples
+        , array                           >= 0.5.2
+        , fclabels                        >= 1.0
+        , random
+
 -- Ray tracer
 -- ----------
 
-Executable accelerate-ray
+executable accelerate-ray
+  default-language:     Haskell2010
   hs-source-dirs:       examples/ray
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:
         Common.Type
         Config
@@ -672,8 +765,8 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
         , colour-accelerate               >= 0.1
         , fclabels                        >= 1.0
@@ -687,9 +780,10 @@
 -- K-means
 -- -------
 
-Executable accelerate-kmeans
+executable accelerate-kmeans
+  default-language:     Haskell2010
   hs-source-dirs:       examples/kmeans
-  Main-is:              Main.hs
+  main-is:              Main.hs
   other-modules:        Config Kmeans
 
   ghc-options:
@@ -711,8 +805,8 @@
     buildable:          False
   else
     build-depends:
-          base                            >= 4.7 && < 4.13
-        , accelerate                      >= 1.2
+          base                            >= 4.7 && < 5
+        , accelerate                      == 1.3.*
         , accelerate-examples
         , binary                          >= 0.7
         , directory                       >= 1.1
@@ -727,7 +821,7 @@
 
 source-repository this
   type:                 git
-  tag:                  v1.2.0.1
+  tag:                  v1.3.0.0
   location:             https://github.com/AccelerateHS/accelerate-examples
 
 -- vim: nospell
diff --git a/examples/canny/src-acc/Canny.hs b/examples/canny/src-acc/Canny.hs
--- a/examples/canny/src-acc/Canny.hs
+++ b/examples/canny/src-acc/Canny.hs
@@ -207,5 +207,5 @@
       indices           = enumFromN (index1 $ size img) 0
       zeros             = fill (index1 $ the len) 0
   in
-  permute const zeros (\ix -> strong!ix == 0 ? (ignore, index1 $ targetIdx!ix)) indices
+  permute const zeros (\ix -> strong!ix == 0 ? (Nothing_, Just_ (I1 (targetIdx!ix)))) indices
 
diff --git a/examples/canny/src-acc/Wildfire.hs b/examples/canny/src-acc/Wildfire.hs
--- a/examples/canny/src-acc/Wildfire.hs
+++ b/examples/canny/src-acc/Wildfire.hs
@@ -7,9 +7,7 @@
 -- This function originally written by Ben Lippmeier for Repa.
 --
 -- NOTE: for best performance this needs to be compiled with the following GHC options:
---       -fllvm -optlo-O3 -Odph -fno-liberate-case
---       -funfolding-use-threshold100 -funfolding-keeness-factor100
---
+-- {-# OPTIONS_GHC -fllvm -optlo-O3 -O3 -fmax-simplifier-iterations=20 -fsimplifier-phases=3 -fno-liberate-case -funfolding-use-threshold100 -funfolding-keeness-factor100 #-}
 
 module Wildfire where
 
diff --git a/examples/fluid/src-acc/Fluid.hs b/examples/fluid/src-acc/Fluid.hs
--- a/examples/fluid/src-acc/Fluid.hs
+++ b/examples/fluid/src-acc/Fluid.hs
@@ -104,7 +104,7 @@
 inject source field =
   let (is, ps) = A.unlift source
   in A.size ps == 0
-       ?| ( field, A.permute (.+.) field (is A.!) ps )
+       ?| ( field, A.permute (.+.) field (\i -> Just_ (is A.! i)) ps )
 
 
 -- The core of the fluid flow algorithm is a finite time step simulation on the
diff --git a/examples/fluid/src-acc/World.hs b/examples/fluid/src-acc/World.hs
--- a/examples/fluid/src-acc/World.hs
+++ b/examples/fluid/src-acc/World.hs
@@ -18,11 +18,10 @@
 import Foreign.ForeignPtr
 import Foreign.Storable
 import Foreign.Marshal.Alloc
-import Data.Array.Accelerate                            ( Z(..), (:.)(..) )
-import Data.Array.Accelerate.Array.Sugar                ( Array(..) )
 
-import qualified Data.Array.Accelerate                  as A
-import qualified Data.Array.Accelerate.Array.Data       as A
+import Data.Array.Accelerate                                        ( Z(..), (:.)(..) )
+import Data.Array.Accelerate.IO.Foreign.Ptr
+import qualified Data.Array.Accelerate                              as A
 
 
 data World = World
@@ -81,7 +80,7 @@
 
 
 renderDensity :: DensityField -> IO Picture
-renderDensity df@(Array _ ad) = do
+renderDensity df = do
   dst   <- mallocBytes (n*4)
   fill 0 src dst
   fptr  <- newForeignPtr finalizerFree dst
@@ -92,7 +91,7 @@
   return $ bitmapOfForeignPtr w h     fptr False
 #endif
   where
-    src         = A.ptrsOfArrayData ad
+    src         = toPtrs df
     Z:.h:.w     = A.arrayShape df
     n           = h*w
     colour !f   = let c = 0 `max` f `min` 1
diff --git a/examples/hashcat/Digest.hs b/examples/hashcat/Digest.hs
--- a/examples/hashcat/Digest.hs
+++ b/examples/hashcat/Digest.hs
@@ -1,4 +1,5 @@
-{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE BangPatterns     #-}
+{-# LANGUAGE TypeApplications #-}
 
 module Digest (readDict, extract)
   where
@@ -6,18 +7,22 @@
 import MD5
 import Config
 
-import Data.Label
-import Control.Monad
 import Control.Applicative
-import Data.ByteString.Internal                 ( w2c )
-import qualified Data.Serialize                 as S
-import qualified Data.ByteString                as S
-import qualified Data.ByteString.Lazy.Char8     as L
+import Control.Monad
+import Data.ByteString.Internal                                     ( w2c )
+import Data.Label
+import Data.Word
 import Prelude
+import qualified Data.ByteString                                    as S
+import qualified Data.ByteString.Lazy.Char8                         as L
+import qualified Data.Serialize                                     as S
 
-import Data.Array.Accelerate.Array.Data         as A
-import Data.Array.Accelerate.Array.Sugar        as A
-import qualified Data.Array.Accelerate          as A
+import Data.Array.Accelerate.Array.Data                             as A
+import Data.Array.Accelerate.Sugar.Array
+import Data.Array.Accelerate.Sugar.Elt
+import Data.Array.Accelerate.Sugar.Shape
+import qualified Data.Array.Accelerate                              as A
+import qualified Data.Array.Accelerate.Representation.Array         as R
 
 
 -- MD5 block sizes
@@ -62,18 +67,18 @@
 
   let sh        = Z :. blockSizeWords :. entries
       (adata,_) = runArrayData $ do
-        arr <- newArrayData (size sh)
+        arr <- newArrayData (eltR @Word32) (size sh)
 
         let go !_ []     = return ()
             go !n (b:bs) = do
-              foldM_ (\i w -> do unsafeWriteArrayData arr (toIndex sh (Z:.i:.n)) (fromElt w)
+              foldM_ (\i w -> do writeArrayData (eltR @Word32) arr (toIndex sh (Z:.i:.n)) (fromElt w)
                                  return (i+1)) 0 (bytes b)
               go (n+1) bs
 
         go 0 blocks
-        return (arr, undefined)
+        return (arr, 0 :: Word32)
 
-  adata `seq` return $ Array (fromElt sh) adata
+  adata `seq` return $ Array (R.Array (fromElt sh) adata)
 
   where
     chunk = maybe id take (get configMaxWords c)
diff --git a/examples/hashcat/MD5.hs b/examples/hashcat/MD5.hs
--- a/examples/hashcat/MD5.hs
+++ b/examples/hashcat/MD5.hs
@@ -34,12 +34,11 @@
     -> Acc (Scalar MD5)
     -> Acc (Scalar Int)
 hashcatDict dict passwd
-  = reshape (constant Z)
-  $ permute const res (\ix -> crypt A.! ix `cmp` the passwd ? (constant (Z:.0), ignore))
+  = permute const res (\ix -> crypt A.! ix `cmp` the passwd ? (Just_ Z_, Nothing_))
                       (enumFromN (index1 n) 0)
   where
     n           = A.size crypt
-    res         = use $ fromList (Z:.1) [-1]    :: Acc (Vector Int)
+    res         = fill Z_ (-1)
     crypt       = md5 dict
 
     cmp x y     = let (x1,x2,x3,x4) = unlift x
diff --git a/examples/hashcat/Main.hs b/examples/hashcat/Main.hs
--- a/examples/hashcat/Main.hs
+++ b/examples/hashcat/Main.hs
@@ -23,9 +23,9 @@
 -- ugly hack because the .cabal file is not able to specify a build
 -- dependency based on the version of a different build dependency?
 #if MIN_VERSION_criterion(1,5,0)
-import "criterion-measurement" Criterion.Measurement
+import Criterion.Measurement
 #else
-import "criterion"             Criterion.Measurement
+import "criterion" Criterion.Measurement
 #endif
 
 import Prelude                                          as P
diff --git a/examples/julia/Config.hs b/examples/julia/Config.hs
new file mode 100644
--- /dev/null
+++ b/examples/julia/Config.hs
@@ -0,0 +1,55 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Config where
+
+import Data.Label
+import System.Console.GetOpt
+
+
+data Config = Config
+  {
+    _configWidth  :: Int
+  , _configHeight :: Int
+  }
+  deriving Show
+
+$(mkLabels [''Config])
+
+defaults :: Config
+defaults = Config
+  { _configWidth    = 800
+  , _configHeight   = 600
+  }
+
+options :: [OptDescr (Config -> Config)]
+options =
+  [ Option []   ["width"]       (ReqArg (set configWidth  . read) "INT")         "visualisation width  (800)"
+  , Option []   ["height"]      (ReqArg (set configHeight . read) "INT")         "visualisation height (600)"
+  ]
+
+header :: [String]
+header =
+  [ "accelerate-julia (c) [2019] The Accelerate Team"
+  , ""
+  , "Usage: accelerate-julia [OPTIONS]"
+  , ""
+  ]
+
+footer :: [String]
+footer =
+  [ ""
+  , "Runtime usage:"
+  , "     ESC           quit"
+  , "     mouse drag    translate display"
+  , "     w/s           zoom in/out"
+  , "     a/d           iteration count"
+  , "     z/c           escape radius"
+  , "     q/e           speed up/slow down"
+  , "     left/right    forward/backwards in time"
+  , "     0 .. 9        select presets"
+  , "     r             reset"
+  , "     .             print current configuration"
+  , "     space         pause/resume"
+  , ""
+  ]
+
diff --git a/examples/julia/Julia.hs b/examples/julia/Julia.hs
new file mode 100644
--- /dev/null
+++ b/examples/julia/Julia.hs
@@ -0,0 +1,60 @@
+{-# LANGUAGE FlexibleContexts    #-}
+{-# LANGUAGE RebindableSyntax    #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeOperators       #-}
+{-# LANGUAGE ViewPatterns        #-}
+
+module Julia where
+
+import Data.Array.Accelerate                              hiding ( fromInteger )
+import Data.Array.Accelerate.Data.Complex
+
+import Prelude                                            ( fromInteger )
+import qualified Prelude                                  as P
+
+
+julia
+    :: forall a. (Num a, RealFloat a, FromIntegral Int a)
+    => Int                                                -- ^ image width
+    -> Int                                                -- ^ image height
+    -> (Exp Float -> Exp (Complex a) -> Exp (Complex a))  -- ^ iteration function
+    -> Acc (Scalar Float)                                 -- ^ current time
+    -> Acc (Scalar a)                                     -- ^ centre x
+    -> Acc (Scalar a)                                     -- ^ centre y
+    -> Acc (Scalar a)                                     -- ^ view width
+    -> Acc (Scalar Int32)                                 -- ^ iteration limit
+    -> Acc (Scalar a)                                     -- ^ divergence radius
+    -> Acc (Array DIM2 (Complex a, Int32))
+julia screenX screenY next (the -> t) (the -> x0) (the -> y0) (the -> width) (the -> limit) (the -> radius) =
+  generate
+    (constant (Z :. screenY :. screenX))
+    (\ix -> let z0 = complexOfPixel ix
+                zn = while (\zi -> snd zi       < limit
+                                && dot (fst zi) < radius)
+                           step
+                           (T2 z0 0)
+             in zn)
+
+  where
+    complexOfPixel :: Exp DIM2 -> Exp (Complex a)
+    complexOfPixel (unlift -> Z :. y :. x) =
+      let
+          height = P.fromIntegral screenY / P.fromIntegral screenX * width
+          xmin   = x0 - width  / 2
+          ymin   = y0 - height / 2
+          --
+          re     = xmin + (fromIntegral x * width)  / fromIntegral (constant screenX)
+          im     = ymin + (fromIntegral y * height) / fromIntegral (constant screenY)
+      in
+      lift (re :+ im)
+
+    -- Divergence condition
+    --
+    dot :: Exp (Complex a) -> Exp a
+    dot (unlift -> x :+ y) = x*x + y*y
+
+    -- Take a single step of the recurrence relation
+    --
+    step :: Exp (Complex a, Int32) -> Exp (Complex a, Int32)
+    step (T2 z i) = T2 (next t z) (i + 1)
+
diff --git a/examples/julia/Main.hs b/examples/julia/Main.hs
new file mode 100644
--- /dev/null
+++ b/examples/julia/Main.hs
@@ -0,0 +1,37 @@
+{-# LANGUAGE RecordWildCards #-}
+-- A Julia set animation
+-- Originally written by Roger Bosman
+--
+
+import World
+import Config
+
+import Data.Label
+
+import Prelude                                                      as P
+import Data.Array.Accelerate.Examples.Internal                      as A
+import qualified Graphics.Gloss.Interface.IO.Game                   as G
+
+-- Main ------------------------------------------------------------------------
+
+main :: IO ()
+main = do
+  beginMonitoring
+  (conf, opts, rest) <- parseArgs options defaults header footer
+
+  let world   = initialWorld conf opts
+      width   = get configWidth conf
+      height  = get configHeight conf
+
+  runBenchmarks opts rest
+    [ bench "julia" $ whnf renderWorld world ]
+
+  runInteractive opts rest $
+    G.playIO (G.InWindow "Julia" (width,height) (10,10))
+             G.black
+             60
+             world
+             draw
+             (react conf opts)
+             advance
+
diff --git a/examples/julia/Palette.hs b/examples/julia/Palette.hs
new file mode 100644
--- /dev/null
+++ b/examples/julia/Palette.hs
@@ -0,0 +1,100 @@
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE RebindableSyntax #-}
+{-# LANGUAGE ViewPatterns     #-}
+
+module Palette where
+
+import Data.Array.Accelerate                              hiding ( fromInteger )
+import Data.Array.Accelerate.Data.Complex
+import Data.Array.Accelerate.Data.Colour.RGB
+import Data.Array.Accelerate.Data.Colour.Names
+
+import Prelude                                            ( fromInteger )
+import qualified Prelude                                  as P
+
+
+-- Convert the iteration count on escape to a colour.
+--
+-- Uses the method described here:
+-- <http://stackoverflow.com/questions/16500656/which-color-gradient-is-used-to-color-mandelbrot-in-wikipedia>
+--
+escapeToRGBA
+    :: (RealFloat a, ToFloating Int32 a)
+    => Acc (Scalar Int32)
+    -> Acc (Vector Word32)
+    -> Exp (Complex a, Int32)
+    -> Exp Word32
+escapeToRGBA (the -> limit) palette (unlift -> (z, n)) =
+  if n == limit
+    then packRGB black
+    else palette ! index1 ix
+      where
+        mag     = magnitude z
+        smooth  = logBase 2 (logBase 2 mag)
+        ix      = truncate (sqrt (toFloating n + 1 - smooth) * scale + shift) `mod` length palette
+        --
+        scale   = 256
+        shift   = 1664
+
+ultraPalette
+    :: Int
+    -> Acc (Vector Word32)
+ultraPalette points
+  = generate (constant (Z :. points))
+             (\ix -> packRGB (ultra (toFloating (unindex1 ix) / P.fromIntegral points)))
+
+
+-- Pick a nice colour, given a number in the range [0,1].
+--
+ultra :: Exp Float -> Exp Colour
+ultra p =
+  if p <= p1 then interp (p0,p1) (c0,c1) (m0,m1) p else
+  if p <= p2 then interp (p1,p2) (c1,c2) (m1,m2) p else
+  if p <= p3 then interp (p2,p3) (c2,c3) (m2,m3) p else
+  if p <= p4 then interp (p3,p4) (c3,c4) (m3,m4) p else
+                  interp (p4,p5) (c4,c5) (m4,m5) p
+  where
+    p0 = 0.0     ; c0 = rgb8 0   7   100  ; m0 = (0.7843138, 2.4509804,  2.52451)
+    p1 = 0.16    ; c1 = rgb8 32  107 203  ; m1 = (1.93816,   2.341629,   1.6544118)
+    p2 = 0.42    ; c2 = rgb8 237 255 255  ; m2 = (1.7046283, 0.0,        0.0)
+    p3 = 0.6425  ; c3 = rgb8 255 170 0    ; m3 = (0.0,       -2.2812111, 0.0)
+    p4 = 0.8575  ; c4 = rgb8 0   2   0    ; m4 = (0.0,       0.0,        0.0)
+    p5 = 1.0     ; c5 = c0                ; m5 = m0
+
+    -- interpolate each of the RGB components
+    interp (x0,x1) (y0,y1) ((mr0,mg0,mb0),(mr1,mg1,mb1)) x =
+      let
+          RGB r0 g0 b0 = unlift y0 :: RGB (Exp Float)
+          RGB r1 g1 b1 = unlift y1 :: RGB (Exp Float)
+      in
+      rgb (cubic (x0,x1) (r0,r1) (mr0,mr1) x)
+          (cubic (x0,x1) (g0,g1) (mg0,mg1) x)
+          (cubic (x0,x1) (b0,b1) (mb0,mb1) x)
+
+-- cubic interpolation
+cubic :: (Exp Float, Exp Float)
+      -> (Exp Float, Exp Float)
+      -> (Exp Float, Exp Float)
+      -> Exp Float
+      -> Exp Float
+cubic (x0,x1) (y0,y1) (m0,m1) x =
+  let
+      -- basis functions for cubic hermite spine
+      h_00 = (1 + 2*t) * (1 - t) ** 2
+      h_10 = t * (1 - t) ** 2
+      h_01 = t ** 2 * (3 - 2 * t)
+      h_11 = t ** 2 * (t - 1)
+      --
+      h    = x1 - x0
+      t    = (x - x0) / h
+  in
+  y0 * h_00 + h * m0 * h_10 + y1 * h_01 + h * m1 * h_11
+
+-- linear interpolation
+linear :: (Exp Float, Exp Float)
+       -> (Exp Float, Exp Float)
+       -> Exp Float
+       -> Exp Float
+linear (x0,x1) (y0,y1) x =
+  y0 + (x - x0) * (y1 - y0) / (x1 - x0)
+
diff --git a/examples/julia/World.hs b/examples/julia/World.hs
new file mode 100644
--- /dev/null
+++ b/examples/julia/World.hs
@@ -0,0 +1,237 @@
+{-# LANGUAGE BangPatterns     #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE PatternGuards    #-}
+{-# LANGUAGE RecordWildCards  #-}
+{-# LANGUAGE TypeOperators    #-}
+
+module World where
+
+import Config
+import Julia
+import Palette
+
+import Graphics.Gloss.Accelerate.Data.Picture                       as G
+import Graphics.Gloss.Interface.Pure.Game                           hiding ( Vector, translate, scale )
+
+import Data.Array.Accelerate                                        ( Array, Scalar, Vector, Exp, DIM2, Elt, Z(..), (:.)(..) )
+import Data.Array.Accelerate.Data.Complex
+import Data.Array.Accelerate.Examples.Internal                      as A
+import qualified Data.Array.Accelerate                              as A
+
+import Data.Char
+import Data.Int
+import Data.Label
+import Data.Word
+import System.Exit
+import Text.Printf
+import Prelude                                                      as P
+
+
+-- World state
+-- -----------
+
+type R = Double
+
+data World = World
+  { worldPicture      :: !Picture
+  , worldAnimating    :: !Bool
+  , worldDirty        :: !Bool
+  , worldRender       :: !(Scalar Float -> Scalar R -> Scalar R -> Scalar R -> Scalar Int32 -> Scalar R -> Array DIM2 Word32)
+  , worldPalette      :: !(Vector Word32)
+  , worldSizeX        :: !Int
+  , worldSizeY        :: !Int
+  , worldTime         :: !(Scalar Float)
+  , worldSpeed        :: !(Scalar Float)
+  , worldPosX         :: !(Scalar R)
+  , worldPosY         :: !(Scalar R)
+  , worldWidth        :: !(Scalar R)
+  , worldRadius       :: !(Scalar R)
+  , worldIters        :: !(Scalar Int32)
+  , worldPanning      :: !(Maybe (Float, Float))
+  , worldZooming      :: !(Maybe Double)
+  }
+
+initialWorld :: Config -> Options -> World
+initialWorld conf opts
+  = loadPreset opts 0
+  $ World
+      { worldDirty        = True
+      , worldAnimating    = True
+      , worldPicture      = blank
+      , worldRender       = \_ _ _ _ _ _ -> A.fromList (Z:.0:.0) []
+      , worldPalette      = run (get optBackend opts) (ultraPalette 2048)
+      , worldSizeX        = get configWidth conf
+      , worldSizeY        = get configHeight conf
+      , worldPanning      = Nothing
+      , worldZooming      = Nothing
+      , worldTime         = unit' 0
+      , worldSpeed        = unit' 1
+      , worldPosX         = unit' 0
+      , worldPosY         = unit' 0
+      , worldWidth        = unit' 0
+      , worldRadius       = unit' 0
+      , worldIters        = unit' 0
+      }
+
+
+-- Draw the world
+--
+draw :: World -> IO Picture
+draw = return . worldPicture
+
+-- React to events
+--
+react :: Config -> Options -> Event -> World -> IO World
+react conf opts event world@World{..} =
+  case event of
+    -- zooming
+    EventKey (Char 'w') s _ _               -> toggle zooming 0.975 s world
+    EventKey (Char 's') s _ _               -> toggle zooming 1.025 s world
+
+    -- panning
+    EventKey (MouseButton LeftButton) s _ p -> toggle panning p s world
+    EventMotion (x,y)
+      | Just (x0,y0) <- worldPanning
+      -> let dx = (x0-x) * P.realToFrac (the' worldWidth) / P.fromIntegral worldSizeX
+             dy = (y0-y) * P.realToFrac (the' worldWidth) / P.fromIntegral worldSizeX
+         in
+         return . dirty
+                $ world { worldPosX    = unit' (the' worldPosX + P.realToFrac dx)
+                        , worldPosY    = unit' (the' worldPosY - P.realToFrac dy)
+                        , worldPanning = Just (x,y)
+                        }
+
+    -- algorithm
+    EventKey (Char 'a') Down _ _ -> return . dirty
+      $ world { worldIters = unit' (P.truncate (P.fromIntegral (the' worldIters) * 0.8 :: Double)) }
+    EventKey (Char 'd') Down _ _ -> return . dirty
+      $ world { worldIters = unit' (P.truncate (P.fromIntegral (the' worldIters) * 1.2 :: Double)) }
+
+    EventKey (Char 'z') Down _ _ -> return . dirty
+      $ world { worldRadius = unit' (the' worldRadius * 0.5) }
+    EventKey (Char 'c') Down _ _ -> return . dirty
+      $ world { worldRadius = unit' (the' worldRadius * 2.0) }
+
+    EventKey (Char 'q') Down _ _ -> return . dirty
+      $ world { worldSpeed = unit' (the' worldSpeed * 0.75) }
+    EventKey (Char 'e') Down _ _ -> return . dirty
+      $ world { worldSpeed = unit' (the' worldSpeed * 1.25) }
+
+    -- animation
+    EventKey (SpecialKey KeyLeft) Down _ _  -> return . dirty
+      $ world { worldTime = unit' (the' worldTime - 1/60 * the' worldSpeed) }
+    EventKey (SpecialKey KeyRight) Down _ _ -> return . dirty
+      $ world { worldTime = unit' (the' worldTime + 1/60 * the' worldSpeed) }
+
+    -- presets
+    EventKey (Char d) Down _ _ | isDigit d  -> return . dirty $ loadPreset opts (read [d]) world
+
+    -- misc
+    EventKey (Char '.') Down _ _            -> putStrLn (showWorld world) >> return world
+    EventKey (Char 'r') Down _ _            -> return $ (initialWorld conf opts) { worldAnimating = worldAnimating }
+    EventKey (SpecialKey KeySpace) Down _ _ -> return $ world { worldAnimating = not worldAnimating }
+    EventKey (SpecialKey KeyEsc) Down _ _   -> exitSuccess
+
+    _                                       -> return world
+  where
+    toggle f x Down = return . dirty . set f (Just x)
+    toggle f _ Up   = return         . set f Nothing
+
+    dirty w = w { worldDirty = True }
+
+
+-- Move and zoom the display based on key state
+--
+advance :: Float -> World -> IO World
+advance dt = return . updateWorld . animate . zoom
+  where
+    animate world@World{..}
+      | worldAnimating          = world { worldDirty = True, worldTime = unit' (dt * the' worldSpeed + the' worldTime) }
+      | otherwise               = world
+    --
+    zoom world@World{..}
+      | Just f <- worldZooming  = world { worldDirty = True, worldWidth = unit' (P.realToFrac f * the' worldWidth)  }
+      | otherwise               = world
+
+-- Update the picture
+--
+updateWorld :: World -> World
+updateWorld world@World{..} =
+  if worldDirty
+    then world { worldDirty   = False
+               , worldPicture = bitmapOfArray (renderWorld world) (not worldAnimating)
+               }
+    else world
+
+renderWorld :: World -> Array DIM2 Word32
+renderWorld World{..} =
+  let !r = worldRender worldTime worldPosX worldPosY worldWidth worldIters worldRadius
+   in r
+
+
+-- Miscellaneous
+-- -------------
+
+zooming :: World :-> Maybe Double
+zooming = lens worldZooming (\f World{..} -> World { worldZooming = f worldZooming, .. })
+
+panning :: World :-> Maybe (Float,Float)
+panning = lens worldPanning (\f World{..} -> World { worldPanning = f worldPanning, .. })
+
+unit' :: Elt a => a -> Scalar a
+unit' a = A.fromList Z [a]
+
+the' :: Elt a => Scalar a -> a
+the' a = a `A.indexArray` Z
+
+
+-- Presets
+-- -------
+
+showWorld :: World -> String
+showWorld World{..} =
+  printf "centre: (%f, %f), width: %f, iterations: %d, radius: %f"
+    (the' worldPosX)
+    (the' worldPosY)
+    (the' worldWidth)
+    (the' worldIters)
+    (the' worldRadius)
+
+loadPreset :: Options -> Int -> World -> World
+loadPreset opts n world@World{..} =
+  let
+      (f, posX, posY, width, iters, radius)
+        = presets !! n
+
+      render t x y w l r
+        = A.map (escapeToRGBA l (A.use worldPalette))
+        $ julia worldSizeX worldSizeY (\a b -> f (A.toFloating a) b) t x y w l r
+  in
+  world
+    { worldRender = runN (get optBackend opts) render
+    , worldPosX   = unit' posX
+    , worldPosY   = unit' posY
+    , worldWidth  = unit' width
+    , worldIters  = unit' iters
+    , worldRadius = unit' radius
+    }
+
+golden :: Floating a => a
+golden = (1 + sqrt 5) / 2
+
+presets
+    :: (Fractional a, A.RealFloat a)
+    => [ (Exp a -> Exp (Complex a) -> Exp (Complex a), a, a, a, Int32, a) ]
+presets =
+  [ (\t z -> z ^ (2::Int) + mkPolar 0.7885 t,                                   0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift ((1 - golden) * cos t :+ A.constant 0),      0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift ((golden-2) * cos t :+ (golden-1) * sin t),  0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift (0.285 * cos t :+ 0.1 * sin t),              0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift (0.45 * cos t :+ 0.1428 * sin t),            0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift ((-0.70176) * cos t :+ (-0.3842) * sin t),   0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift ((-0.835) * cos t :+ (-0.2321) * sin t),     0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift ((-0.8) * cos t :+ 0.156 * sin t),           0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift ((-0.7269) * cos t :+ 0.1889 * sin t),       0, 0, 4, 255, 16.0)
+  , (\t z -> z ^ (2::Int) + A.lift (0 :+ (-0.8) * sin t),                       0, 0, 4, 255, 16.0)
+  ]
+
diff --git a/examples/kmeans/Config.hs b/examples/kmeans/Config.hs
--- a/examples/kmeans/Config.hs
+++ b/examples/kmeans/Config.hs
@@ -27,7 +27,7 @@
 --
 header :: [String]
 header =
-  [ "accelerate-kmeans (c) [2014] The Accelerate Team"
+  [ "accelerate-kmeans (c) [2014..2020] The Accelerate Team"
   , ""
   , "Usage: accelerate-kmeans [OPTIONS]"
   , ""
diff --git a/examples/kmeans/Kmeans.hs b/examples/kmeans/Kmeans.hs
--- a/examples/kmeans/Kmeans.hs
+++ b/examples/kmeans/Kmeans.hs
@@ -4,10 +4,10 @@
 {-# LANGUAGE TypeOperators       #-}
 -- |
 -- Module      : Data.Array.Accelerate.Math.Kmeans
--- Copyright   : [2014] Trevor L. McDonell
+-- Copyright   : [2014..2020] Trevor L. McDonell
 -- License     : BSD3
 --
--- Maintainer  : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer  : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability   : experimental
 -- Portability : non-portable (GHC extensions)
 --
diff --git a/examples/mandelbrot/Mandel.hs b/examples/mandelbrot/Mandel.hs
--- a/examples/mandelbrot/Mandel.hs
+++ b/examples/mandelbrot/Mandel.hs
@@ -17,7 +17,7 @@
 
 
 mandelbrot
-    :: forall a. (Num a, RealFloat a, FromIntegral Int a, Elt (Complex a))
+    :: forall a. (Num a, RealFloat a, FromIntegral Int a)
     => Int                                  -- ^ image width
     -> Int                                  -- ^ image height
     -> Acc (Scalar a)                       -- ^ centre x
@@ -71,7 +71,7 @@
 -- <http://stackoverflow.com/questions/16500656/which-color-gradient-is-used-to-color-mandelbrot-in-wikipedia>
 --
 escapeToColour
-    :: (RealFloat a, ToFloating Int32 a, Elt (Complex a))
+    :: (RealFloat a, ToFloating Int32 a)
     => Acc (Scalar Int32)
     -> Exp (Complex a, Int32)
     -> Exp Colour
@@ -89,7 +89,7 @@
         points  = 2048 :: Exp Int
 
 escapeToRGBA
-    :: (RealFloat a, ToFloating Int32 a, Elt (Complex a))
+    :: (RealFloat a, ToFloating Int32 a)
     => Acc (Scalar Int32)
     -> Acc (Vector Word32)
     -> Exp (Complex a, Int32)
diff --git a/examples/mandelbrot/World.hs b/examples/mandelbrot/World.hs
--- a/examples/mandelbrot/World.hs
+++ b/examples/mandelbrot/World.hs
@@ -27,7 +27,6 @@
 import Prelude                                                      as P
 
 import Data.Array.Accelerate                                        ( Arrays, Array, Scalar, Vector, DIM2, Elt, Acc, Z(..), (:.)(..) )
-import Data.Array.Accelerate.Data.Complex
 import Data.Array.Accelerate.Examples.Internal                      as A
 import qualified Data.Array.Accelerate                              as A
 
@@ -38,7 +37,7 @@
 data Precision  = Float | Double
 
 data World where
-  World :: (P.RealFloat a, A.RealFloat a, A.Elt (Complex a)) =>
+  World :: (P.Show a, P.RealFloat a, A.RealFloat a) =>
     { worldPicture      :: !Picture
     , worldDirty        :: Bool
     , worldPrecision    :: Precision
@@ -79,7 +78,7 @@
 setPrecision :: Options -> Precision -> World -> World
 setPrecision opts prec World{..} =
   let
-      mandel :: (A.RealFloat a, A.FromIntegral Int a, A.ToFloating Int32 a, A.Elt (Complex a))
+      mandel :: (A.RealFloat a, A.FromIntegral Int a, A.ToFloating Int32 a)
              => Acc (Scalar a) -> Acc (Scalar a) -> Acc (Scalar a) -> Acc (Scalar Int32) -> Acc (Scalar a) -> Acc (Array DIM2 Word32)
       mandel x y w l r = A.map (escapeToRGBA l (A.use worldPalette)) $ mandelbrot worldSizeX worldSizeY x y w l r
 
@@ -136,8 +135,8 @@
              dy = (y0-y) * P.realToFrac (the worldWidth) / P.fromIntegral worldSizeX
          in
          return . dirty
-                $ World { worldPosX    = unit (P.realToFrac dx + the worldPosX)
-                        , worldPosY    = unit (P.realToFrac dy + the worldPosY)
+                $ World { worldPosX    = unit (the worldPosX + P.realToFrac dx)
+                        , worldPosY    = unit (the worldPosY - P.realToFrac dy)
                         , worldPanning = Just (x,y)
                         , ..
                         }
diff --git a/examples/n-body/Common/Body.hs b/examples/n-body/Common/Body.hs
--- a/examples/n-body/Common/Body.hs
+++ b/examples/n-body/Common/Body.hs
@@ -21,7 +21,7 @@
 
 import Common.Type
 
-import Data.Array.Accelerate                                        as A
+import Data.Array.Accelerate                                        as A hiding ( V3 )
 import Data.Array.Accelerate.Linear.Metric
 import Data.Array.Accelerate.Linear.Vector
 import Data.Array.Accelerate.Control.Lens
diff --git a/examples/n-body/Common/World.hs b/examples/n-body/Common/World.hs
--- a/examples/n-body/Common/World.hs
+++ b/examples/n-body/Common/World.hs
@@ -35,9 +35,7 @@
                         $ A.map pointMassOfBody bodies
 
         -- Apply the accelerations to the bodies and advance them
-        advance b a     = let m         = massOfPointMass (pointMassOfBody b)
-                              a'        = m *^ a
-                          in advanceBody (the timeStep) (setAccelOfBody a' b)
+        advance b a     = advanceBody (the timeStep) (setAccelOfBody a b)
     in
     A.zipWith advance bodies accels
 
diff --git a/examples/n-body/Config.hs b/examples/n-body/Config.hs
--- a/examples/n-body/Config.hs
+++ b/examples/n-body/Config.hs
@@ -56,7 +56,7 @@
   , _configRate                 = 30
 
   , _configBodyCount            = 1000
-  , _configBodyMass             = 40
+  , _configBodyMass             = 1600
   , _configTimeStep             = 1
   , _configEpsilon              = 50
 
diff --git a/examples/n-body/Main.hs b/examples/n-body/Main.hs
--- a/examples/n-body/Main.hs
+++ b/examples/n-body/Main.hs
@@ -16,6 +16,7 @@
 import qualified Solver.BarnsHut                        as BarnsHut
 
 import Data.Array.Accelerate                            as A hiding ( size )
+import Data.Array.Accelerate.System.Random.MWC          as A
 import Data.Array.Accelerate.Examples.Internal          as A
 
 -- system
@@ -42,14 +43,14 @@
             radius      = get configStartDiscSize conf
             backend     = get optBackend opts
 
-            -- Generate random particle positions in a disc layout centred at
-            -- the origin. Start the system rotating with particle speed
-            -- proportional to distance from the origin
-            --
-            positions   = randomArray (cloud (size,size) radius) (Z :. n)
-            masses      = randomArray (uniformR (1, mass)) (Z :. n)
+        -- Generate random particle positions in a disc layout centred at
+        -- the origin. Start the system rotating with particle speed
+        -- proportional to distance from the origin
+        --
+        positions      <- randomArray (cloud (size,size) radius) (Z :. n)
+        masses         <- randomArray (uniformR (1, mass)) (Z :. n)
 
-            bodies      = run backend
+        let bodies      = run backend
                         $ A.map (setStartVelOfBody . constant $ get configStartSpeed conf)
                         $ A.zipWith setMassOfBody (A.use masses)
                         $ A.map unitBody (A.use positions)
diff --git a/examples/n-body/Random/Position.hs b/examples/n-body/Random/Position.hs
--- a/examples/n-body/Random/Position.hs
+++ b/examples/n-body/Random/Position.hs
@@ -10,8 +10,8 @@
 import Common.Type
 
 import System.Random.MWC                                ( uniformR )
-import Data.Array.Accelerate.Examples.Internal          ( (:~>) )
-import Data.Array.Accelerate.Array.Sugar                as A
+import Data.Array.Accelerate.System.Random.MWC          ( (:~>) )
+import Data.Array.Accelerate.Sugar.Shape
 
 
 -- | Points distributed as a disc
@@ -36,7 +36,7 @@
           = disc (V3 (sx * sizeX) (sy * sizeY) (sz * (sizeX `min` sizeY)))
                  (radiusMax * r)
 
-    in case A.size ix `mod` 5 of
+    in case size ix `mod` 5 of
         0 -> blob ( 0.25, 0.25, 0.25) 1.00 ix gen
         1 -> blob (-0.10, 0.10, 0.10) 0.60 ix gen
         2 -> blob (-0.05, 0.30,-0.30) 0.35 ix gen
diff --git a/examples/n-body/Test.hs b/examples/n-body/Test.hs
--- a/examples/n-body/Test.hs
+++ b/examples/n-body/Test.hs
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
 
 module Test (makeTests)
   where
@@ -5,9 +6,10 @@
 import Common.Type
 
 import Prelude                                          as P
-import Data.Array.Accelerate                            as A
+import Data.Array.Accelerate                            as A hiding ( V3 )
 import Data.Array.Accelerate.Examples.Internal
 
+
 -- Generate the tests
 --
 makeTests :: (Scalar Time -> Vector Body -> Vector Body) -> [Test]
@@ -29,6 +31,12 @@
     t50'        = advance t40'
 
 
+instance Similar a => Similar (V3 a) where
+  V3 x1 y1 z1 ~= V3 x2 y2 z2 =
+    x1 ~= x2 P.&&
+    y1 ~= y2 P.&&
+    z1 ~= z2
+
 -- Input data
 --
 bodies :: Vector Body
@@ -40,10 +48,10 @@
 -- Take a number of steps in 0.1 second increments
 --
 t0, t10, t20, t30, t40, t50 :: Vector Body
-t0  = fromList (Z :. 32) [((V3 49.934765 48.864784 49.504097,3.456227),V3 10.561408 (-10.792668) 10.699586,V3 (-0.2020692) (-0.18428235) (-0.13120669)),((V3 (-19.72055) 21.0447 21.976465,63.459526),V3 6.989762 6.5499606 7.2992377,V3 3.0261776 (-0.7999116) (-1.3126944)),((V3 (-8.485103) 70.43111 (-66.07767),74.34554),V3 14.306272 1.7235309 (-13.421982),V3 (-0.1371406) (-3.710925) 3.796874),((V3 (-40.529545) (-23.411388) (-23.874193),8.434827),V3 (-6.4595428) 11.182692 (-6.5872374),V3 0.42419815 0.5393226 0.31401542),((V3 36.915504 (-13.378705) 22.885813,16.776989),V3 (-3.9690585) (-10.951718) 6.7895308,V3 (-0.9118709) 0.8006712 0.2444),((V3 58.12199 47.11681 49.27831,21.63172),V3 9.955754 (-12.281143) 10.4124775,V3 (-1.5379857) (-0.9758822) (-0.7344652)),((V3 (-18.56515) 19.121122 19.856537,69.831604),V3 6.6335444 6.440665 6.8886757,V3 2.988307 (-0.41186926) (-0.9475892)),((V3 (-16.319696) 68.65275 (-70.91549),66.98223),V3 13.727621 3.263243 (-14.180073),V3 1.625271 (-2.7936146) 4.267117),((V3 (-35.320797) (-9.581309) (-15.5530615),23.477612),V3 (-3.0388143) 11.202367 (-4.932819),V3 1.208595 1.1207385 0.7841558),((V3 35.467846 (-31.458008) 57.63878,4.5274367),V3 (-7.2828484) (-8.211167) 13.343963,V3 (-0.12642522) 0.3105037 (-0.2921983)),((V3 22.741138 16.762173 47.443493,45.534313),V3 4.5114946 (-6.1207175) 12.769291,V3 (-1.232773) 2.6571987e-2 (-2.692973)),((V3 (-19.066488) 32.53443 19.284454,37.293446),V3 9.998227 5.859364 5.926348,V3 1.6313204 (-1.8151838) (-0.52129644)),((V3 (-4.6187997) 54.83043 (-69.1615),52.771004),V3 11.664729 0.9826122 (-14.713549),V3 (-0.81280035) (-0.112044565) 3.5451076),((V3 (-37.741123) (-23.498236) (-29.302645),83.92678),V3 (-6.4404936) 10.344243 (-8.03139),V3 3.5243607 5.315734 3.9011729),((V3 36.013374 (-17.063395) 32.41684,13.032608),V3 (-4.7614217) (-10.049282) 9.045693,V3 (-0.61353976) 0.70832497 (-0.11806177)),((V3 49.562435 83.03267 83.920395,18.12446),V3 14.676114 (-8.760214) 14.83302,V3 (-0.4695076) (-1.0319139) (-1.0167954)),((V3 (-9.462863) 25.536043 36.41799,53.132633),V3 7.573575 2.8065314 10.800983,V3 1.3853245 (-1.4187478) (-3.0760522)),((V3 (-10.790539) 66.63314 (-67.998985),94.62536),V3 13.614646 2.204749 (-13.893719),V3 0.56374645 (-3.55292) 5.51218),((V3 (-40.558056) (-29.971233) (-24.474981),6.5728045),V3 (-8.00616) 10.834197 (-6.5379558),V3 0.30523086 0.47446692 0.23335022),((V3 29.8883 (-20.165321) 45.04451,53.180336),V3 (-5.309554) (-7.869626) 11.860275,V3 (-1.4631323) 3.3048942 (-2.3880641)),((V3 32.482105 30.910307 49.05143,91.3407),V3 7.583363 (-7.9689794) 12.034005,V3 (-3.6304643) (-2.5821278) (-4.8232713)),((V3 (-20.018032) 19.918154 27.472118,87.52959),V3 6.346644 6.378469 8.753611,V3 4.4817963 (-0.7540304) (-3.3089616)),((V3 (-12.006343) 50.781525 (-48.374542),75.542244),V3 12.0401945 2.8466792 (-11.469504),V3 0.74818593 (-0.64892244) 1.946604),((V3 (-36.06932) (-13.634953) (-28.24347),35.689384),V3 (-3.9444003) 10.434348 (-8.17044),V3 1.5595063 1.77316 1.7561425),((V3 36.564384 (-22.889074) 41.142605,77.35545),V3 (-5.9291406) (-9.471566) 10.6575,V3 (-3.1575167) 4.8282127 (-2.4603796)),((V3 72.98635 36.489113 44.127728,34.4798),V3 7.5769863 (-15.15566) 9.163149,V3 (-3.1058714) (-0.73178864) (-0.6773815)),((V3 (-6.637457) 11.754714 14.4537,20.805649),V3 5.286392 2.9850323 6.5001945,V3 6.1454386e-2 0.3914103 0.19268043),((V3 (-5.4672456) 71.23518 (-59.5781),58.3743),V3 14.7713995 1.1336936 (-12.354176),V3 (-0.6793159) (-3.241285) 1.9731628),((V3 (-43.633926) (-22.012821) (-7.0467205),20.659788),V3 (-6.265288) 12.4190855 (-2.0056372),V3 1.3458371 1.3664191 0.22117926),((V3 54.48485 (-44.066643) 29.847332,82.26547),V3 (-10.098527) (-12.486015) 6.8399606,V3 (-4.644851) 6.0297318 (-0.19813985)),((V3 50.216465 50.00622 49.413647,86.262726),V3 10.759963 (-10.805201) 10.632457,V3 (-5.0198126) (-4.7489667) (-3.2173421)),((V3 (-24.18221) 1.1176014 18.39111,52.37195),V3 0.40538555 8.771569 6.670974,V3 2.865766 2.5242555 (-0.771268))]
-t10 = fromList (Z :. 32) [((V3 60.402256 37.99447 60.14521,3.456227),V3 10.347675 (-10.957504) 10.569622,V3 (-0.22668193) (-0.14637746) (-0.13127826)),((V3 (-11.430504) 27.125307 28.753597,63.459526),V3 9.780841 5.350463 6.240201,V3 2.5433345 (-1.5698189) (-0.8167556)),((V3 5.672099 70.57071 (-77.842896),74.34554),V3 13.856287 (-1.666952) (-9.809946),V3 (-0.7218549) (-3.07428) 3.454369),((V3 (-46.79211) (-12.007825) (-30.323624),8.434827),V3 (-6.012946) 11.642888 (-6.2869954),V3 0.46778414 0.38886592 0.2849534),((V3 32.574455 (-23.946268) 29.79417,16.776989),V3 (-4.7382054) (-10.062807) 7.0655513,V3 (-0.6296934) 0.97357625 0.30322555),((V3 67.3728 34.43472 59.36437,21.63172),V3 8.367946 (-13.115515) 9.689009,V3 (-1.6421701) (-0.6976927) (-0.72507)),((V3 (-10.644274) 25.257013 26.39887,69.831604),V3 9.401735 5.590103 6.2358103,V3 2.5346236 (-1.2643027) (-0.3754633)),((V3 (-1.9366095) 70.68937 (-83.21151),66.98223),V3 15.068537 0.5764816 (-10.042387),V3 1.0556761 (-2.6000845) 4.0255356),((V3 (-37.81175) 2.0563722 (-20.14278),23.477612),V3 (-1.817153) 12.071388 (-4.190213),V3 1.2293873 0.63759214 0.687956),((V3 28.138607 (-39.52876) 70.849945,4.5274367),V3 (-7.370752) (-7.898251) 13.046776,V3 (-5.1867843e-2) 0.31481925 (-0.30228883)),((V3 26.732052 10.697684 58.990242,45.534313),V3 3.4046803 (-5.9327974) 10.0338125,V3 (-0.98696345) 0.33534586 (-2.785121)),((V3 (-8.415286) 37.529408 25.032337,37.293446),V3 11.330664 3.876094 5.60827,V3 1.0490761 (-2.1232) (-0.13574754)),((V3 6.675616 55.826862 (-82.31381),52.771004),V3 10.847925 1.0917499 (-11.286869),V3 (-0.7843886) 0.27396658 3.3349295),((V3 (-42.53744) (-10.963094) (-35.619644),83.92678),V3 (-2.7064044) 14.917309 (-4.294997),V3 3.9198356 3.8610702 3.5435603),((V3 31.007177 (-26.778881) 41.412075,13.032608),V3 (-5.2589273) (-9.285036) 8.936092,V3 (-0.38566536) 0.8186842 (-0.10571819)),((V3 64.01576 73.82858 98.300285,18.12446),V3 14.1636095 (-9.714817) 13.833233,V3 (-0.55458456) (-0.8758056) (-0.98143333)),((V3 (-1.29756) 27.675724 45.853508,53.132633),V3 8.84061 1.2858781 7.796603,V3 1.1496811 (-1.6105593) (-2.9288754)),((V3 2.984476 67.32786 (-79.47979),94.62536),V3 13.839526 (-1.0205598) (-8.638148),V3 (-8.429852e-2) (-2.9109285) 4.988788),((V3 (-48.420025) (-18.939562) (-30.91017),6.5728045),V3 (-7.6758323) 11.250289 (-6.3134418),V3 0.35382912 0.36280265 0.21467017),((V3 24.05571 (-26.526985) 55.817623,53.180336),V3 (-6.2717843) (-4.4937367) 9.426997,V3 (-0.48020265) 3.4272532 (-2.4739354)),((V3 38.412075 21.907555 58.91943,91.3407),V3 3.8768096 (-10.066701) 7.232523,V3 (-3.7875612) (-1.6009333) (-4.7642846)),((V3 (-11.713844) 25.808075 34.806118,87.52959),V3 10.581014 5.0761976 5.7207565,V3 3.913912 (-1.8188158) (-2.7121327)),((V3 0.29591668 53.392735 (-59.070557),75.542244),V3 12.523133 2.3962336 (-9.897869),V3 0.258676 (-0.2904919) 1.2244126),((V3 (-39.304882) (-2.4880366) (-35.646812),35.689384),V3 (-2.3586354) 11.898649 (-6.5040054),V3 1.6116967 1.186789 1.5703841),((V3 29.410185 (-30.127684) 50.689945,77.35545),V3 (-8.353604) (-4.429852) 8.189255,V3 (-1.6932052) 5.2191257 (-2.4670205)),((V3 79.16618 21.078148 52.9975,34.4798),V3 4.4726243 (-15.612979) 8.523445,V3 (-3.1038995) (-0.19130452) (-0.6173794)),((V3 (-1.3194776) 14.902553 21.06105,20.805649),V3 5.366333 3.3273313 6.76692,V3 0.10942383 0.29500887 0.33297652),((V3 8.919601 70.99377 (-71.09529),58.3743),V3 13.811482 (-1.798587) (-10.556653),V3 (-1.1980586) (-2.6337848) 1.6664244),((V3 (-49.27589) (-9.043354) (-8.953376),20.659788),V3 (-4.8574266) 13.547301 (-1.7893666),V3 1.4573994 0.90100104 0.20331861),((V3 42.495594 (-53.756332) 36.63188,82.26547),V3 (-13.994319) (-6.1497493) 6.7633076,V3 (-3.1410325) 6.6301613 3.0234138e-2),((V3 58.644115 37.20186 58.620056,86.262726),V3 5.4610834 (-15.029127) 7.486924,V3 (-5.588184) (-3.6724644) (-3.101759)),((V3 (-22.410553) 10.888989 24.760492,52.37195),V3 3.5517094 10.775686 6.068233,V3 3.405976 1.4547812 (-0.44147408))]
-t20 = fromList (Z :. 32) [((V3 70.64258 26.97726 70.65352,3.456227),V3 10.103177 (-11.083501) 10.430128,V3 (-0.25878596) (-0.1096651) (-0.14805585)),((V3 (-0.60530925) 31.649681 34.703568,63.459526),V3 11.983897 3.3875232 5.6731596,V3 1.9059213 (-2.2702324) (-0.38499674)),((V3 19.129223 67.63949 (-86.13814),74.34554),V3 12.898823 (-4.338295) (-6.4802012),V3 (-1.11779) (-2.3244681) 3.2478783),((V3 (-52.587482) (-0.21061647) (-36.487682),8.434827),V3 (-5.521948) 11.965574 (-6.018765),V3 0.5088869 0.27565396 0.25721252),((V3 27.600586 (-33.542427) 37.002804,16.776989),V3 (-5.2118816) (-8.994746) 7.3886538,V3 (-0.35461906) 1.1443055 0.33297035),((V3 74.98001 21.052492 68.71739,21.63172),V3 6.6536603 (-13.656725) 8.92714,V3 (-1.7712361) (-0.41551957) (-0.8035278)),((V3 (-0.1968162) 30.138866 32.549713,69.831604),V3 11.614001 3.864655 6.1276393,V3 1.9305562 (-2.0955043) 7.4945375e-2),((V3 13.495451 70.11945 (-91.47385),66.98223),V3 15.745442 (-1.9447142) (-6.1191072),V3 0.34707648 (-2.4542372) 3.844818),((V3 (-39.07626) 14.344181 (-24.048937),23.477612),V3 (-0.5911909) 12.481703 (-3.5879762),V3 1.2193754 0.2451571 0.5313611),((V3 20.755718 (-47.285156) 83.758934,4.5274367),V3 (-7.3864875) (-7.5831957) 12.738908,V3 1.0477281e-2 0.3141431 (-0.31150085)),((V3 29.731346 4.957616 67.74644,45.534313),V3 2.542373 (-5.4659686) 7.1639175,V3 (-0.773719) 0.55258787 (-2.949255)),((V3 3.2952871 40.414585 30.630938,37.293446),V3 12.0785885 1.6407151 5.635318,V3 0.5175421 (-2.311788) 0.13688904),((V3 17.204876 57.061028 (-92.11485),52.771004),V3 10.187838 1.4056993 (-7.992482),V3 (-0.5327076) 0.28180283 3.2848911),((V3 (-43.428978) 5.4403176 (-38.405262),83.92678),V3 1.3721125 17.93844 (-1.0416794),V3 4.1768746 2.3258047 2.9994802),((V3 25.61177 (-35.67625) 50.29802,13.032608),V3 (-5.5239754) (-8.40189) 8.819078,V3 (-0.17469631) 0.9371397 (-0.13386086)),((V3 77.91648 63.749935 111.700096,18.12446),V3 13.566664 (-10.48896) 12.8802395,V3 (-0.6257403) (-0.68909454) (-0.9268724)),((V3 8.015066 28.20771 52.363438,53.132633),V3 9.834624 (-0.42201662) 4.975245,V3 0.8522565 (-1.7886617) (-2.724254)),((V3 16.687307 65.11167 (-85.9828),94.62536),V3 13.431137 (-3.5456862) (-4.025685),V3 (-0.6603307) (-2.1941738) 4.275058),((V3 (-55.929226) (-7.5420556) (-37.130413),6.5728045),V3 (-7.2981763) 11.561206 (-6.1095667),V3 0.39473253 0.27254176 0.196624),((V3 17.732718 (-29.473835) 64.11756,53.180336),V3 (-6.2080007) (-1.0590713) 6.9066863,V3 0.49391943 3.4189227 (-2.5597522)),((V3 40.55933 11.31991 64.03876,91.3407),V3 1.478368e-2 (-10.987337) 2.5858128,V3 (-3.8935337) (-0.3199196) (-4.506024)),((V3 0.45339978 29.896873 39.454823,87.52959),V3 13.876055 2.7052927 3.5193348,V3 2.690946 (-2.7923274) (-1.7411938)),((V3 12.880193 55.68854 (-68.52059),75.542244),V3 12.610873 2.1888132 (-9.000532),V3 (-1.7048633e-2) (-0.18977338) 0.6773345),((V3 (-40.928196) 9.86234 (-41.4781),35.689384),V3 (-0.7128805) 12.819815 (-5.0434055),V3 1.6750612 0.72688335 1.3807626),((V3 20.569416 (-32.173176) 57.774376,77.35545),V3 (-9.122361) 0.8884996 5.742017,V3 1.2530923e-2 5.3429766 (-2.4258206)),((V3 82.24203 5.4715424 61.2392,34.4798),V3 1.3694282 (-15.498303) 7.885867,V3 (-3.0998273) 0.35917798 (-0.67349565)),((V3 4.1159596 18.343342 27.995344,20.805649),V3 5.547433 3.5543864 7.153706,V3 0.2545224 0.16027838 0.41772422),((V3 22.132597 68.11572 (-80.91648),58.3743),V3 12.430078 (-4.07933) (-8.919203),V3 (-1.4921408) (-1.9892223) 1.665496),((V3 (-53.46823) 4.8355 (-10.660793),20.659788),V3 (-3.3736873) 14.207917 (-1.6194743),V3 1.4933307 0.48024258 0.13877386),((V3 27.381256 (-56.825172) 43.436813,82.26547),V3 (-16.138443) 0.79542387 6.8798237,V3 (-1.272959) 7.1740904 0.16700138),((V3 61.48199 20.758127 64.70831,86.262726),V3 (-0.48431414) (-17.875822) 4.367215,V3 (-6.221025) (-2.0769675) (-3.1554008)),((V3 (-17.251387) 22.09256 30.678736,52.37195),V3 7.1905856 11.458972 5.7806373,V3 3.7821503 9.846892e-3 (-0.18520965))]
-t30 = fromList (Z :. 32) [((V3 80.62529 15.850722 81.01362,3.456227),V3 9.832466 (-11.171636) 10.271142,V3 (-0.27626523) (-6.907271e-2) (-0.16648479)),((V3 12.109674 33.908443 40.254055,63.459526),V3 13.452332 0.7633101 5.4452367,V3 1.0651537 (-2.9039454) (-0.13198845)),((V3 31.485191 62.397385 (-91.180084),74.34554),V3 11.659424 (-6.17881) (-3.3099105),V3 (-1.3080394) (-1.4175643) 3.1050818),((V3 (-57.875084) 11.86496 (-42.392822),8.434827),V3 (-4.9964967) 12.19545 (-5.7677174),V3 0.53527856 0.19483553 0.24825694),((V3 22.266294 (-41.991844) 44.539543,16.776989),V3 (-5.4461217) (-7.745878) 7.7115583,V3 (-0.14457354) 1.3438723 0.30253243),((V3 80.82082 7.255052 77.26334,21.63172),V3 4.8354826 (-13.9168) 8.057859,V3 (-1.8398229) (-0.1291134) (-0.92295176)),((V3 12.16488 32.92552 38.752,69.831604),V3 13.12455 1.3194892 6.3205833,V3 1.1184452 (-2.9104452) 0.23775212),((V3 29.262188 67.1042 (-95.894775),66.98223),V3 15.635218 (-4.276028) (-2.3869843),V3 (-0.5043809) (-2.201609) 3.6215343),((V3 (-39.12235) 26.887955 (-27.421051),23.477612),V3 0.6162337 12.572925 (-3.130873),V3 1.1982962 (-1.6151225e-2) 0.4058443),((V3 13.381501 (-54.72822) 96.35743,4.5274367),V3 (-7.351956) (-7.273869) 12.427602,V3 5.11916e-2 0.3034085 (-0.3084455)),((V3 31.944645 (-0.24181631) 73.54906,45.534313),V3 1.8208045 (-4.8607187) 4.099617,V3 (-0.7120765) 0.6306646 (-3.160519)),((V3 15.529402 40.993393 36.353447,37.293446),V3 12.340105 (-0.740232) 5.8483925,V3 5.584805e-2 (-2.4297142) 0.2502288),((V3 27.210176 58.54192 (-98.62292),52.771004),V3 9.847976 1.4936708 (-4.6850176),V3 (-0.17808737) (-0.12827606) 3.3288074),((V3 (-40.165707) 24.159132 (-38.19885),83.92678),V3 5.569859 19.36941 1.6151043,V3 4.1652684 0.6796782 2.36701),((V3 20.0366 (-43.634075) 59.045513,13.032608),V3 (-5.610209) (-7.3880525) 8.644443,V3 (-2.1231862e-2) 1.0824242 (-0.2157843)),((V3 91.1954 52.98254 124.174416,18.12446),V3 12.923086 (-11.0728035) 11.991299,V3 (-0.65076464) (-0.49877062) (-0.85619026)),((V3 18.163801 26.950344 56.156433,53.132633),V3 10.439416 (-2.310497) 2.4027362,V3 0.35562944 (-1.9632834) (-2.4307075)),((V3 29.736702 60.715374 (-88.231476),94.62536),V3 12.49499 (-5.2733855) (-0.25494644),V3 (-1.143601) (-1.3175715) 3.3169105),((V3 (-63.04561) 4.129257 (-43.15318),6.5728045),V3 (-6.891207) 11.792309 (-5.9181933),V3 0.41236284 0.19797336 0.18787487),((V3 11.896064 (-29.014198) 69.856224,53.180336),V3 (-5.2224894) 2.284795 4.2921305,V3 1.3726617 3.257218 (-2.6621897)),((V3 38.84494 0.44165504 64.68979,91.3407),V3 (-3.7706373) (-10.44458) (-1.5761747),V3 (-3.6047552) 1.2989374 (-3.7820122)),((V3 15.253961 31.213158 42.37834,87.52959),V3 15.57238 (-0.5108675) 2.4073062,V3 0.77382207 (-3.5107894) (-0.5931102)),((V3 25.462185 57.7606 (-77.258286),75.542244),V3 12.529613 1.8682239 (-8.432913),V3 (-0.11828619) (-0.50076365) 0.56394),((V3 (-40.875896) 22.949284 (-45.92175),35.689384),V3 1.0001571 13.351651 (-3.730043),V3 1.7436737 0.38464665 1.2702756),((V3 11.7580805 (-28.916342) 62.435238,77.35545),V3 (-8.081674) 6.077168 3.352129,V3 1.9076473 4.964432 (-2.3579834)),((V3 82.2225 (-9.7786255) 68.797226,34.4798),V3 (-1.7052021) (-14.852521) 7.1237183,V3 (-3.0383008) 0.8755246 (-0.85059637)),((V3 9.812528 21.933826 35.338314,20.805649),V3 5.919625 3.5853083 7.5684195,V3 0.47318155 (-0.10099702) 0.39165217),((V3 33.87477 63.25305 (-89.045364),58.3743),V3 10.897609 (-5.691883) (-7.101499),V3 (-1.5258808) (-1.2934843) 1.9847765),((V3 (-56.17241) 19.20363 (-12.229358),20.659788),V3 (-1.8913364) 14.507622 (-1.5179769),V3 1.4663916 0.16752706 7.473919e-2),((V3 11.038544 (-52.75113) 50.393963,82.26547),V3 (-16.147457) 8.103466 7.0406375,V3 1.1229347 7.317746 0.116557844),((V3 58.12866 2.3073416 67.638176,86.262726),V3 (-6.899946) (-18.700304) 1.1591533,V3 (-6.4619718) 0.34747308 (-3.231288)),((V3 (-8.346832) 33.286644 36.39714,52.37195),V3 10.981637 10.563141 5.655627,V3 3.7102525 (-1.6548095) (-0.10352421))]
-t40 = fromList (Z :. 32) [((V3 90.3346 4.655861 91.20859,3.456227),V3 9.561887 (-11.214318) 10.101466,V3 (-0.26128083) (-2.0770896e-2) (-0.16977718)),((V3 25.855879 33.27752 45.650112,63.459526),V3 13.874311 (-2.4134786) 5.3301144,V3 (-0.17173003) (-3.3428502) (-0.14888263)),((V3 42.55104 55.74881 (-93.12408),74.34554),V3 10.346969 (-7.033272) (-0.31666315),V3 (-1.2832952) (-0.39005303) 2.8811932),((V3 (-62.630367) 24.135597 (-48.04935),8.434827),V3 (-4.4623313) 12.3485365 (-5.5214076),V3 0.5272145 0.11860251 0.24403755),((V3 16.786787 (-49.09336) 52.37048,16.776989),V3 (-5.482549) (-6.270866) 7.9521694,V3 6.0247123e-2 1.5767819 0.17346881),((V3 84.83455 (-6.668477) 84.889885,21.63172),V3 3.0254977 (-13.872956) 7.0852513,V3 (-1.7604394) 0.1894979 (-1.002964)),((V3 25.607107 32.814 45.158234,69.831604),V3 13.595416 (-1.9758472) 6.462585,V3 (-0.13727047) (-3.549432) (-3.7056354e-3)),((V3 44.518757 61.90863 (-96.71034),66.98223),V3 14.625989 (-6.22489) 1.0272641,V3 (-1.417286) (-1.7000344) 3.2084227),((V3 (-37.96874) 39.424587 (-30.38036),23.477612),V3 1.8094404 12.464852 (-2.7568665),V3 1.1918833 (-0.17094232) 0.36163473),((V3 6.057052 (-61.869263) 108.64919,4.5274367),V3 (-7.286687) (-6.983825) 12.130093,V3 7.459494e-2 0.27627227 (-0.28570133)),((V3 33.423145 (-4.8133616) 76.19642,45.534313),V3 1.0209748 (-4.2072473) 0.8476473,V3 (-0.9101132) 0.69006634 (-3.3002555)),((V3 27.816963 39.14842 42.311176,37.293446),V3 12.133267 (-3.2016866) 6.077291,V3 (-0.43277112) (-2.4690394) 0.1829573),((V3 37.032055 59.871284 (-101.80806),52.771004),V3 9.842458 1.0014532 (-1.3576142),V3 0.113305725 (-0.80959976) 3.3034868),((V3 (-32.768158) 43.553585 (-35.62678),83.92678),V3 9.558228 19.116442 3.6231754,V3 3.785976 (-1.0030328) 1.7205341),((V3 14.439234 (-50.508904) 67.57433,13.032608),V3 (-5.5554476) (-6.2216606) 8.366025,V3 0.12124021 1.2241457 (-0.33175266)),((V3 103.82722 41.714848 135.79294,18.12446),V3 12.279673 (-11.474536) 11.176818,V3 (-0.631969) (-0.3265566) (-0.78048927)),((V3 28.635696 23.74509 57.530754,53.132633),V3 10.348517 (-4.291683) 0.19939163,V3 (-0.5118455) (-1.936669) (-1.9911488)),((V3 41.658382 55.011665 (-87.18198),94.62536),V3 11.169736 (-6.0489197) 2.4283314,V3 (-1.4343514) (-0.3365628) 2.1519272),((V3 (-69.752426) 15.998649 (-48.988125),6.5728045),V3 (-6.48451) 11.950421 (-5.7348514),V3 0.39747268 0.12604822 0.17903966),((V3 7.421006 (-25.314278) 72.93206,53.180336),V3 (-3.4275875) 5.3594904 1.5695516,V3 2.1104321 2.8862293 (-2.7693553)),((V3 33.593594 (-9.123072) 61.628304,91.3407),V3 (-6.853316) (-8.163884) (-4.585922),V3 (-2.5169895) 3.068793 (-2.2420175)),((V3 30.775204 29.06608 44.69013,87.52959),V3 14.991441 (-4.1634536) 2.3604884,V3 (-1.743295) (-3.6350572) 0.3263754),((V3 37.925953 59.291317 (-85.37278),75.542244),V3 12.364148 0.97157943 (-7.610811),V3 (-0.22051588) (-1.2753534) 1.148759),((V3 (-39.081818) 36.42463 (-49.090176),35.689384),V3 2.7722025 13.572521 (-2.4910996),V3 1.7876816 8.852193e-2 1.2181025),((V3 4.854909 (-20.765474) 64.73786,77.35545),V3 (-5.121062) 10.451305 1.0317328,V3 3.773904 3.7349844 (-2.2926235)),((V3 79.178535 (-24.155758) 75.49906,34.4798),V3 (-4.636625) (-13.707212) 6.141575,V3 (-2.8098998) 1.3618014 (-1.0914961)),((V3 15.977711 25.408234 43.059597,20.805649),V3 6.4937973 3.2579877 7.8726983,V3 0.63328594 (-0.5327105) 0.20720817),((V3 44.112415 57.10134 (-95.17267),58.3743),V3 9.473635 (-6.577284) (-4.840429),V3 (-1.3064284) (-0.55162036) 2.500792),((V3 (-57.413094) 33.74672 (-13.71971),20.659788),V3 (-0.45732188) 14.546219 (-1.4605455),V3 1.4030969 (-5.6085628e-2) 5.0729703e-2),((V3 (-4.132298) (-41.444485) 57.4354,82.26547),V3 (-13.4335) 15.047902 6.9562955,V3 4.059167 6.4290543 (-0.3307359)),((V3 48.41738 (-15.724357) 67.36842,86.262726),V3 (-12.948876) (-16.616163) (-1.95434),V3 (-5.4540496) 3.5695972 (-2.9190702)),((V3 4.210882 42.83211 41.997192,52.37195),V3 14.340451 8.013545 5.5130305,V3 2.9640288 (-3.234027) (-0.19869432))]
-t50 = fromList (Z :. 32) [((V3 99.78429 (-6.5603447) 101.23478,3.456227),V3 9.319103 (-11.210923) 9.935835,V3 (-0.22626747) 2.1161372e-2 (-0.1612093)),((V3 39.403965 29.356451 50.871735,63.459526),V3 12.86763 (-5.723307) 5.028878,V3 (-1.6957306) (-3.1606607) (-0.4616191)),((V3 52.3492 48.69863 (-92.19782),74.34554),V3 9.166924 (-6.910074) 2.3809798,V3 (-1.0765165) 0.49746767 2.5362353),((V3 (-66.8613) 36.525005 (-53.462444),8.434827),V3 (-3.9560394) 12.425948 (-5.2827253),V3 0.48558196 4.514877e-2 0.23342745),((V3 11.3726 (-54.63127) 60.366547,16.776989),V3 (-5.284395) (-4.62866) 8.007034,V3 0.309564 1.6607597 (-5.4514244e-2)),((V3 87.09958 (-20.402815) 91.51911,21.63172),V3 1.3766433 (-13.507609) 6.0697675,V3 (-1.5429239) 0.502993 (-1.0176795)),((V3 38.87964 29.213264 51.52705,69.831604),V3 12.579766 (-5.5654917) 6.13499,V3 (-1.747105) (-3.477748) (-0.63458973)),((V3 58.371513 55.032394 (-94.33609),66.98223),V3 12.771849 (-7.537657) 3.9042752,V3 (-2.1691554) (-0.976144) 2.5849755),((V3 (-35.62298) 51.793858 (-32.97171),23.477612),V3 3.000215 12.232307 (-2.3830836),V3 1.1863849 (-0.2821353) 0.39073357),((V3 (-1.1938903) (-68.73547) 120.656364,4.5274367),V3 (-7.2055235) (-6.73064) 11.863677,V3 8.4682934e-2 0.2324943 (-0.24955781)),((V3 33.98479 (-8.668965) 75.568375,45.534313),V3 (-4.586573e-2) (-3.3565376) (-2.4003098),V3 (-1.161805) 1.0472943 (-3.1469493)),((V3 39.66494 34.850323 48.43695,37.293446),V3 11.395371 (-5.6083426) 6.138593,V3 (-0.99539036) (-2.3176267) (-6.147321e-2)),((V3 46.950523 60.39374 (-101.70575),52.771004),V3 10.027083 (-0.18237326) 1.846281,V3 0.21004155 (-1.4657336) 3.093771),((V3 (-21.612383) 61.96557 (-31.32596),83.92678),V3 12.976039 17.290213 5.0295744,V3 3.0800977 (-2.4412982) 1.1717454),((V3 8.96526 (-56.172928) 75.77116,13.032608),V3 (-5.345359) (-4.985807) 7.967873,V3 0.27868465 1.2160217 (-0.45238936)),((V3 115.829254 30.117777 146.63062,18.12446),V3 11.671261 (-11.721733) 10.436247,V3 (-0.5865162) (-0.18780562) (-0.70882756)),((V3 38.582184 18.651218 56.93042,53.132633),V3 9.270124 (-5.9622445) (-1.4593434),V3 (-1.5178046) (-1.3589051) (-1.3558631)),((V3 52.169697 48.95184 (-83.96839),94.62536),V3 9.706987 (-5.938324) 3.989206,V3 (-1.4470835) 0.41542193 1.1349429),((V3 (-76.06361) 27.99487 (-54.644337),6.5728045),V3 (-6.106245) 12.040813 (-5.5623775),V3 0.36062056 6.338345e-2 0.1667967),((V3 5.031253 (-18.753942) 73.24428,53.180336),V3 (-1.0452096) 7.9019423 (-1.2293646),V3 2.5434313 2.215863 (-2.8002636)),((V3 25.895203 (-15.654797) 56.379826,91.3407),V3 (-8.374308) (-4.2960773) (-5.6613545),V3 (-0.61054236) 4.410234 (-0.105147086)),((V3 44.56931 23.377563 47.275223,87.52959),V3 11.912463 (-7.3660054) 2.9104905,V3 (-4.0473733) (-2.6802368) 0.6384738),((V3 50.153812 59.54019 (-92.28699),75.542244),V3 12.008861 (-0.7881906) (-5.8424706),V3 (-0.4955644) (-2.1168833) 2.3230572),((V3 (-35.506397) 49.987667 (-51.03989),35.689384),V3 4.5507164 13.495833 (-1.2958468),V3 1.7571652 (-0.21390966) 1.1755395),((V3 1.6586281 (-8.966029) 64.74854,77.35545),V3 (-0.6585472) 13.033994 (-1.2206159),V3 4.837213 1.534798 (-2.2026932)),((V3 73.34591 (-37.17399) 81.11334,34.4798),V3 (-7.204541) (-12.09446) 4.9343133,V3 (-2.3330922) 1.8091398 (-1.2886307)),((V3 22.757414 28.347914 50.975887,20.805649),V3 7.116842 2.4678946 7.908502,V3 0.5789135 (-0.98542297) (-0.11901239)),((V3 53.056896 50.391014 (-98.801895),58.3743),V3 8.367776 (-6.7536325) (-2.0602012),V3 (-0.93099135) 0.10514579 2.9887574),((V3 (-57.253033) 48.23814 (-15.15559),20.659788),V3 0.8975221 14.393842 (-1.4017532),V3 1.3112133 (-0.22530983) 7.0312925e-2),((V3 (-15.272543) (-23.845793) 64.09268,82.26547),V3 (-7.877729) 20.243881 6.091751,V3 6.59736 3.9433155 (-1.3863378)),((V3 33.405663 (-30.212833) 64.24376,86.262726),V3 (-17.00329) (-11.36592) (-4.358442),V3 (-2.6607215) 6.4482036 (-1.8884766)),((V3 19.681992 49.188995 47.388447,52.37195),V3 16.6021 4.146414 5.202059,V3 1.6236293 (-4.2790256) (-0.41353542))]
+t0  = fromList (Z :. 32) [((V3 49.934765 48.864784 49.504097,3.456227),V3 10.561408 (-10.792668) 10.699586,V3 (-5.8465254e-2) (-5.3318936e-2) (-3.7962403e-2)),((V3 (-19.72055) 21.0447 21.976465,63.459526),V3 6.989762 6.5499606 7.2992377,V3 4.7686737e-2 (-1.2605067e-2) (-2.0685539e-2)),((V3 (-8.485103) 70.43111 (-66.07767),74.34554),V3 14.306272 1.7235309 (-13.421982),V3 (-1.8446379e-3) (-4.991456e-2) 5.1070634e-2),((V3 (-40.529545) (-23.411388) (-23.874193),8.434827),V3 (-6.4595428) 11.182692 (-6.5872374),V3 5.029127e-2 6.393997e-2 3.7228435e-2),((V3 36.915504 (-13.378705) 22.885813,16.776989),V3 (-3.9690585) (-10.951718) 6.7895308,V3 (-5.4352477e-2) 4.772437e-2 1.4567572e-2),((V3 58.12199 47.11681 49.27831,21.63172),V3 9.955754 (-12.281143) 10.4124775,V3 (-7.109863e-2) (-4.511348e-2) (-3.3953156e-2)),((V3 (-18.56515) 19.121122 19.856537,69.831604),V3 6.6335444 6.440665 6.8886757,V3 4.2793047e-2 (-5.898035e-3) (-1.3569633e-2)),((V3 (-16.319696) 68.65275 (-70.91549),66.98223),V3 13.727621 3.263243 (-14.180073),V3 2.426421e-2 (-4.17068e-2) 6.3705206e-2),((V3 (-35.320797) (-9.581309) (-15.5530615),23.477612),V3 (-3.0388143) 11.202367 (-4.932819),V3 5.147862e-2 4.773648e-2 3.3400152e-2),((V3 35.467846 (-31.458008) 57.63878,4.5274367),V3 (-7.2828484) (-8.211167) 13.343963,V3 (-2.792424e-2) 6.858267e-2 (-6.4539455e-2)),((V3 22.741138 16.762173 47.443493,45.534313),V3 4.5114946 (-6.1207175) 12.769291,V3 (-2.7073495e-2) 5.835596e-4 (-5.9141617e-2)),((V3 (-19.066488) 32.53443 19.284454,37.293446),V3 9.998227 5.859364 5.926348,V3 4.3742817e-2 (-4.8672996e-2) (-1.3978232e-2)),((V3 (-4.6187997) 54.83043 (-69.1615),52.771004),V3 11.664729 0.9826122 (-14.713549),V3 (-1.5402405e-2) (-2.1232222e-3) 6.7179084e-2),((V3 (-37.741123) (-23.498236) (-29.302645),83.92678),V3 (-6.4404936) 10.344243 (-8.03139),V3 4.199328e-2 6.333776e-2 4.648305e-2),((V3 36.013374 (-17.063395) 32.41684,13.032608),V3 (-4.7614217) (-10.049282) 9.045693,V3 (-4.7077283e-2) 5.435021e-2 (-9.058952e-3)),((V3 49.562435 83.03267 83.920395,18.12446),V3 14.676114 (-8.760214) 14.83302,V3 (-2.5904639e-2) (-5.6934875e-2) (-5.6100726e-2)),((V3 (-9.462863) 25.536043 36.41799,53.132633),V3 7.573575 2.8065314 10.800983,V3 2.607295e-2 (-2.6702004e-2) (-5.7893842e-2)),((V3 (-10.790539) 66.63314 (-67.998985),94.62536),V3 13.614646 2.204749 (-13.893719),V3 5.9576677e-3 (-3.754723e-2) 5.825267e-2),((V3 (-40.558056) (-29.971233) (-24.474981),6.5728045),V3 (-8.00616) 10.834197 (-6.5379558),V3 4.643845e-2 7.218637e-2 3.550238e-2),((V3 29.8883 (-20.165321) 45.04451,53.180336),V3 (-5.309554) (-7.869626) 11.860275,V3 (-2.7512655e-2) 6.2145043e-2 (-4.490502e-2)),((V3 32.482105 30.910307 49.05143,91.3407),V3 7.583363 (-7.9689794) 12.034005,V3 (-3.9746404e-2) (-2.8269194e-2) (-5.2805282e-2)),((V3 (-20.018032) 19.918154 27.472118,87.52959),V3 6.346644 6.378469 8.753611,V3 5.1203217e-2 (-8.614577e-3) (-3.780392e-2)),((V3 (-12.006343) 50.781525 (-48.374542),75.542244),V3 12.0401945 2.8466792 (-11.469504),V3 9.904206e-3 (-8.5901925e-3) 2.5768416e-2),((V3 (-36.06932) (-13.634953) (-28.24347),35.689384),V3 (-3.9444003) 10.434348 (-8.17044),V3 4.3696642e-2 4.968312e-2 4.9206298e-2),((V3 36.564384 (-22.889074) 41.142605,77.35545),V3 (-5.9291406) (-9.471566) 10.6575,V3 (-4.081828e-2) 6.2415935e-2 (-3.1806156e-2)),((V3 72.98635 36.489113 44.127728,34.4798),V3 7.5769863 (-15.15566) 9.163149,V3 (-9.0077996e-2) (-2.122369e-2) (-1.9645749e-2)),((V3 (-6.637457) 11.754714 14.4537,20.805649),V3 5.286392 2.9850323 6.5001945,V3 2.9537356e-3 1.8812694e-2 9.260967e-3),((V3 (-5.4672456) 71.23518 (-59.5781),58.3743),V3 14.7713995 1.1336936 (-12.354176),V3 (-1.1637243e-2) (-5.5525895e-2) 3.380191e-2),((V3 (-43.633926) (-22.012821) (-7.0467205),20.659788),V3 (-6.265288) 12.4190855 (-2.0056372),V3 6.514283e-2 6.6139065e-2 1.0705786e-2),((V3 54.48485 (-44.066643) 29.847332,82.26547),V3 (-10.098527) (-12.486015) 6.8399606,V3 (-5.6461737e-2) 7.329602e-2 (-2.408542e-3)),((V3 50.216465 50.00622 49.413647,86.262726),V3 10.759963 (-10.805201) 10.632457,V3 (-5.819214e-2) (-5.5052362e-2) (-3.7297014e-2)),((V3 (-24.18221) 1.1176014 18.39111,52.37195),V3 0.40538555 8.771569 6.670974,V3 5.4719485e-2 4.8198618e-2 (-1.4726739e-2))]
+t10 = fromList (Z :. 32) [((V3 60.46915 38.049763 60.18694,3.456227),V3 10.500432 (-10.839749) 10.662977,V3 (-6.299738e-2) (-4.0606603e-2) (-3.503151e-2)),((V3 (-12.710341) 27.58728 29.2675,63.459526),V3 7.033509 6.531166 7.2826796,V3 3.9417017e-2 (-2.4318043e-2) (-1.2529185e-2)),((V3 5.8191376 72.13333 (-79.47746),74.34554),V3 14.300079 1.6779364 (-13.373929),V3 (-1.007577e-2) (-4.138974e-2) 4.4931494e-2),((V3 (-46.965878) (-12.202626) (-30.445168),8.434827),V3 (-6.4073753) 11.2366295 (-6.5520697),V3 5.316237e-2 4.436316e-2 3.2511435e-2),((V3 32.924366 (-24.30769) 29.68248,16.776989),V3 (-4.0144243) (-10.899687) 6.8062797,V3 (-3.625469e-2) 5.5133607e-2 1.8903675e-2),((V3 68.04529 34.81722 59.675842,21.63172),V3 9.883088 (-12.319228) 10.379867,V3 (-7.3707074e-2) (-3.0890143e-2) (-3.1040747e-2)),((V3 (-11.913213) 25.55745 26.740288,69.831604),V3 6.672953 6.428675 6.8795137,V3 3.5638496e-2 (-1.743291e-2) (-4.858997e-3)),((V3 (-2.5822248) 71.89773 (-85.06752),66.98223),V3 13.748029 3.2234287 (-14.118707),V3 1.6976822e-2 (-3.800234e-2) 5.893958e-2),((V3 (-38.33642) 1.6395313 (-20.47131),23.477612),V3 (-2.987542) 11.239037 (-4.9014173),V3 5.0148148e-2 2.6261436e-2 2.8640006e-2),((V3 28.174822 (-39.638298) 70.95353,4.5274367),V3 (-7.3018956) (-8.142821) 13.278979,V3 (-1.0446727e-2) 6.7271136e-2 (-6.4846575e-2)),((V3 27.241245 10.642716 60.18606,45.534313),V3 4.48744 (-6.116445) 12.709923,V3 (-2.0935236e-2) 7.756635e-3 (-5.9058737e-2)),((V3 (-9.050869) 38.37063 25.206083,37.293446),V3 10.03332 5.8062935 5.9181905,V3 2.6315982e-2 (-5.6510445e-2) (-2.6036697e-3)),((V3 7.0388546 55.81346 (-83.84555),52.771004),V3 11.648944 0.98554176 (-14.649176),V3 (-1.57277e-2) 7.7191275e-3 6.156286e-2),((V3 (-44.162117) (-13.127917) (-37.31366),83.92678),V3 (-6.396497) 10.39863 (-7.987127),V3 4.5245014e-2 4.5870926e-2 4.15155e-2),((V3 31.233261 (-27.087244) 41.458775,13.032608),V3 (-4.799122) (-9.991673) 9.037911,V3 (-2.832059e-2) 5.9691917e-2 (-6.264761e-3)),((V3 64.2263 74.24797 98.728455,18.12446),V3 14.648074 (-8.81287) 14.778009,V3 (-2.9918874e-2) (-4.8322428e-2) (-5.3722136e-2)),((V3 (-1.8782356) 28.330034 47.19328,53.132633),V3 7.59696 2.7780106 10.744472,V3 2.0323046e-2 (-2.9926136e-2) (-5.5057187e-2)),((V3 2.8258152 68.821976 (-81.86721),94.62536),V3 13.617112 2.1707473 (-13.838209),V3 (-5.690545e-4) (-3.0585786e-2) 5.2687045e-2),((V3 (-48.542404) (-19.107103) (-30.99738),6.5728045),V3 (-7.9566193) 10.896909 (-6.504232),V3 5.1728886e-2 5.3543624e-2 3.1369787e-2),((V3 24.568964 (-28.00671) 56.884422,53.180336),V3 (-5.327383) (-7.8068233) 11.814985,V3 (-8.408111e-3) 6.240661e-2 (-4.514151e-2)),((V3 40.04745 22.930038 61.06176,91.3407),V3 7.5432544 (-7.991842) 11.981683,V3 (-4.0066183e-2) (-1.734879e-2) (-5.1456492e-2)),((V3 (-13.648971) 26.291054 36.20942,87.52959),V3 6.3953285 6.363704 8.71845,V3 4.5679934e-2 (-2.0351104e-2) (-3.255792e-2)),((V3 3.732586e-2 53.625175 (-59.833904),75.542244),V3 12.046625 2.8412018 (-11.449239),V3 3.5754684e-3 (-2.4492005e-3) 1.4656954e-2),((V3 (-39.99398) (-3.1807213) (-36.39248),35.689384),V3 (-3.9006371) 10.474942 (-8.12412),V3 4.3195367e-2 3.2081887e-2 4.2915497e-2),((V3 30.619442 (-32.331882) 51.785816,77.35545),V3 (-5.96035) (-9.407012) 10.625909,V3 (-2.1698227e-2) 6.559224e-2 (-3.0963803e-2)),((V3 80.522934 21.326115 53.282482,34.4798),V3 7.4876595 (-15.168581) 9.145257,V3 (-8.789413e-2) (-4.634789e-3) (-1.594974e-2)),((V3 (-1.3497021) 14.747591 20.959105,20.805649),V3 5.2893558 3.0016286 6.513338,V3 2.654566e-3 1.4720943e-2 1.6898232e-2),((V3 9.297517 72.34537 (-71.9181),58.3743),V3 14.754692 1.0836073 (-12.324341),V3 (-2.1258706e-2) (-4.474873e-2) 2.5740145e-2),((V3 (-49.86918) (-9.567169) (-9.047593),20.659788),V3 (-6.1978917) 12.473326 (-1.9953101),V3 6.835022e-2 4.2655468e-2 9.441908e-3),((V3 44.36339 (-56.518818) 36.68667,82.26547),V3 (-10.145613) (-12.409902) 6.8393135,V3 (-3.7586633e-2) 7.784604e-2 1.1802961e-3),((V3 60.949482 39.17787 60.02967,86.262726),V3 10.699112 (-10.854074) 10.596562,V3 (-6.302479e-2) (-4.245186e-2) (-3.4275807e-2)),((V3 (-23.750837) 9.908354 25.05635,52.37195),V3 0.46491468 8.810416 6.659598,V3 6.342939e-2 2.9681843e-2 (-8.060057e-3))]
+t20 = fromList (Z :. 32) [((V3 70.940926 27.194159 70.83488,3.456227),V3 10.436661 (-10.872334) 10.630414,V3 (-6.3702285e-2) (-2.6215306e-2) (-3.0383842e-2)),((V3 (-5.660862) 34.106026 36.545834,63.459526),V3 7.067012 6.50226 7.274301,V3 2.8636439e-2 (-3.1787507e-2) (-5.3949296e-3)),((V3 20.113588 73.794075 (-92.83234),74.34554),V3 14.286518 1.6412429 (-13.332854),V3 (-1.596944e-2) (-3.305968e-2) 3.7983958e-2),((V3 (-53.349514) (-0.94910014) (-36.98383),8.434827),V3 (-6.3550825) 11.271065 (-6.5236855),V3 5.0966967e-2 2.7126692e-2 2.494448e-2),((V3 28.896786 (-35.182377) 36.49797,16.776989),V3 (-4.0404034) (-10.844409) 6.8274474,V3 (-1.8333117e-2) 5.4089986e-2 2.2786777e-2),((V3 77.89528 22.486729 70.04246,21.63172),V3 9.809835 (-12.341405) 10.351269,V3 (-7.2197996e-2) (-1.53069e-2) (-2.6450971e-2)),((V3 (-5.2257814) 31.976822 33.618996,69.831604),V3 6.7033725 6.406703 6.8790994,V3 2.6121568e-2 (-2.4829935e-2) 2.7872734e-3),((V3 11.172485 75.104645 (-99.16061),66.98223),V3 13.761965 3.1873329 (-14.062773),V3 1.1852332e-2 (-3.4682337e-2) 5.3524207e-2),((V3 (-41.30235) 12.887198 (-25.361189),23.477612),V3 (-2.9407856) 11.25507 (-4.877336),V3 4.3456644e-2 8.742283e-3 2.0246286e-2),((V3 20.871014 (-47.75181) 84.203735,4.5274367),V3 (-7.3033338) (-8.079022) 13.215667,V3 5.1343776e-3 6.029517e-2 (-6.1662707e-2)),((V3 31.72047 4.530795 72.86988,45.534313),V3 4.470532 (-6.1054206) 12.652626,V3 (-1.3586503e-2) 1.320723e-2 (-5.5407785e-2)),((V3 0.9911369 44.150925 31.124847,37.293446),V3 10.049239 5.748253 5.921204,V3 7.793383e-3 (-5.8347225e-2) 7.060324e-3),((V3 18.681034 56.80402 (-98.46801),52.771004),V3 11.634397 0.99828106 (-14.590865),V3 (-1.3220655e-2) 1.6499214e-2 5.5775106e-2),((V3 (-50.53828) (-2.7113636) (-45.283306),83.92678),V3 (-6.3515453) 10.4356985 (-7.9496207),V3 4.4152167e-2 3.0574834e-2 3.424655e-2),((V3 26.42458 (-37.05218) 50.494526,13.032608),V3 (-4.8171215) (-9.932865) 9.033869,V3 (-1.0390338e-2) 5.6891277e-2 (-2.20375e-3)),((V3 78.860435 65.41494 113.48289,18.12446),V3 14.6167 (-8.855929) 14.726366,V3 (-3.2222364e-2) (-3.8846087e-2) (-4.9778752e-2)),((V3 5.7265587 31.094398 57.913513,53.132633),V3 7.61287 2.7476835 10.691206,V3 1.2211628e-2 (-3.0119797e-2) (-5.1844157e-2)),((V3 16.441877 70.980095 (-95.68275),94.62536),V3 13.614055 2.1438737 (-13.788962),V3 (-4.6635508e-3) (-2.404581e-2) 4.6508152e-2),((V3 (-56.47554) (-8.189092) (-37.488613),6.5728045),V3 (-7.9044585) 10.940743 (-6.476644),V3 5.1829427e-2 3.6626413e-2 2.4401663e-2),((V3 19.240845 (-35.78634) 68.679474,53.180336),V3 (-5.3259783) (-7.747733) 11.771242,V3 8.4766075e-3 5.5464007e-2 (-4.2263586e-2)),((V3 47.573032 14.932348 73.020874,91.3407),V3 7.5045857 (-8.002793) 11.932297,V3 (-3.700923e-2) (-6.0861283e-3) (-4.736238e-2)),((V3 (-7.234455) 32.644043 44.91404,87.52959),V3 6.436363 6.3384748 8.688532,V3 3.7053145e-2 (-2.8388696e-2) (-2.8069116e-2)),((V3 12.084962 56.46628 (-71.27857),75.542244),V3 12.048439 2.8420198 (-11.441257),V3 9.836407e-4 3.2525589e-3 2.7331803e-3),((V3 (-43.87578) 7.306008 (-44.49869),35.689384),V3 (-3.8596008) 10.4984665 (-8.085855),V3 3.8833767e-2 1.726707e-2 3.4572046e-2),((V3 24.652512 (-41.709797) 62.398254,77.35545),V3 (-5.971736) (-9.343225) 10.596589,V3 (-3.7949837e-3) 6.1280284e-2 (-2.7761616e-2)),((V3 87.97208 6.158334 62.421383,34.4798),V3 7.4034786 (-15.163776) 9.132037,V3 (-8.044969e-2) 1.20189125e-2 (-1.0931971e-2)),((V3 3.9405742 17.755447 27.481209,20.805649),V3 5.2910595 3.0151963 6.5339346,V3 8.4806746e-4 1.3092043e-2 2.314742e-2),((V3 24.041346 73.41068 (-84.23238),58.3743),V3 14.729314 1.0449233 (-12.303653),V3 (-2.823351e-2) (-3.3955187e-2) 1.6640395e-2),((V3 (-56.036804) 2.921592 (-11.039263),20.659788),V3 (-6.1315494) 12.503833 (-1.987989),V3 6.3774034e-2 2.1634754e-2 5.3701038e-3),((V3 34.204216 (-68.89385) 43.527176,82.26547),V3 (-10.172236) (-12.333) 6.842662,V3 (-1.8256117e-2) 7.508198e-2 5.00622e-3),((V3 71.61986 28.307106 70.61154,86.262726),V3 10.63512 (-10.888539) 10.564786,V3 (-6.4079866e-2) (-2.8110847e-2) (-2.9580195e-2)),((V3 (-23.256598) 18.729097 31.713388,52.37195),V3 0.5306311 8.83028 6.6549573,V3 6.674404e-2 1.2605487e-2 (-2.2145887e-3))]
+t30 = fromList (Z :. 32) [((V3 81.34933 16.312138 81.45247,3.456227),V3 10.374506 (-10.891698) 10.602904,V3 (-6.0418803e-2) (-1.4253663e-2) (-2.5135279e-2)),((V3 1.4173416 40.59341 43.818542,63.459526),V3 7.0900993 6.4688225 7.271563,V3 1.8832706e-2 (-3.415514e-2) (-9.225694e-4)),((V3 34.392273 75.42162 (-106.149155),74.34554),V3 14.268494 1.6120832 (-13.298374),V3 (-1.9416006e-2) (-2.6191663e-2) 3.1753942e-2),((V3 (-59.682415) 10.331989 (-43.49749),8.434827),V3 (-6.3066883) 11.291188 (-6.5026755),V3 4.6069723e-2 1.5118206e-2 1.7986214e-2),((V3 24.850342 (-46.003483) 43.336105,16.776989),V3 (-4.051738) (-10.794013) 6.8515763,V3 (-6.6093383e-3) 4.6820942e-2 2.4971312e-2),((V3 87.67338 10.140693 80.38266,21.63172),V3 9.740307 (-12.349378) 10.327609,V3 (-6.691807e-2) (-2.5031497e-3) (-2.136768e-2)),((V3 1.4878578 38.371784 40.500256,69.831604),V3 6.7246284 6.380213 6.8847594,V3 1.7549807e-2 (-2.7232328e-2) 7.6355343e-3),((V3 24.939228 78.276794 (-113.200134),66.98223),V3 13.772068 3.1539972 (-14.011981),V3 8.937125e-3 (-3.239144e-2) 4.866305e-2),((V3 (-44.224968) 24.14416 (-30.230755),23.477612),V3 (-2.9020076) 11.257332 (-4.86146),V3 3.487286e-2 (-2.1618789e-3) 1.2551526e-2),((V3 13.571867 (-55.805252) 97.39241,4.5274367),V3 (-7.292245) (-8.023982) 13.156609,V3 1.51392985e-2 5.056349e-2 (-5.6803618e-2)),((V3 36.186085 (-1.5681891) 85.498474,45.534313),V3 4.4608884 (-6.0907354) 12.600278,V3 (-6.5275407e-3) 1.54500315e-2 (-4.965913e-2)),((V3 11.041236 49.87329 37.050385,37.293446),V3 10.048435 5.6913366 5.9319296,V3 (-7.214087e-3) (-5.5201832e-2) 1.3256496e-2),((V3 30.310135 57.81089 (-113.03461),52.771004),V3 11.623426 1.018544 (-14.537836),V3 (-8.956906e-3) 2.3017546e-2 5.093141e-2),((V3 (-56.870506) 7.7361383 (-53.218616),83.92678),V3 (-6.309311) 10.45999 (-7.918944),V3 4.0419314e-2 1.9777462e-2 2.7987558e-2),((V3 21.604952 (-46.960693) 59.528038,13.032608),V3 (-4.8206663) (-9.880324) 9.03375,V3 1.0307725e-3 4.8505776e-2 1.4639762e-3),((V3 93.46253 56.542988 128.1876,18.12446),V3 14.584199 (-8.890012) 14.67914,V3 (-3.2461796e-2) (-3.0384775e-2) (-4.5065958e-2)),((V3 13.343607 33.828907 68.58188,53.132633),V3 7.620753 2.718978 10.640974,V3 4.52757e-3 (-2.7155485e-2) (-4.8959743e-2)),((V3 30.053465 73.114044 (-109.45171),94.62536),V3 13.608259 2.1227496 (-13.74552),V3 (-6.4530065e-3) (-1.8950796e-2) 4.107008e-2),((V3 (-64.3571) 2.765954 (-43.955406),6.5728045),V3 (-7.854152) 10.970362 (-6.455949),V3 4.8777547e-2 2.4572749e-2 1.7826559e-2),((V3 13.9206295 (-43.510826) 80.43237,53.180336),V3 (-5.311387) (-7.6981025) 11.731233,V3 1.8590396e-2 4.4575725e-2 (-3.8092814e-2)),((V3 55.061825 6.928291 84.93275,91.3407),V3 7.4705606 (-8.004173) 11.887948,V3 (-3.132838e-2) 1.9064394e-3 (-4.176428e-2)),((V3 (-0.78287584) 38.969078 53.59043,87.52959),V3 6.468615 6.308092 8.661984,V3 2.84936e-2 (-3.1360246e-2) (-2.5563456e-2)),((V3 24.133852 59.310493 (-82.72036),75.542244),V3 12.049583 2.8475695 (-11.444233),V3 1.6354368e-3 7.1373354e-3 (-7.3236106e-3)),((V3 (-47.718903) 17.810387 (-52.57019),35.689384),V3 (-3.824175) 10.509773 (-8.055168),V3 3.2458644e-2 7.056477e-3 2.7815936e-2),((V3 18.681246 (-51.026814) 72.98298,77.35545),V3 (-5.9686418) (-9.286678) 10.570958,V3 7.750378e-3 5.2297138e-2 (-2.3882877e-2)),((V3 95.34105 (-8.997792) 71.54933,34.4798),V3 7.3288136 (-15.144553) 9.123839,V3 (-6.9617525e-2) 2.4384921e-2 (-6.0460954e-3)),((V3 9.231722 20.776619 34.0262,20.805649),V3 5.2909746 3.028683 6.5590487,V3 (-7.2599156e-4) 1.4122104e-2 2.6299851e-2),((V3 38.757183 74.441895 (-96.52994),58.3743),V3 14.698639 1.0161176 (-12.29159),V3 (-3.2323584e-2) (-2.4858963e-2) 8.505447e-3),((V3 (-62.14096) 15.432594 (-13.025587),20.659788),V3 (-6.0722384) 12.517293 (-1.9850992),V3 5.540452e-2 7.7841384e-3 9.358013e-4),((V3 24.026352 (-81.19422) 50.372597,82.26547),V3 (-10.182178) (-12.2619505) 6.849285,V3 (-3.9810054e-3) 6.7295246e-2 7.7587366e-3),((V3 82.226494 17.40803 81.16388,86.262726),V3 10.572411 (-10.909785) 10.538089,V3 (-6.1113685e-2) (-1.6114168e-2) (-2.4319973e-2)),((V3 (-22.695969) 27.562899 38.368004,52.37195),V3 0.59706545 8.836004 6.6548023,V3 6.5704644e-2 8.678102e-4 1.2026024e-3)]
+t40 = fromList (Z :. 32) [((V3 91.697495 5.4155703 92.044914,3.456227),V3 10.316977 (-10.900996) 10.580583,V3 (-5.4984577e-2) (-5.759611e-3) (-2.0093894e-2)),((V3 8.514568 47.0469 51.09017,63.459526),V3 7.104572 6.4349384 7.2721677,V3 1.12648755e-2 (-3.332868e-2) 1.6347226e-3),((V3 48.651657 77.02288 (-119.434135),74.34554),V3 14.247916 1.5890028 (-13.2695875),V3 (-2.1358604e-2) (-2.0729013e-2) 2.6509188e-2),((V3 (-65.969284) 21.628542 (-49.99305),8.434827),V3 (-6.263674) 11.301711 (-6.48786),V3 4.0518373e-2 7.286787e-3 1.2429871e-2),((V3 20.796795 (-56.777897) 50.19909,16.776989),V3 (-4.0547376) (-10.752103) 6.8770275,V3 (-7.846622e-4) 3.7900403e-2 2.5655352e-2),((V3 97.3847 (-2.2081537) 90.70148,21.63172),V3 9.677236 (-12.346555) 10.308925,V3 (-5.978675e-2) 6.644931e-3 (-1.6574375e-2)),((V3 8.219228 44.739773 47.38899,69.831604),V3 6.738449 6.353192 6.8940797,V3 1.1111753e-2 (-2.6524562e-2) 1.0468326e-2),((V3 38.71502 81.41648 (-127.190926),66.98223),V3 13.780056 3.1223996 (-13.965635),V3 7.3537864e-3 (-3.1081533e-2) 4.456732e-2),((V3 (-47.112682) 35.39936 (-35.08761),23.477612),V3 (-2.8717735) 11.251528 (-4.852271),V3 2.6577218e-2 (-8.196353e-3) 6.7232624e-3),((V3 6.287464 (-63.808132) 110.52431,4.5274367),V3 (-7.2739043) (-7.97887) 13.102639,V3 2.0361908e-2 4.0780798e-2 (-5.1679e-2)),((V3 40.64508 (-7.651926) 98.07744,45.534313),V3 4.45779 (-6.0752378) 12.554097,V3 (-4.7569186e-4) 1.5253849e-2 (-4.3336727e-2)),((V3 21.084469 55.54065 42.98896,37.293446),V3 10.034918 5.639096 5.947337,V3 (-1.8082762e-2) (-4.9611334e-2) 1.6854208e-2),((V3 41.930336 58.84061 (-127.55019),52.771004),V3 11.617168 1.0442036 (-14.489118),V3 (-4.012311e-3) 2.7554316e-2 4.7043316e-2),((V3 (-63.16238) 18.20372 (-61.125805),83.92678),V3 (-6.2714214) 10.4755945 (-7.893672),V3 3.577896e-2 1.2664541e-2 2.32645e-2),((V3 16.78585 (-56.820793) 68.56295,13.032608),V3 (-4.816262) (-9.83716) 9.036822,V3 6.4066965e-3 3.8840972e-2 4.2562652e-3),((V3 108.03228 47.64052 142.84729,18.12446),V3 14.552307 (-8.91643) 14.636781,V3 (-3.12577e-2) (-2.3407878e-2) (-4.015102e-2)),((V3 20.96532 36.536415 79.20127,53.132633),V3 7.6217933 2.694405 10.593484,V3 (-1.5331376e-3) (-2.227648e-2) (-4.6305884e-2)),((V3 43.65871 75.22893 (-123.179535),94.62536),V3 13.601485 2.1059594 (-13.707001),V3 (-6.8961466e-3) (-1.5207153e-2) 3.6573946e-2),((V3 (-72.18996) 13.745907 (-50.40427),6.5728045),V3 (-7.8075924) 10.990235 (-6.4411592),V3 4.4698413e-2 1.6537784e-2 1.2498314e-2),((V3 8.618523 (-51.190758) 92.14716,53.180336),V3 (-5.290025) (-7.659791) 11.69547,V3 2.2915501e-2 3.331896e-2 (-3.3908583e-2)),((V3 62.51936 (-1.0741624) 96.802895,91.3407),V3 7.442807 (-7.9995756) 11.849421,V3 (-2.4826422e-2) 6.3129836e-3 (-3.5914797e-2)),((V3 5.697339 45.263023 62.241142,87.52959),V3 6.4931397 6.2767706 8.637129,V3 2.1570526e-2 (-3.091899e-2) (-2.4423473e-2)),((V3 36.184513 62.16168 (-94.16929),75.542244),V3 12.052404 2.8559704 (-11.456068),V3 3.9396686e-3 9.183076e-3 (-1.5204716e-2)),((V3 (-51.52961) 28.322126 (-60.61371),35.689384),V3 (-3.7955291) 10.512978 (-8.030145),V3 2.5527062e-2 5.251167e-4 2.2997385e-2),((V3 12.717247 (-60.291595) 83.543816,77.35545),V3 (-5.9573126) (-9.239835) 10.5491085,V3 1.3533689e-2 4.2462174e-2 (-2.025762e-2)),((V3 102.64048 (-24.12993) 80.671165,34.4798),V3 7.2656713 (-15.115608) 9.120109,V3 (-5.7862338e-2) 3.2016918e-2 (-1.9865108e-3)),((V3 14.522226 23.812027 40.597305,20.805649),V3 5.2898326 3.0440855 6.585962,V3 (-1.3282294e-3) 1.6567424e-2 2.7148526e-2),((V3 53.44085 75.44811 (-108.818886),58.3743),V3 14.664958 0.9954541 (-12.286937),V3 (-3.4582797e-2) (-1.7471505e-2) 1.7086626e-3),((V3 (-68.189735) 27.951857 (-15.010899),20.659788),V3 (-6.0217195) 12.520229 (-1.9862144),V3 4.6607077e-2 (-3.295843e-4) (-2.627628e-3)),((V3 13.844069 (-93.427414) 57.225677,82.26547),V3 (-10.180802) (-12.199761) 6.8579884,V3 5.057639e-3 5.7978097e-2 9.31179e-3),((V3 92.772194 6.4925504 91.69188,86.262726),V3 10.514038 (-10.920899) 10.516583,V3 (-5.5935867e-2) (-7.5338217e-3) (-1.9282315e-2)),((V3 (-22.069828) 36.397938 45.023678,52.37195),V3 0.66104734 8.83258 6.657023,V3 6.2330484e-2 (-6.367284e-3) 2.8503416e-3)]
+t50 = fromList (Z :. 32) [((V3 101.99071 (-5.4870133) 102.617195,3.456227),V3 10.265284 (-10.903558) 10.562952,V3 (-4.9000565e-2) (-3.3972552e-4) (-1.5734198e-2)),((V3 15.623246 53.467186 58.363354,63.459526),V3 7.112743 6.4028063 7.2746725,V3 5.9479624e-3 (-3.1028748e-2) 3.1013165e-3),((V3 62.889755 78.60331 (-132.69252),74.34554),V3 14.225896 1.5707291 (-13.24551),V3 (-2.2473829e-2) (-1.6414119e-2) 2.2224657e-2),((V3 (-72.21559) 32.932617 (-56.47607),8.434827),V3 (-6.2260547) 11.306083 (-6.4778924),V3 3.5342116e-2 2.3256044e-3 8.116115e-3),((V3 16.74215 (-67.514336) 57.08764,16.776989),V3 (-4.054191) (-10.718734) 6.902565,V3 1.2219967e-3 2.988921e-2 2.5324985e-2),((V3 107.036255 (-14.55062) 101.00365,21.63172),V3 9.621546 (-12.336401) 10.2946615,V3 (-5.2374657e-2) 1.2614721e-2 (-1.2493394e-2)),((V3 14.961885 51.081345 54.28809,69.831604),V3 6.7470284 6.327776 6.9055386,V3 6.794804e-3 (-2.4389178e-2) 1.2146068e-2),((V3 52.49822 84.525 (-141.1371),66.98223),V3 13.786882 3.0916724 (-13.922968),V3 6.465013e-3 (-3.053215e-2) 4.1216098e-2),((V3 (-49.973724) 46.646618 (-39.937595),23.477612),V3 (-2.849211) 11.241526 (-4.847935),V3 1.9487087e-2 (-1.1123189e-2) 2.607631e-3),((V3 (-0.9768374) (-71.77011) 123.6045,4.5274367),V3 (-7.2522144) (-7.942882) 13.053603,V3 2.2418443e-2 3.230849e-2 (-4.6956714e-2)),((V3 45.103493 (-13.720522) 110.613045,45.534313),V3 4.4600415 (-6.060778) 12.514094,V3 4.2852517e-3 1.3671357e-2 (-3.7366506e-2)),((V3 31.109907 61.158455 48.944256,37.293446),V3 10.0125475 5.5929227 5.9653625,V3 (-2.5414275e-2) (-4.334791e-2) 1.8791612e-2),((V3 53.54652 59.897755 (-142.01868),52.771004),V3 11.615888 1.0735046 (-14.443832),V3 9.178282e-4 3.0527089e-2 4.394864e-2),((V3 (-69.41846) 28.684185 (-69.00963),83.92678),V3 (-6.238167) 10.4856205 (-7.8724136),V3 3.125227e-2 8.188032e-3 1.9771319e-2),((V3 11.972829 (-66.64195) 77.602036,13.032608),V3 (-4.8088284) (-9.803157) 9.0422325,V3 7.842329e-3 3.029911e-2 6.2510986e-3),((V3 122.57083 38.71451 157.46681,18.12446),V3 14.522111 (-8.936715) 14.599252,V3 (-2.9246895e-2) (-1.7945994e-2) (-3.543596e-2)),((V3 28.585655 39.221703 89.77437,53.132633),V3 7.617787 2.675154 10.548599,V3 (-5.7717618e-3) (-1.6758509e-2) (-4.372806e-2)),((V3 57.25712 77.32852 (-136.8707),94.62536),V3 13.594677 2.092296 (-13.67248),V3 (-6.6718357e-3) (-1.2538318e-2) 3.296495e-2),((V3 (-79.97811) 24.74263 (-56.84053),6.5728045),V3 (-7.7651296) 11.003712 (-6.4310308),V3 4.0688474e-2 1.1308812e-2 8.347267e-3),((V3 3.339027 (-58.837246) 103.82801,53.180336),V3 (-5.2665424) (-7.632007) 11.663635,V3 2.3542905e-2 2.35395e-2 (-3.0227607e-2)),((V3 69.95202 (-9.070525) 108.63706,91.3407),V3 7.4213643 (-7.992147) 11.816503,V3 (-1.8806573e-2) 8.021819e-3 (-3.0572055e-2)),((V3 12.1992855 51.526188 70.86738,87.52959),V3 6.511814 6.246946 8.612987,V3 1.658094e-2 (-2.8778369e-2) (-2.3976022e-2)),((V3 48.23915 65.021935 (-105.63324),75.542244),V3 12.057885 2.865588 (-11.474666),V3 6.764085e-3 9.796099e-3 (-2.1098565e-2)),((V3 (-55.31476) 38.83461 (-68.63411),35.689384),V3 (-3.7736616) 10.51119 (-8.009105),V3 1.897558e-2 (-3.3548211e-3) 1.9611102e-2),((V3 6.7664723 (-69.51381) 94.08433,77.35545),V3 (-5.94245) (-9.202252) 10.5306015,V3 1.552987e-2 3.384546e-2 (-1.7154729e-2)),((V3 109.88197 (-39.230373) 89.79093,34.4798),V3 7.213953 (-15.081241) 9.119863,V3 (-4.688688e-2) 3.580751e-2 1.0214294e-3),((V3 19.81148 26.864025 47.19544,20.805649),V3 5.2886024 3.0621727 6.6129193,V3 (-1.0406151e-3) 1.931533e-2 2.666069e-2),((V3 68.09002 76.436745 (-121.10601),58.3743),V3 14.629651 0.981356 (-12.2883415),V3 (-3.5781976e-2) (-1.1530216e-2) (-3.7686753e-3)),((V3 (-74.19182) 40.471096 (-16.998747),20.659788),V3 (-5.9795036) 12.51725 (-1.9902846),V3 3.881838e-2 (-4.720899e-3) (-5.0941026e-3)),((V3 3.666522 (-105.60259) 64.088,82.26547),V3 (-10.17266) (-12.1467285) 6.8677063,V3 1.0192296e-2 4.9138103e-2 9.935473e-3),((V3 103.26202 (-4.430718) 102.20054,86.262726),V3 10.461283 (-10.925178) 10.499763,V3 (-5.0150417e-2) (-2.012527e-3) (-1.4929474e-2)),((V3 (-21.381445) 45.226868 51.68212,52.37195),V3 0.7209554 8.823734 6.660278,V3 5.781613e-2 (-1.05035845e-2) 3.476929e-3)]
 
diff --git a/examples/pagerank/Load.hs b/examples/pagerank/Load.hs
--- a/examples/pagerank/Load.hs
+++ b/examples/pagerank/Load.hs
@@ -13,16 +13,16 @@
 
 -- | Load the whole page graph into memory.
 loadPages
-        :: FilePath             -- ^ Pages file.
-        -> PageId               -- ^ Maximum page number
-        -> IO ( V.Vector PageId -- ^ From vector
-              , V.Vector PageId -- ^ To vector
-              , V.Vector Int    -- ^ Degrees (number of outgoing links) for each page
+        :: FilePath             -- Pages file.
+        -> PageId               -- Maximum page number
+        -> IO ( V.Vector PageId -- From vector
+              , V.Vector PageId -- To vector
+              , V.Vector Int    -- Degrees (number of outgoing links) for each page
               )
 
 loadPages filePath maxPageId
  = do
-        -- Lazilly read the pages files.
+        -- Lazily read the pages files.
         bs              <- BL.readFile filePath
 
         -- Create an initial vector to hold the pages.
diff --git a/examples/pagerank/Rank.hs b/examples/pagerank/Rank.hs
--- a/examples/pagerank/Rank.hs
+++ b/examples/pagerank/Rank.hs
@@ -12,7 +12,7 @@
 import Step
 
 import Data.Array.Accelerate                            as A
-import Data.Array.Accelerate.Array.Sugar                as A ( EltRepr )
+import Data.Array.Accelerate.Sugar.Elt                  as A
 import Data.Array.Accelerate.Examples.Internal          as A
 import Data.Array.Accelerate.IO.Data.Vector.Storable    as A
 
@@ -23,7 +23,7 @@
 
 
 arrayize
-    :: (Vectors (EltRepr e) ~ S.Vector a, Elt e, S.Storable a)
+    :: (Vectors (EltR e) ~ S.Vector a, Elt e, S.Storable a)
     => S.Vector a
     -> Vector e
 arrayize vec = (A.fromVectors (Z :. S.length vec) vec)
diff --git a/examples/pagerank/Step.hs b/examples/pagerank/Step.hs
--- a/examples/pagerank/Step.hs
+++ b/examples/pagerank/Step.hs
@@ -72,6 +72,6 @@
 
         -- Add to the partial ranks the contribution of the supplied links.
         ranks' = A.permute (+) parRanks (\ix -> let (_, to) = unlift $ links ! ix :: (Exp PageId, Exp PageId)
-                                              in index1 (A.fromIntegral to)) contribution
+                                                 in Just_ (index1 (A.fromIntegral to))) contribution
         in ranks'
 
diff --git a/examples/quicksort/Config.hs b/examples/quicksort/Config.hs
new file mode 100644
--- /dev/null
+++ b/examples/quicksort/Config.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Config where
+
+import Data.Label
+import System.Console.GetOpt
+
+
+data Config
+  = Config
+  { _configRandomSize :: Maybe Int
+  }
+
+$(mkLabels [''Config])
+
+defaults :: Config
+defaults = Config Nothing
+
+options :: [OptDescr (Config -> Config)]
+options =
+  [ Option [] ["size"] (ReqArg (set configRandomSize . Just . read) "INT") "number of elements for a random input"
+  ]
+
+
+header :: [String]
+header =
+  [ "accelerate-quicksort (c) [2019] The Accelerate Team"
+  , ""
+  , "Usage: accelerate-quicksort input.txt"
+  , "  where input.txt is a file containing a list of integers seperated by spaces"
+  , ""
+  , "Usage: accelerate-quicksort --size n"
+  , "  where n is a number, denoting the size of a random input"
+  , ""
+  ]
+
+footer :: [String]
+footer = [ "" ]
+
diff --git a/examples/quicksort/Main.hs b/examples/quicksort/Main.hs
new file mode 100644
--- /dev/null
+++ b/examples/quicksort/Main.hs
@@ -0,0 +1,60 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module Main where
+
+import Config
+import QuickSort
+
+import Control.Monad
+import Data.Array.IO
+import Data.Label
+import Data.Maybe
+import System.Random
+import Text.Read (readMaybe)
+
+import Data.Array.Accelerate.Examples.Internal
+import qualified Data.Array.Accelerate                              as A
+
+main :: IO ()
+main = do
+  beginMonitoring
+  (conf, opts, rest) <- parseArgs options defaults header footer
+  let qsort = quicksort $ get optBackend opts
+
+  case (get configRandomSize conf, rest) of
+    (Nothing, [path]) -> do
+      -- Read input from file
+      file <- readFile path
+      let input = map (fromMaybe (error "Parse error. Input file should contain integers separated by spaces") . readMaybe) $ words file
+      let result = A.toList $ qsort $ A.fromList (A.Z A.:. length input) input
+      putStrLn $ unwords $ map show result
+    (Just size, _) -> do
+      -- Do multiple runs using a random input
+      -- For later runs, the program does not have to be recompiled
+      replicateM_ 10 $ randomRun qsort size
+    _ -> do
+      putStrLn "Usage: accelerate-quicksort input.txt"
+      putStrLn "Or:    accelerate-quicksort --size 1000"
+
+randomRun :: (A.Vector Int -> A.Vector Int) -> Int -> IO ()
+randomRun qsort size = do
+  putStrLn $ "Sorting " ++ show size ++ " elements"
+  input <- shuffle [1 .. size]
+  let result = A.toList $ qsort $ A.fromList (A.Z A.:. length input) input
+  putStrLn $ unwords (map show $ take 30 result) ++ (if size <= 30 then "" else " ...")
+  putStrLn ""
+
+-- | /O(N)/ Randomly shuffle a list
+-- From https://wiki.haskell.org/Random_shuffle
+--
+shuffle :: forall a. [a] -> IO [a]
+shuffle xs = do
+  let n = length xs
+  ar <- newListArray (1,n) xs :: IO (IOArray Int a)
+  forM [1..n] $ \i -> do
+      j <- randomRIO (i,n)
+      vi <- readArray ar i
+      vj <- readArray ar j
+      writeArray ar j vi
+      return vj
+
diff --git a/examples/quicksort/QuickSort.hs b/examples/quicksort/QuickSort.hs
new file mode 100644
--- /dev/null
+++ b/examples/quicksort/QuickSort.hs
@@ -0,0 +1,155 @@
+{-# LANGUAGE FlexibleContexts    #-}
+{-# LANGUAGE FlexibleInstances   #-}
+{-# LANGUAGE RebindableSyntax    #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module QuickSort (quicksort) where
+
+import Data.Array.Accelerate
+import Data.Array.Accelerate.Unsafe
+import Data.Array.Accelerate.Data.Bits
+import Data.Array.Accelerate.Examples.Internal
+
+
+quicksort :: Backend -> Vector Int -> Vector Int
+quicksort backend = runN backend quicksort'
+
+quicksort' :: Ord a => Acc (Vector a) -> Acc (Vector a)
+quicksort' input = result
+  where
+    -- Initially, we have one segment, namely the whole array
+    initialFlags = scatter (fill (I1 1) 0 ++ fill (I1 1) (length input)) emptyFlags fullFlags
+    emptyFlags   = fill (I1 (1 + length input)) False_
+    fullFlags    = fill (I1 2) True_
+
+    -- We stop when each segment contains just one element, as segments of
+    -- one element are sorted.
+    T2 result _ = awhile condition step $ T2 input initialFlags
+
+type State a =
+  ( Vector a      -- Values
+  , Vector Bool   -- Head flags, denoting the starting points of the unsorted segments
+  )
+
+step :: Ord a => Acc (State a) -> Acc (State a)
+step (T2 values headFlags) = (T2 values' headFlags')
+  where
+    -- Per element, the pivot of the segment of that element
+    -- For each segment, we just take the first element as pivot
+    pivots = propagateSegmentHead headFlags values
+
+    -- Find which elements are larger than the pivot
+    isLarger = zipWith (>=) values pivots
+
+    -- Propagate the start index of a segment to all elements
+    startIndex = propagateSegmentHead headFlags (generate (shape values) unindex1)
+
+    -- Compute the offsets to which the elements must be moved using a scan
+    indicesLarger, indicesSmaller :: Acc (Vector Int)
+    indicesLarger  = map (\x -> x - 1) $ postscanSegHead (+) headFlags $ map (? (1, 0)) isLarger
+    indicesSmaller = map (\x -> x - 1) $ postscanSegHead (+) headFlags $ map (? (0, 1)) isLarger
+
+    -- Propagate the number of smaller elements to each segment
+    -- This is needed as an offset for the larger elements
+    countSmaller :: Acc (Vector Int)
+    countSmaller = map (+1) $ propagateSegmentLast headFlags indicesSmaller
+
+    -- Compute the new indices of the elements
+    permutation = zipWith5 partitionPermuteIndex isLarger startIndex indicesSmaller indicesLarger countSmaller
+
+    -- Perform the permutation
+    values' = scatter permutation (fill (shape values) undef) values
+
+    -- Update the head flags for the next iteration (the 'recursive call' in a traditional implementation)
+    -- Mark new section starts at:
+    --  * the position of the pivot
+    --  * the position of the pivot + 1
+    headFlags' =
+      let
+          f :: Int -> Exp Bool -> Exp Int -> Exp Int -> Exp (Maybe DIM1)
+          f inc headF start countSmall =
+            headF ? (Just_ (I1 $ start + countSmall + constant inc), Nothing_)
+
+          writes :: Int -> Acc (Vector (Maybe DIM1))
+          writes inc = zipWith3 (f inc) headFlags startIndex countSmaller
+      in
+      -- Note that (writes 1) may go out of bounds of the values array.
+      -- We made the headFlags array one larger, such that this gives no problems.
+      writeFlags (writes 0) $ writeFlags (writes 1) $ headFlags
+
+-- Checks whether all segments have length 1. If that is the case, then the
+-- loop may terminate.
+--
+condition :: Elt a => Acc (State a) -> Acc (Scalar Bool)
+condition (T2 _ headFlags) = map not $ fold (&&) True_ headFlags
+
+-- Finds the new index of an element of the list, as the result of the
+-- partition
+--
+partitionPermuteIndex :: Exp Bool -> Exp Int -> Exp Int -> Exp Int -> Exp Int -> Exp Int
+partitionPermuteIndex isLarger start indexIfSmaller indexIfLarger countSmaller =
+  start + (isLarger ? (countSmaller + indexIfLarger, indexIfSmaller))
+
+-- Given head flags, propagates the value of the head to all elements in
+-- the segment
+--
+propagateSegmentHead
+    :: Elt a
+    => Acc (Vector Bool)
+    -> Acc (Vector a)
+    -> Acc (Vector a)
+propagateSegmentHead headFlags values
+  = map fst
+  $ postscanl f (T2 undef True_)
+  $ zip values headFlags
+  where
+    f left (T2 rightValue rightFlag) =
+      if rightFlag
+         then T2 rightValue True_
+         else left
+
+-- Given head flags, propagates the value of the head to all elements in
+-- the segment
+--
+propagateSegmentLast
+    :: Elt a
+    => Acc (Vector Bool)
+    -> Acc (Vector a)
+    -> Acc (Vector a)
+propagateSegmentLast headFlags values
+  = map fst
+  $ postscanr f (T2 undef True_)
+  $ zip values
+  $ tail headFlags
+  where
+    f (T2 leftValue leftFlag) right =
+      if leftFlag
+         then T2 leftValue True_
+         else right
+
+-- Segmented postscan, where the segments are defined with head flags
+--
+postscanSegHead
+    :: Elt a
+    => (Exp a -> Exp a -> Exp a)
+    -> Acc (Vector Bool)
+    -> Acc (Vector a)
+    -> Acc (Vector a)
+postscanSegHead f headFlags values
+  = map fst
+  $ postscanl g (T2 undef True_)
+  $ zip values headFlags
+  where
+    g (T2 leftValue leftFlag) (T2 rightValue rightFlag)
+      = T2
+          (rightFlag ? (rightValue, f leftValue rightValue))
+          (leftFlag .|. rightFlag)
+
+-- Writes True to the specified indices in a flags arrays
+--
+writeFlags
+    :: Acc (Vector (Maybe DIM1))
+    -> Acc (Vector Bool)
+    -> Acc (Vector Bool)
+writeFlags writes flags = permute const flags (writes !) (fill (shape writes) True_)
+
diff --git a/examples/ray/Common/Type.hs b/examples/ray/Common/Type.hs
--- a/examples/ray/Common/Type.hs
+++ b/examples/ray/Common/Type.hs
@@ -10,5 +10,5 @@
 
 type Position     = V3 Float
 type Direction    = V3 Float
-type Noraml       = (Position, Direction)
+type Normal       = (Position, Direction)
 
diff --git a/examples/ray/Gloss/Draw.hs b/examples/ray/Gloss/Draw.hs
--- a/examples/ray/Gloss/Draw.hs
+++ b/examples/ray/Gloss/Draw.hs
@@ -10,7 +10,7 @@
 import Ray.Trace
 
 -- frenemies
-import Data.Array.Accelerate                                    as A
+import Data.Array.Accelerate                                    as A hiding ( V3 )
 import Data.Array.Accelerate.Data.Colour.RGB                    as RGB
 import Data.Array.Accelerate.Linear.Metric
 import qualified Data.Array.Accelerate.Data.Colour.RGBA         as RGBA
@@ -56,7 +56,7 @@
 
         (x,y)           = xyOfPoint point
 
-        eyeDir          = normalize $ lift (V3 (x * fovX) ((-y) * fovY) 0) - eyePos
+        eyeDir          = normalize $ lift (V3 (x * fovX) (y * fovY) 0) - eyePos
         eyePos          = the eyePos'
         (objects, lights, eyePos')
                         = unlift state
diff --git a/examples/ray/Ray/Trace.hs b/examples/ray/Ray/Trace.hs
--- a/examples/ray/Ray/Trace.hs
+++ b/examples/ray/Ray/Trace.hs
@@ -10,7 +10,7 @@
 import Ray.Intersect
 
 -- frenemies
-import Data.Array.Accelerate                                    as A
+import Data.Array.Accelerate                                    as A hiding ( V3 )
 import Data.Array.Accelerate.Data.Colour.RGB                    as RGB
 import Data.Array.Accelerate.Data.Colour.Names
 import Data.Array.Accelerate.Linear.Metric
@@ -41,7 +41,7 @@
     in
     A.generate (constant (Z :. sizeY :. sizeX))
                (\ix -> let (x, y) = xyOfPoint $ pointOfIndex sizeX sizeY ix
-                       in  normalize $ lift (V3 (x * fovX) ((-y) * fovY) 0) - eyePos)
+                       in  normalize $ lift (V3 (x * fovX) (y * fovY) 0) - eyePos)
 
 
 -- | Cast a single ray into the scene
@@ -58,8 +58,8 @@
   where
     (spheres, planes)   = unlift objects
 
-    dummySphere         = constant (Sphere (V3 0 0 0) 0          (RGB 0 0 0) 0)
-    dummyPlane          = constant (Plane  (V3 0 0 0) (V3 0 0 1) (RGB 0 0 0) 0)
+    dummySphere         = constant (Sphere_ (V3 0 0 0) 0          (RGB 0 0 0) 0)
+    dummyPlane          = constant (Plane_  (V3 0 0 0) (V3 0 0 1) (RGB 0 0 0) 0)
 
     -- Stop once there are too many reflections, in case we've found two
     -- parallel mirrors.
diff --git a/examples/ray/Scene/Light.hs b/examples/ray/Scene/Light.hs
--- a/examples/ray/Scene/Light.hs
+++ b/examples/ray/Scene/Light.hs
@@ -1,8 +1,7 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# LANGUAGE UndecidableInstances  #-}
+{-# LANGUAGE DeriveAnyClass    #-}
+{-# LANGUAGE DeriveGeneric     #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE PatternSynonyms   #-}
 
 module Scene.Light
   where
@@ -19,25 +18,18 @@
 import Data.Array.Accelerate.Linear.Metric
 import Data.Array.Accelerate.Linear.Vector
 
-import Data.Array.Accelerate.Array.Sugar                        ( Elt(..), EltRepr, Tuple(..), fromTuple, toTuple )
-import Data.Array.Accelerate.Product
-import Data.Array.Accelerate.Smart
 
--- standard library
-import Data.Typeable
-import qualified Prelude                                        as P
-
-
 -- | An omnidirectional point light source, whose intensity drops off with
 --   distance from the source.
 --
-data Light = Light Position Colour
-  deriving (P.Eq, P.Show, Typeable)
+data Light = Light_ Position Colour
+  deriving (Show, Generic, Elt)
 
 type Lights = Array DIM1 Light
 
-lightPos   :: Exp Light -> Exp Position
-lightColor :: Exp Light -> Exp Colour
+pattern Light :: Exp Position -> Exp Colour -> Exp Light
+pattern Light { lightPos, lightColor } = Pattern (lightPos, lightColor)
+{-# COMPLETE Light #-}
 
 
 -- | Compute the direct lighting contribution of all lights acting on a point on
@@ -89,28 +81,4 @@
     in
     checkRay distanceToSphere spheres point dir dist || checkRay distanceToPlane planes point dir dist
       ? ( constant black, refl )
-
-
-
--- Get Lights into Accelerate --------------------------------------------------
-
-lightPos l   = Exp $ SuccTupIdx ZeroTupIdx `Prj` l
-lightColor l = Exp $ ZeroTupIdx `Prj` l
-
-type instance EltRepr Light = EltRepr (Position, Colour)
-
-instance Elt Light where
-  eltType (_ :: Light)  = eltType (undefined :: (Position, Colour))
-  toElt light           = let (p,c) = toElt light in Light p c
-  fromElt (Light p c)   = fromElt (p,c)
-
-instance IsProduct Elt Light where
-  type ProdRepr Light     = ProdRepr (Position, Colour)
-  fromProd _ (Light p c)  = fromTuple (p,c)
-  toProd _ t              = let (p,c) = toTuple t in Light p c
-  prod cst _              = prod cst (undefined :: (Position, Colour))
-
-instance Lift Exp Light where
-  type Plain Light = Light
-  lift (Light p c) = Exp . Tuple $ NilTup `SnocTup` lift p `SnocTup` lift c
 
diff --git a/examples/ray/Scene/Object.hs b/examples/ray/Scene/Object.hs
--- a/examples/ray/Scene/Object.hs
+++ b/examples/ray/Scene/Object.hs
@@ -1,8 +1,6 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# LANGUAGE UndecidableInstances  #-}
+{-# LANGUAGE DeriveAnyClass  #-}
+{-# LANGUAGE DeriveGeneric   #-}
+{-# LANGUAGE PatternSynonyms #-}
 
 module Scene.Object
   where
@@ -14,46 +12,37 @@
 import Data.Array.Accelerate                                    as A
 import Data.Array.Accelerate.Control.Lens
 import Data.Array.Accelerate.Data.Bits
+import Data.Array.Accelerate.Data.Colour.RGB
 import Data.Array.Accelerate.Linear.Metric
 import Data.Array.Accelerate.Linear.V3
 import Data.Array.Accelerate.Linear.Vector
 
-import Data.Array.Accelerate.Array.Sugar                        ( Elt(..), EltRepr, Tuple(..), fromTuple, toTuple )
-import Data.Array.Accelerate.Product
-import Data.Array.Accelerate.Smart
-
-import Data.Array.Accelerate.Data.Colour.RGB
-
 -- standard library
-import Data.Typeable
 import qualified Prelude                                        as P
 
 
 -- | All objects in the scene
 --
-type Objects = (Array DIM1 Sphere, Array DIM1 Plane)
-
+type Objects = (Vector Sphere, Vector Plane)
 
 -- | Objects in the world. Accelerate does not have sum types, so define each
 --   object separately (and hope this works out...)
 --
-data Sphere = Sphere Position Float Colour Float
-  deriving (P.Eq, P.Show, Typeable)
-
-spherePos    :: Exp Sphere -> Exp Position
-sphereColor  :: Exp Sphere -> Exp Colour
-sphereShine  :: Exp Sphere -> Exp Float
-sphereRadius :: Exp Sphere -> Exp Float
-
+data Sphere = Sphere_ Position Float Colour Float
+  deriving (Show, Generic, Elt)
 
-data Plane = Plane Position Direction Colour Float
-  deriving (P.Eq, P.Show, Typeable)
+data Plane = Plane_ Position Direction Colour Float
+  deriving (Show, Generic, Elt)
 
-planePos    :: Exp Plane -> Exp Position
-planeNormal :: Exp Plane -> Exp Direction
-planeColor  :: Exp Plane -> Exp Colour
-planeShine  :: Exp Plane -> Exp Float
+pattern Sphere :: Exp Position -> Exp Float -> Exp Colour -> Exp Float -> Exp Sphere
+pattern Sphere { spherePos, sphereRadius, sphereColor, sphereShine } =
+  Pattern ( spherePos, sphereRadius, sphereColor, sphereShine )
+{-# COMPLETE Sphere #-}
 
+pattern Plane :: Exp Position -> Exp Direction -> Exp Colour -> Exp Float -> Exp Plane
+pattern Plane { planePos, planeNormal, planeColor, planeShine } =
+  Pattern ( planePos, planeNormal, planeColor, planeShine )
+{-# COMPLETE Plane #-}
 
 type PlaneCheck = Plane
 
@@ -61,7 +50,11 @@
 planeCheckNormal :: Exp PlaneCheck -> Exp Direction
 planeCheckShine  :: Exp PlaneCheck -> Exp Float
 
+planeCheckPos    = planePos
+planeCheckNormal = planeNormal
+planeCheckShine  = planeShine
 
+
 -- | Compute the distance to the surface of a sphere
 --
 distanceToSphere
@@ -138,95 +131,4 @@
     v1 `xor` v2 `xor` v3 `xor` v4 == 1 {- True -}
       ? ( rgb 1.0 1.0 1.0
         , rgb 0.4 0.4 0.4 )
-
-
--- Get Objects into Accelerate -------------------------------------------------
-
--- Because the Object types aren't parameterised, the type of the individual
--- fields are fixed. Thus we can't unlift from (Exp Sphere) to a Sphere of Exp
--- things. Poop.
---
-spherePos s    = Exp $ SuccTupIdx (SuccTupIdx (SuccTupIdx ZeroTupIdx)) `Prj` s
-sphereRadius s = Exp $ SuccTupIdx (SuccTupIdx ZeroTupIdx) `Prj` s
-sphereColor s  = Exp $ SuccTupIdx ZeroTupIdx `Prj` s
-sphereShine s  = Exp $ ZeroTupIdx `Prj` s
-
-planePos p    = Exp $ SuccTupIdx (SuccTupIdx (SuccTupIdx ZeroTupIdx)) `Prj` p
-planeNormal p = Exp $ SuccTupIdx (SuccTupIdx ZeroTupIdx) `Prj` p
-planeColor p  = Exp $ SuccTupIdx ZeroTupIdx `Prj` p
-planeShine p  = Exp $ ZeroTupIdx `Prj` p
-
-planeCheckPos    = planePos
-planeCheckNormal = planeNormal
-planeCheckShine  = planeShine
-
-
--- Sphere
--- ------
-
-type instance EltRepr Sphere = EltRepr (Position, Float, Colour, Float)
-
-instance Elt Sphere where
-  eltType (_ :: Sphere)         = eltType (undefined :: (Position, Float, Colour, Float))
-  toElt sphere                  = let (p,r,c,s) = toElt sphere in Sphere p r c s
-  fromElt (Sphere p r c s)      = fromElt (p, r, c, s)
-
-instance IsProduct Elt Sphere where
-  type ProdRepr Sphere = ProdRepr (Position, Float, Colour, Float)
-  fromProd _ (Sphere p r c s)    = fromTuple (p, r, c, s)
-  toProd _ t                     = let (p, r, c, s) = toTuple t in Sphere p r c s
-  prod cst _                     = prod cst (undefined :: (Position, Float, Colour, Float))
-
-instance Lift Exp Sphere where
-  type Plain Sphere = Sphere
-  lift (Sphere p r c s)
-      = Exp . Tuple
-      $ NilTup `SnocTup` lift p `SnocTup` lift r `SnocTup` lift c `SnocTup` lift s
-
-
--- Plane
--- -----
-
-type instance EltRepr Plane = EltRepr (Position, Direction, Colour, Float)
-
-instance Elt Plane where
-  eltType (_ :: Plane)          = eltType (undefined :: (Position, Direction, Colour, Float))
-  toElt plane                   = let (p,n,c,s) = toElt plane in Plane p n c s
-  fromElt (Plane p n c s)       = fromElt (p, n, c, s)
-
-instance IsProduct Elt Plane where
-  type ProdRepr Plane           = ProdRepr (Position, Direction, Colour, Float)
-  fromProd _ (Plane p n c s)    = fromTuple (p, n, c, s)
-  toProd _ t                    = let (p, n, c, s) = toTuple t in Plane p n c s
-  prod cst _                    = prod cst (undefined :: (Position, Direction, Colour, Float))
-
-instance Lift Exp Plane where
-  type Plain Plane = Plane
-  lift (Plane p n c s)
-      = Exp . Tuple
-      $ NilTup `SnocTup` lift p `SnocTup` lift n `SnocTup` lift c `SnocTup` lift s
-
-
-{--
--- Checkered Plane
--- ---------------
-
-type instance EltRepr PlaneCheck = EltRepr (Position, Direction, Float)
-
-instance Elt PlaneCheck where
-  eltType (_ :: PlaneCheck)     = eltType (undefined :: (Position, Direction, Float))
-  toElt plane                   = let (p,n,s) = toElt plane in PlaneCheck p n s
-  fromElt (PlaneCheck p n s)    = fromElt (p, n, s)
-
-instance IsTuple PlaneCheck where
-  type TupleRepr PlaneCheck = TupleRepr (Position, Direction, Float)
-  fromTuple (PlaneCheck p n s)  = fromTuple (p, n, s)
-  toTuple t                     = let (p, n, s) = toTuple t in PlaneCheck p n s
-
-instance Lift Exp PlaneCheck where
-  type Plain PlaneCheck = PlaneCheck
-  lift (PlaneCheck p n s)
-      = Exp . Tuple
-      $ NilTup `SnocTup` lift p `SnocTup` lift n `SnocTup` lift s
---}
 
diff --git a/examples/ray/Scene/State.hs b/examples/ray/Scene/State.hs
--- a/examples/ray/Scene/State.hs
+++ b/examples/ray/Scene/State.hs
@@ -10,7 +10,7 @@
 import Scene.World
 
 -- frenemies
-import Data.Array.Accelerate                                    as A
+import Data.Array.Accelerate                                    as A hiding ( V3 )
 
 -- library
 import Prelude                                                  hiding ( (.), id )
@@ -108,11 +108,11 @@
 
 translateObjects :: Position -> Objects -> Objects
 translateObjects v (spheres, planes)
-  = ( fromList (arrayShape spheres) [ Sphere (p + v) r c s | Sphere p r c s <- toList spheres ]
-    , fromList (arrayShape planes)  [ Plane  (p + v) d c s | Plane  p d c s <- toList planes  ]
+  = ( fromList (arrayShape spheres) [ Sphere_ (p + v) r c s | Sphere_ p r c s <- toList spheres ]
+    , fromList (arrayShape planes)  [ Plane_  (p + v) d c s | Plane_  p d c s <- toList planes  ]
     )
 
 translateLights :: Position -> Lights -> Lights
 translateLights v lights
-  = fromList (arrayShape lights) [ Light (p + v) c | Light p c <- toList lights ]
+  = fromList (arrayShape lights) [ Light_ (p + v) c | Light_ p c <- toList lights ]
 
diff --git a/examples/ray/Scene/World.hs b/examples/ray/Scene/World.hs
--- a/examples/ray/Scene/World.hs
+++ b/examples/ray/Scene/World.hs
@@ -6,46 +6,46 @@
 import Scene.Object
 
 -- frenemies
-import Data.Array.Accelerate                                    as A
+import Data.Array.Accelerate                                    as A hiding ( V3 )
 import Data.Array.Accelerate.Data.Colour.RGB
 
 
 makeLights :: Float -> Lights
 makeLights _time
-  = A.fromList (Z :. 1) [ Light (V3 300 (-300) (-100))
-                                (RGB 150000 150000 150000)
+  = A.fromList (Z :. 1) [ Light_ (V3 300 (-300) (-100))
+                                 (RGB 150000 150000 150000)
                         ]
 
 makeObjects :: Float -> Objects
 makeObjects time
   = let
         spheres = A.fromList (Z :. 4)
-          [ Sphere (V3 (40 * sin time) 80 0.0)
-                   20
-                   (RGB 1.0 0.3 1.0)
-                   0.4
+          [ Sphere_ (V3 (40 * sin time) 80 0.0)
+                    20
+                    (RGB 1.0 0.3 1.0)
+                    0.4
 
-          , Sphere (V3 (200 * sin time) (-40 * sin (time + pi/2)) (200 * cos time))
-                   100.0
-                   (RGB 0.4 0.4 1.0)
-                   0.8
+          , Sphere_ (V3 (200 * sin time) (-40 * sin (time + pi/2)) (200 * cos time))
+                    100.0
+                    (RGB 0.4 0.4 1.0)
+                    0.8
 
-          , Sphere (V3 (-200.0 * sin time) (-40 * sin (time - pi/2)) (-200 * cos time))
-                   100.0
-                   (RGB 0.4 0.4 1.0)
-                   0.5
+          , Sphere_ (V3 (-200.0 * sin time) (-40 * sin (time - pi/2)) (-200 * cos time))
+                    100.0
+                    (RGB 0.4 0.4 1.0)
+                    0.5
 
-          , Sphere (V3 0.0 (-150.0) (-100.0))
-                   50.0
-                   (RGB 1.0 1.0 1.0)
-                   0.8
+          , Sphere_ (V3 0.0 (-150.0) (-100.0))
+                    50.0
+                    (RGB 1.0 1.0 1.0)
+                    0.8
           ]
 
         planes = A.fromList (Z :. 1)
-          [ Plane (V3 0.0 100.0 0.0)
-                  (V3 0.0 (-0.9805807) (-0.19611613))
-                  (RGB 1.0 1.0 1.0)
-                  0.2
+          [ Plane_ (V3 0.0 100.0 0.0)
+                   (V3 0.0 (-0.9805807) (-0.19611613))
+                   (RGB 1.0 1.0 1.0)
+                   0.2
           ]
     in
     (spheres, planes)
diff --git a/examples/smoothlife/Main.hs b/examples/smoothlife/Main.hs
--- a/examples/smoothlife/Main.hs
+++ b/examples/smoothlife/Main.hs
@@ -11,6 +11,7 @@
 -- system
 import Prelude                                          as P
 import Data.Array.Accelerate                            as A
+import Data.Array.Accelerate.System.Random.MWC          as A
 import Data.Array.Accelerate.Examples.Internal          as A
 import Data.Label
 import Control.Exception
@@ -41,7 +42,7 @@
 
         -- initialise with patches of random data
         dots    <- randomCircles dish ra rb
-        agar    <- randomArrayWithSystemRandom (splat dots) dish
+        agar    <- randomArray (splat dots) dish
 
         world   <- evaluate (advance agar)
 
diff --git a/examples/smoothlife/Random/Splat.hs b/examples/smoothlife/Random/Splat.hs
--- a/examples/smoothlife/Random/Splat.hs
+++ b/examples/smoothlife/Random/Splat.hs
@@ -8,7 +8,7 @@
 import Control.Monad
 import System.Random.MWC
 import Data.Array.Accelerate                            ( DIM2, Z(..), (:.)(..) )
-import Data.Array.Accelerate.Examples.Internal          ( (:~>) )
+import Data.Array.Accelerate.System.Random.MWC          ( (:~>) )
 
 
 -- Generate a random point on the grid by checking which circles it overlaps.
diff --git a/examples/tunnel/Main.hs b/examples/tunnel/Main.hs
--- a/examples/tunnel/Main.hs
+++ b/examples/tunnel/Main.hs
@@ -12,7 +12,7 @@
 
 import Data.Label
 
-import Data.Array.Accelerate                                        as A hiding ( clamp )
+import Data.Array.Accelerate                                        as A hiding ( clamp, V2, V3 )
 import Data.Array.Accelerate.Examples.Internal                      as A
 
 import Data.Array.Accelerate.Linear.Metric
diff --git a/lib/Data/Array/Accelerate/Examples/Internal.hs b/lib/Data/Array/Accelerate/Examples/Internal.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal.hs
@@ -1,10 +1,10 @@
 {-# OPTIONS_HADDOCK hide #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
@@ -20,7 +20,6 @@
   module Data.Array.Accelerate.Examples.Internal.Interactive,
   module Data.Array.Accelerate.Examples.Internal.TestFramework,
   module Data.Array.Accelerate.Examples.Internal.Monitoring,
-  module Data.Array.Accelerate.Examples.Internal.Random.Array,
   module Data.Array.Accelerate.Examples.Internal.Util,
 
 ) where
@@ -29,8 +28,6 @@
 import Data.Array.Accelerate.Examples.Internal.Interactive
 import Data.Array.Accelerate.Examples.Internal.Monitoring
 import Data.Array.Accelerate.Examples.Internal.ParseArgs
-import Data.Array.Accelerate.Examples.Internal.Random.Array
-import Data.Array.Accelerate.Examples.Internal.Similar
 import Data.Array.Accelerate.Examples.Internal.TestFramework
 import Data.Array.Accelerate.Examples.Internal.Util
 
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Backend.hs b/lib/Data/Array/Accelerate/Examples/Internal/Backend.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/Backend.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/Backend.hs
@@ -3,10 +3,10 @@
 {-# LANGUAGE TypeOperators #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.Backend
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
@@ -22,7 +22,8 @@
 import System.Console.GetOpt
 
 import Data.Array.Accelerate
-import Data.Array.Accelerate.Trafo                                  ( Afunction, AfunctionR )
+import Data.Array.Accelerate.Trafo                                  ( Afunction )
+import Data.Array.Accelerate.Trafo.Sharing                          ( AfunctionR )
 import qualified Data.Array.Accelerate.Interpreter                  as Interp
 #ifdef ACCELERATE_LLVM_NATIVE_BACKEND
 import qualified Data.Array.Accelerate.LLVM.Native                  as CPU
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Codespeed.hs b/lib/Data/Array/Accelerate/Examples/Internal/Codespeed.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/Codespeed.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/Codespeed.hs
@@ -6,10 +6,10 @@
 {-# LANGUAGE TupleSections       #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.Codespeed
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Criterion.hs b/lib/Data/Array/Accelerate/Examples/Internal/Criterion.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/Criterion.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/Criterion.hs
@@ -1,10 +1,10 @@
 {-# LANGUAGE CPP #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.Criterion
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Criterion/Config.hs b/lib/Data/Array/Accelerate/Examples/Internal/Criterion/Config.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/Criterion/Config.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/Criterion/Config.hs
@@ -3,10 +3,10 @@
 {-# LANGUAGE TypeOperators   #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.Criterion.Config
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Interactive.hs b/lib/Data/Array/Accelerate/Examples/Internal/Interactive.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/Interactive.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/Interactive.hs
@@ -1,10 +1,10 @@
 {-# LANGUAGE CPP #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.Interactive
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Monitoring.hs b/lib/Data/Array/Accelerate/Examples/Internal/Monitoring.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/Monitoring.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/Monitoring.hs
@@ -1,10 +1,10 @@
 {-# LANGUAGE CPP #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.Monitoring
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/ParseArgs.hs b/lib/Data/Array/Accelerate/Examples/Internal/ParseArgs.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/ParseArgs.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/ParseArgs.hs
@@ -5,10 +5,10 @@
 {-# LANGUAGE ViewPatterns    #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.ParseArgs
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Random/Array.hs b/lib/Data/Array/Accelerate/Examples/Internal/Random/Array.hs
deleted file mode 100644
--- a/lib/Data/Array/Accelerate/Examples/Internal/Random/Array.hs
+++ /dev/null
@@ -1,105 +0,0 @@
-{-# LANGUAGE RankNTypes    #-}
-{-# LANGUAGE TypeOperators #-}
--- Module:      : Data.Array.Accelerate.Examples.Internal.Random.Array
--- Copyright    : [2014] Trevor L. McDonell
--- License      : BSD3
---
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
--- Stability    : experimental
--- Portability  : non-portable (GHC extensions)
---
-
-module Data.Array.Accelerate.Examples.Internal.Random.Array (
-
-  -- * Generating random arrays
-  (:~>),
-  uniform, uniformR,
-  randomArray, randomArrayWithSeed, randomArrayWithSystemRandom,
-
-) where
-
-import System.Random.MWC                        hiding ( uniform, uniformR )
-import qualified System.Random.MWC              as R
-
-import Data.Array.Accelerate                    as A
-import Data.Array.Accelerate.Array.Data         as A
-import Data.Array.Accelerate.Array.Sugar        as Sugar
-
-
--- | A PNRG from indices to variates
---
-type sh :~> e = sh -> GenIO -> IO e
-
-
--- | Uniformly distributed random variates.
---
-uniform :: Variate e => sh :~> e
-uniform _ = R.uniform
-
--- | Uniformly distributed random variates in a given range.
---
-uniformR :: Variate e => (e, e) -> sh :~> e
-uniformR bounds _ = R.uniformR bounds
-
-
--- | Generate an array of random values using the supplied generator function.
---   The generator for variates is initialised with a fixed seed.
---
-randomArray :: (Shape sh, Elt e) => sh :~> e -> sh -> Array sh e
-randomArray f sh
-  = let
-        (adata, _)      = runArrayData $ do
-                            gen <- create
-                            arr <- runRandomArray f sh gen
-                            return (arr, undefined)
-    in
-    adata `seq` Array (fromElt sh) adata
-
-
--- | Generate an array of random values using a supplied generator function and
---   seed value.
---
-randomArrayWithSeed :: (Shape sh, Elt e) => Seed -> sh :~> e -> sh -> Array sh e
-randomArrayWithSeed seed f sh
-  = let
-        (adata, _)      = runArrayData $ do
-                            gen <- restore seed
-                            arr <- runRandomArray f sh gen
-                            return (arr, undefined)
-    in
-    adata `seq` Array (fromElt sh) adata
-
-
--- | Generate an array of random values using a supplied generator function,
---   initialised with the system's source of pseudo-random numbers.
---
---   TODO: find a way to do this directly, without going via save/restore.
---
-randomArrayWithSystemRandom
-    :: forall sh e. (Shape sh, Elt e)
-    => sh :~> e
-    -> sh
-    -> IO (Array sh e)
-randomArrayWithSystemRandom f sh
-  = do
-       seed   <- withSystemRandom (asGenIO save)
-       return $! randomArrayWithSeed seed f sh
-
-
--- Common function to create a mutable array and fill it with random values
---
-runRandomArray
-    :: (Shape sh, Elt e)
-    => sh :~> e
-    -> sh
-    -> GenIO
-    -> IO (MutableArrayData (EltRepr e))
-runRandomArray f sh gen
-  = do
-      arr <- newArrayData $! Sugar.size sh
-      let write ix = unsafeWriteArrayData arr (Sugar.toIndex sh ix)
-                   . fromElt =<< f ix gen
-
-      iter sh write (>>) (return ())
-      return arr
-
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Report.hs b/lib/Data/Array/Accelerate/Examples/Internal/Report.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/Report.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/Report.hs
@@ -1,10 +1,10 @@
 {-# LANGUAGE CPP #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.Report
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Similar.hs b/lib/Data/Array/Accelerate/Examples/Internal/Similar.hs
deleted file mode 100644
--- a/lib/Data/Array/Accelerate/Examples/Internal/Similar.hs
+++ /dev/null
@@ -1,149 +0,0 @@
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE DefaultSignatures #-}
-{-# LANGUAGE TypeOperators     #-}
-{-# OPTIONS_GHC -fno-warn-orphans #-}
--- |
--- Module:      : Data.Array.Accelerate.Examples.Internal.Similar
--- Copyright    : [2014] Trevor L. McDonell
--- License      : BSD3
---
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
--- Stability    : experimental
--- Portability  : non-portable (GHC extensions)
---
-
-module Data.Array.Accelerate.Examples.Internal.Similar (
-
-  Similar(..)
-
-) where
-
-import Data.Array.Accelerate                            ( Z(..), (:.)(..), Array, Shape, arrayShape, toList )
-import Data.Complex
-import Data.Int
-import Data.Word
-import Foreign.C.Types
-import Linear.V1
-import Linear.V2
-import Linear.V3
-import Linear.V4
-import Prelude                                          as P
-
-
--- A class of things that support almost-equality, so that we can disregard
--- small amounts of floating-point round-off error.
---
-class Similar a where
-  {-# INLINE (~=) #-}
-  (~=) :: a -> a -> Bool
-  default (~=) :: Eq a => a -> a -> Bool
-  (~=) = (==)
-
-infix 4 ~=
-
-instance Similar a => Similar [a] where
-  []     ~= []          = True
-  (x:xs) ~= (y:ys)      = x ~= y && xs ~= ys
-  _      ~= _           = False
-
-instance (Similar a, Similar b) => Similar (a, b) where
-  (x1, x2) ~= (y1, y2) = x1 ~= y1 && x2 ~= y2
-
-instance (Similar a, Similar b, Similar c) => Similar (a, b, c) where
-  (x1, x2, x3) ~= (y1, y2, y3) = x1 ~= y1 && x2 ~= y2 && x3 ~= y3
-
-instance (Similar a, Similar b, Similar c, Similar d) => Similar (a, b, c, d) where
-  (x1, x2, x3, x4) ~= (y1, y2, y3, y4) = x1 ~= y1 && x2 ~= y2 && x3 ~= y3 && x4 ~= y4
-
-instance (Similar a, Similar b, Similar c, Similar d, Similar e)
-    => Similar (a, b, c, d, e) where
-  (x1, x2, x3, x4, x5) ~= (y1, y2, y3, y4, y5) =
-    x1 ~= y1 && x2 ~= y2 && x3 ~= y3 && x4 ~= y4 && x5 ~= y5
-
-instance (Similar a, Similar b, Similar c, Similar d, Similar e, Similar f)
-    => Similar (a, b, c, d, e, f) where
-  (x1, x2, x3, x4, x5, x6) ~= (y1, y2, y3, y4, y5, y6) =
-    x1 ~= y1 && x2 ~= y2 && x3 ~= y3 && x4 ~= y4 && x5 ~= y5 && x6 ~= y6
-
-instance (Similar a, Similar b, Similar c, Similar d, Similar e, Similar f, Similar g)
-    => Similar (a, b, c, d, e, f, g) where
-  (x1, x2, x3, x4, x5, x6, x7) ~= (y1, y2, y3, y4, y5, y6, y7) =
-    x1 ~= y1 && x2 ~= y2 && x3 ~= y3 && x4 ~= y4 && x5 ~= y5 && x6 ~= y6 && x7 ~= y7
-
-instance (Similar a, Similar b, Similar c, Similar d, Similar e, Similar f, Similar g, Similar h)
-    => Similar (a, b, c, d, e, f, g, h) where
-  (x1, x2, x3, x4, x5, x6, x7, x8) ~= (y1, y2, y3, y4, y5, y6, y7, y8) =
-    x1 ~= y1 && x2 ~= y2 && x3 ~= y3 && x4 ~= y4 && x5 ~= y5 && x6 ~= y6 && x7 ~= y7 && x8 ~= y8
-
-instance (Similar a, Similar b, Similar c, Similar d, Similar e, Similar f, Similar g, Similar h, Similar i)
-    => Similar (a, b, c, d, e, f, g, h, i) where
-  (x1, x2, x3, x4, x5, x6, x7, x8, x9) ~= (y1, y2, y3, y4, y5, y6, y7, y8, y9) =
-    x1 ~= y1 && x2 ~= y2 && x3 ~= y3 && x4 ~= y4 && x5 ~= y5 && x6 ~= y6 && x7 ~= y7 && x8 ~= y8 && x9 ~= y9
-
-instance Similar a => Similar (V1 a) where
-  V1 x ~= V1 y = x ~= y
-
-instance Similar a => Similar (V2 a) where
-  V2 x1 x2 ~= V2 y1 y2 = x1 ~= y1 && x2 ~= y2
-
-instance Similar a => Similar (V3 a) where
-  V3 x1 x2 x3 ~= V3 y1 y2 y3 = x1 ~= y1 && x2 ~= y2 && x3 ~= y3
-
-instance Similar a => Similar (V4 a) where
-  V4 x1 x2 x3 x4 ~= V4 y1 y2 y3 y4 = x1 ~= y1 && x2 ~= y2 && x3 ~= y3 && x4 ~= y4
-
-instance Similar Z
-instance (Eq sh, Eq sz) => Similar (sh:.sz)
-
-instance Similar Int
-instance Similar Int8
-instance Similar Int16
-instance Similar Int32
-instance Similar Int64
-instance Similar Word
-instance Similar Word8
-instance Similar Word16
-instance Similar Word32
-instance Similar Word64
-instance Similar Char
-instance Similar Bool
-instance Similar CShort
-instance Similar CUShort
-instance Similar CInt
-instance Similar CUInt
-instance Similar CLong
-instance Similar CULong
-instance Similar CLLong
-instance Similar CULLong
-instance Similar CChar
-instance Similar CSChar
-instance Similar CUChar
-
-instance Similar Float   where (~=) = absRelTol 0.00005 0.005
-instance Similar Double  where (~=) = absRelTol 0.00005 0.005
-instance Similar CFloat  where (~=) = absRelTol 0.00005 0.005
-instance Similar CDouble where (~=) = absRelTol 0.00005 0.005
-
-instance Similar e => Similar (Complex e) where
-  (r1 :+ i1) ~= (r2 :+ i2) = r1 ~= r2 && i1 ~= i2
-
-
--- {-# INLINE relTol #-}
--- relTol :: (Fractional a, Ord a) => a -> a -> a -> Bool
--- relTol epsilon x y = abs ((x-y) / (x+y+epsilon)) < epsilon
-
-{-# INLINEABLE absRelTol #-}
-absRelTol :: RealFloat a => a -> a -> a -> a -> Bool
-absRelTol epsilonAbs epsilonRel u v
-  |  isInfinite u
-  && isInfinite v          = True
-  |  isNaN u
-  && isNaN v               = True
-  | abs (u-v) < epsilonAbs = True
-  | abs u > abs v          = abs ((u-v) / u) < epsilonRel
-  | otherwise              = abs ((v-u) / v) < epsilonRel
-
-instance (Similar e, Eq sh, Shape sh) => Similar (Array sh e) where
-  a1 ~= a2      =  arrayShape a1 == arrayShape a2
-                && toList a1     ~= toList a2
-
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/TH.hs b/lib/Data/Array/Accelerate/Examples/Internal/TH.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/TH.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/TH.hs
@@ -2,10 +2,10 @@
 {-# LANGUAGE TemplateHaskell     #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.TH
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/TestFramework.hs b/lib/Data/Array/Accelerate/Examples/Internal/TestFramework.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/TestFramework.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/TestFramework.hs
@@ -1,9 +1,9 @@
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.TestFramework
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
@@ -20,12 +20,12 @@
   Assertion, testCase, assertEqual,
 
   -- ** Similarity
-  module Data.Array.Accelerate.Examples.Internal.Similar,
+  module Data.Array.Accelerate.Test.Similar
 
 ) where
 
+import Data.Array.Accelerate.Test.Similar
 import Data.Array.Accelerate.Examples.Internal.ParseArgs
-import Data.Array.Accelerate.Examples.Internal.Similar
 
 import Data.Label
 import Control.Monad
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/TestFramework/Config.hs b/lib/Data/Array/Accelerate/Examples/Internal/TestFramework/Config.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/TestFramework/Config.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/TestFramework/Config.hs
@@ -2,10 +2,10 @@
 {-# LANGUAGE TemplateHaskell #-}
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.TestFramework.Config
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
diff --git a/lib/Data/Array/Accelerate/Examples/Internal/Util.hs b/lib/Data/Array/Accelerate/Examples/Internal/Util.hs
--- a/lib/Data/Array/Accelerate/Examples/Internal/Util.hs
+++ b/lib/Data/Array/Accelerate/Examples/Internal/Util.hs
@@ -1,9 +1,9 @@
 -- |
 -- Module:      : Data.Array.Accelerate.Examples.Internal.Util
--- Copyright    : [2014] Trevor L. McDonell
+-- Copyright    : [2014..2020] Trevor L. McDonell
 -- License      : BSD3
 --
--- Maintainer   : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
+-- Maintainer   : Trevor L. McDonell <trevor.mcdonell@gmail.com>
 -- Stability    : experimental
 -- Portability  : non-portable (GHC extensions)
 --
