module Data.Text.Zipper.Vector
    ( vecLines
    )
where

import qualified Data.Vector as V

vecLines :: V.Vector Char -> [V.Vector Char]
vecLines :: Vector Char -> [Vector Char]
vecLines Vector Char
v | Vector Char -> Bool
forall a. Vector a -> Bool
V.null Vector Char
v  = []
           | Bool
otherwise = case Char -> Vector Char -> Maybe Int
forall a. Eq a => a -> Vector a -> Maybe Int
V.elemIndex Char
'\n' Vector Char
v of
               Maybe Int
Nothing -> [Vector Char
v]
               Just Int
i -> let (Vector Char
h, Vector Char
t) = Int -> Vector Char -> (Vector Char, Vector Char)
forall a. Int -> Vector a -> (Vector a, Vector a)
V.splitAt Int
i Vector Char
v
                         in Vector Char
h Vector Char -> [Vector Char] -> [Vector Char]
forall a. a -> [a] -> [a]
: Vector Char -> [Vector Char]
vecLines Vector Char
t