I'm trying to change a character at indices x and y in a matrix made of ByteString
s to a different character. Initially, I used [[Char]]
to represent the matrix, so I was able to use .~
from Control.Lens.Setter
to change the value, but this doesn't seem to work for [ByteString]
.
Is there any way to use the lens or to modify the element without unpack
ing the ByteString
like I'm doing right now?
The code, right now, is:
render :: [[Char]] -> [Loc Int] -> [[Char]]
render maze [] = maze
render maze (Loc (x,y):locs) = render mutate locs
where mutate = element y . element x .~ '*' $ maze
Where Loc
is just:
newtype Loc a = Loc (a,a) deriving (Show,Eq,Ord)