I want to map a function of type Float -> Float over a part of a data structure which looks like this.
VDstruct { _onBuild = Just True
, _imageName = Just "arc.png"
, _category = Just "All"
, _mmo = Just 210
, _structTypes = Just
( Mage
{ _ict = Nothing
, _create = Just 1.24
, _sh = Nothing
}
}
I want to apply that function to _ict, _create and to _sh.
I know how to do that for each one of those.
I'm using Lenses to help me out with that.
The result has _create = Just 5.4 which is exactly what I expect from plusXPercent function.
This is what I'm using right now.
setSer x = x & (structTypes . _Just . create) %~ fmap plusXPercent
What I want to do is instead of naming every _ict, _sh, etc. I want a way to 'map' that function over the entirety of Mage structure.
How should I go about doing that?
Edit: _ict, _create and _sh have type Maybe Float
and Mage is defined like this
data Mage = Mage { _ict :: Maybe Float
, _create :: Maybe Float
, _sh :: Maybe Float
} deriving Show