Created
January 13, 2015 14:39
-
-
Save mithrandi/2490e7394b264d337b25 to your computer and use it in GitHub Desktop.
Lenses example with IO
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
findDataset :: Dataset -> Maybe String | |
findDataset (view datasetName -> Just name) = M.lookup name datasets | |
findDataset (view datasetName -> Nothing) = Nothing | |
update_dataset_id :: Dataset -> IO Dataset | |
update_dataset_id d = | |
case findDataset d of | |
Just did -> return $ d & datasetId ?~ did | |
Nothing -> (\did -> d & datasetId ?~ did) <$> toString <$> nextRandom | |
update_all_dataset_ids :: Deployment -> IO Deployment | |
update_all_dataset_ids = mapMOf (nodes.traversed.applications.traversed.volume.dataset) update_dataset_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment