-- | collects the regions where `xa` doesn't match / aka invert a set of intervals
-- unused, but don't want to delete it yet - Aug 30, 2018
_no :: SubseqExtractor' n a -> SubseqExtractor' n ()
_no xa = SubseqExtractor' $ \note ->
  let as = runSubseq xa note
  in  if null [ a | Pure a <- as ]
        then -- results are not full
             if null as
          then [Pure ()] -- results are empty, make them full
      -- not full and not empty, find the negation
          else reverse . fst $ foldl' go
                                      ([], Nothing)
                                      (List.sort $ fmap toPairs as)
        else [] -- results were full, make them empty
 where
  toPairs :: Ranged a -> (Int, Int)
  toPairs (Pure _            ) = error "this case should be avoided by the if!"
  toPairs (Ranged _ start end) = (start, end)

  go :: ([Ranged ()], Maybe Int) -> (Int, Int) -> ([Ranged ()], Maybe Int)
  go ([]   , Nothing) (0, r) = ([], Just (r + 1))
  go ([]   , Nothing) (l, r) = ([Ranged () 0 (l - 1)], Just r)
  go (_ : _, Nothing) _      = error "state machine bug in Extractor2.no"
  go (rs, Just r0) (l, r) =
    (if r0 + 1 <= l - 1 then Ranged () (r0 + 1) (l - 1) : rs else rs, Just r)

-- unused / untested
_no :: SubseqExtractor' n a -> SubseqExtractor' n ()
_no xa = SubseqExtractor' $ \note ->
  let as = runSubseq xa note
  in  if null [ a | Pure a <- as ]
        then -- results are not full
             if null as
          then [Pure ()] -- results are empty, make them full
      -- not full and not empty, find the negation
          else reverse . fst $ foldl' go
                                      ([], Nothing)
                                      (List.sort $ fmap toPairs as)
        else [] -- results were full, make them empty
 where
  toPairs :: Ranged a -> (Int, Int)
  toPairs (Pure _            ) = error "this case should be avoided by the if!"
  toPairs (Ranged _ start end) = (start, end)

  go :: ([Ranged ()], Maybe Int) -> (Int, Int) -> ([Ranged ()], Maybe Int)
  go ([]   , Nothing) (0, r) = ([], Just (r + 1))
  go ([]   , Nothing) (l, r) = ([Ranged () 0 (l - 1)], Just r)
  go (_ : _, Nothing) _      = error "state machine bug in Extractor2.no"
  go (rs, Just r0) (l, r) =
    (if r0 + 1 <= l - 1 then Ranged () (r0 + 1) (l - 1) : rs else rs, Just r)

-- unused / untested
_no xa = SubseqExtractor' $ \note ->
  let as = runSubseq xa note
  in  if null [ a | Pure a <- as ]
        then -- results are not full
             if null as
          then [Pure ()] -- results are empty, make them full
      -- not full and not empty, find the negation
          else reverse . fst $ foldl' go
                                      ([], Nothing)
                                      (List.sort $ fmap toPairs as)
        else [] -- results were full, make them empty
 where
  toPairs :: Ranged a -> (Int, Int)
  toPairs (Pure _            ) = error "this case should be avoided by the if!"
  toPairs (Ranged _ start end) = (start, end)

  go :: ([Ranged ()], Maybe Int) -> (Int, Int) -> ([Ranged ()], Maybe Int)
  go ([]   , Nothing) (0, r) = ([], Just (r + 1))
  go ([]   , Nothing) (l, r) = ([Ranged () 0 (l - 1)], Just r)
  go (_ : _, Nothing) _      = error "state machine bug in Extractor2.no"
  go (rs, Just r0) (l, r) =
    (if r0 + 1 <= l - 1 then Ranged () (r0 + 1) (l - 1) : rs else rs, Just r)

-- unused / untested