Created
November 26, 2018 23:16
-
-
Save hhefesto/13c48bfe5ae9ed96d2346726ce5fa7f8 to your computer and use it in GitHub Desktop.
not an expression? Why?
This file contains hidden or 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
| data SupportData = SupportData | |
| { customer :: Entity Customer | |
| , followUps :: [Entity FollowUp] | |
| , customerFollowUps :: [(Entity FollowUp, Entity Customer)] | |
| } | |
| getSupportRData :: CustomerId -> Handler SupportData | |
| getSupportRData customerId = do | |
| customer_issues_followUps_list <- runDB $ | |
| E.select $ | |
| E.from $ \(c `E.InnerJoin` i `E.LeftOuterJoin` f) -> do | |
| E.on (i ^. IssueId ==. f ^. FollowUpIssueId) | |
| E.on (c ^. CustomerId ==. i ^. IssueCustomerId) | |
| E.where_ (i ^. IssueCustomerId ==. E.val customerId) | |
| return (i, f, c) | |
| let followUps = snd3 . unzip3 $ customer_issues_followUps_list | |
| customers_followUps <- forM followUps $ \followUp -> do | |
| customers <- runDB $ | |
| E.select $ | |
| E.from $ \c -> do | |
| E.where_ (c ^. CustomerId ==. E.val (followUpAuthor (entityVal followUp))) | |
| return $ (followUp, (fromMaybe (error "Foreign key violation: followUp -> customer") (listToMaybe customers))) | |
| let issues :: [Maybe (Entity Issue)] = map listToMaybe . group . sort . fst3 . unzip3 $ customer_issues_followUps_list | |
| let customer = listToMaybe . thd3 . unzip3 $ customer_issues_followUps_list | |
| return SupportData | |
| { customer = customer | |
| , followUps = followUps | |
| , customerFollowUps = customer_followUps | |
| } |
This file contains hidden or 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
| [18 of 19] Compiling Handler.Support ( src/Handler/Support.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/build/Handler/Support.o ) | |
| /home/hhefesto/dev/laurus-nobilis/src/Handler/Support.hs:18:5: error: | |
| The last statement in a 'do' block must be an expression | |
| customers <- runDB $ E.select $ E.from | |
| $ \ c | |
| -> do E.where_ | |
| (c ^. CustomerId ==. E.val (followUpAuthor (entityVal followUp))) | |
| return | |
| $ (followUp, | |
| (fromMaybe | |
| (error "Foreign key violation: followUp -> customer") | |
| (listToMaybe customers))) | |
| | | |
| 18 | customers <- runDB $ | |
| | ^^^^^^^^^^^^^^^^^^^^... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment