-- Scopes --
asPathExtractor :: (C.PathElement v loc -> Maybe a) -> SubseqExtractor v loc a
asPathExtractor = fromPathExtractor . extractor
 where
  fromPathExtractor :: PathExtractor v loc a -> SubseqExtractor v loc a
  fromPathExtractor ex =
    subseqExtractor $ join . fmap go . (`zip` [0 ..]) . toList . C.path
   where
    go (e, i) = case extract ex e of
      Just a  -> [Ranged a i i]
      Nothing -> []
asPathExtractor :: (C.PathElement v loc -> Maybe a) -> SubseqExtractor v loc a
asPathExtractor = fromPathExtractor . extractor
 where
  fromPathExtractor :: PathExtractor v loc a -> SubseqExtractor v loc a
  fromPathExtractor ex =
    subseqExtractor $ join . fmap go . (`zip` [0 ..]) . toList . C.path
   where
    go (e, i) = case extract ex e of
      Just a  -> [Ranged a i i]
      Nothing -> []
asPathExtractor = fromPathExtractor . extractor
 where
  fromPathExtractor :: PathExtractor v loc a -> SubseqExtractor v loc a
  fromPathExtractor ex =
    subseqExtractor $ join . fmap go . (`zip` [0 ..]) . toList . C.path
   where
    go (e, i) = case extract ex e of
      Just a  -> [Ranged a i i]
      Nothing -> []