{-# LANGUAGE TypeFamilies, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts #-}

--
-- | Given an instance of @ScanVectorMachine V' (V S)@, we can produce
--   a type @V''@ and instance @ScanVectorMachine V'' (V' (V S))@.  In
--   other words, given an implementation of vectors with some nonzero
--   nesting depth, this will produce an implementation with nesting
--   depth /one level deeper/.
--
--   This is different from @SegmentedVectors@, which uses flat
--   vectors (0-deep nesting) to emulate segmented vectors (1-deep
--   nesting) by cutting the size of the scalars in half.  Here, there
--   is no need to assume that the flat-vector scalars are twice as
--   wide (in terms of bits) as the segmented scalars, so arbitrarily
--   deep nesting may be achieved without sacrificing any additional
--   bit-width.  In addition, @NestedVectors@ introduces less overhead
--   than @SegmentedVectors@.  For this reason, many hardware/platform
--   providers choose to implement @ScanVectorMachine V' (V S)@
--   instead of @ScanVectorMachine (V S)@; this requires more work
--   (more methods to implement), but eliminates the overhead of
--   @SegmentedVectors@.
--

module Control.Parallel.ScanVectorMachine.NestedVectors where
import Control.Parallel.ScanVectorMachine.ScanVectorMachine as SVM

-- private; isomorphic to (,)
data VecPair v = VecPair v v

-- sanity check that the two vectors have identical segment descriptors; if not, raise an error
check_eq a b = a  -- FIXME: implement; for now we just trust the user

instance (SVM.ScanVectorMachine v s,
          SVM.ScanVectorMachine v' (v s)) =>
          SVM.ScanVectorMachine VecPair (v' (v s)) where
  neg         (VecPair a alens)                                     = undefined
  leq         (VecPair a alens) (VecPair b blens)                   = undefined
  op       o  (VecPair a alens) (VecPair b blens)                   = undefined
  select      (VecPair b blens) (VecPair x xlens) (VecPair y ylens) = undefined
  permute     (VecPair a alens) (VecPair i ilens)                   = undefined
  insert      (VecPair a alens) pos v                               = undefined
  extract     (VecPair a alens) pos                                 = undefined
  distribute  v len                                                 = undefined
  length      (VecPair a alens)                                     = undefined
  scan     o  (VecPair a alens)                                     = undefined