I still don't get how bytestrings work
import qualified Data.ByteString.Lazy as BS
let x = BS.readFile "somefile.txt" --some large file
let z = ((reverse (BS.unpack x)) !! 2) --do stuff here
I know bytestrings can be used to read large amounts of data ,very quickly and efficiently. But unpacking a packing doesn't make sense.
let z = readArray x 1 --can you read the bytestring like its a array?(something like this)
Can't you just read the data in bytestring form without unpacking? or just unpack a segment of the data?
Could you explain how it all works?(Code examples)