I mean, not the simple stuff like this (from here):
strike :: StateT Game IO ()
strike = do
lift $ putStrLn "*shink*"
boss.health -= 10
But things like using lens to map over types from Linear
. How would I express this in terms of lens:
vecMod :: (Integral a) => V2 a -> V2 a -> V2 a
vecMod (V2 x1 y1) (V2 x2 y2) = V2 (x1 `mod` x2) (y1 `mod` y2)
Another example: my current code is full of small expressions like this:
isAt :: Thing -> Position -> Game Bool
isAt thing pos = do
b <- use board
return $ elem thing (b ! pos)
(where board is Array (V2 Int)
)
I guess is that there (with lens
) there is a more canonical way to express this.
In general: how do I find out what lens is able to do, what not and how it is done?