Skip to content

Instantly share code, notes, and snippets.

@tel
Last active March 30, 2017 05:46
Show Gist options
  • Save tel/6b2438180a0af9a247d113d99f455d5a to your computer and use it in GitHub Desktop.
Save tel/6b2438180a0af9a247d113d99f455d5a to your computer and use it in GitHub Desktop.
-- 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