[Haskell-cafe] lens and Maybe value

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Tue Dec 20 16:13:13 UTC 2022


Hello,

I have a data whcih contain a Maybe value

data A = A (_a = Maybe a)

I would like to use a lens in order to merge two values with this log

replace the value only if it is a (Just a)

So My question is

is there something more elegant than

let myA' = case ma of
              Nothing  -> conf
              (Just na) -> (a .~ na) myA

Thanks for your help

Frederic


More information about the Haskell-Cafe mailing list