Created
January 9, 2013 22:21
-
-
Save saml/4497545 to your computer and use it in GitHub Desktop.
lends stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Lens | |
import Control.Monad.State | |
import Data.Foldable (mapM_) | |
data Rec = | |
Rec { _recA :: Int, _recB :: String, _recC :: Double } | |
deriving (Eq, Ord, Show) | |
makeLenses Rec | |
a = Just 1 | |
b = Nothing | |
c = Just 3.14 | |
x = Rec 0 "" 0.0 | |
-- I want to update x with a, b, c and skip Nothing. | |
main = do | |
let x' = flip execState x $ do | |
mapM_ (assign recA) a | |
mapM_ (assign recB) b | |
mapM_ (assign recC) c | |
print x' | |
-- http://hpaste.org/80514#a80515 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment