Last active
March 30, 2017 05:46
-
-
Save tel/6b2438180a0af9a247d113d99f455d5a to your computer and use it in GitHub Desktop.
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
-- Example code | |
example :: (Context m, MonadLog m, AreaDao m) => [Actor] -> m () | |
example list = | |
forM list $ \actor -> do | |
logInfo $ "Actor being read: " ++ actorCode actor | |
areaList <- getArea actor | |
case areaList of | |
[] -> return () -- do nothing | |
(area : _) -> do | |
setActorArea actor area | |
logInfo $ | |
"Area{" ++ show area ++ "} is fetched for actor {" ++ actorCode actor ++ "}" | |
setReadCount 1 | |
-- Assumed preliminaries | |
data Actor | |
data Area | |
class MonadLog m | |
class AreaDao m | |
class Context m | |
logInfo :: MonadLog m => String -> m () | |
actorCode :: Actor -> String | |
getArea :: AreaDao m => Actor -> m [Area] | |
setActorArea :: AreaDao m => Actor -> Area -> m () | |
setReadCount :: Context m => Int -> m () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment