{"action":"created","issue":{"url":"https://api.github.com/repos/llvm-hs/llvm-hs-quote/issues/8","repository_url":"https://api.github.com/repos/llvm-hs/llvm-hs-quote","labels_url":"https://api.github.com/repos/llvm-hs/llvm-hs-quote/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/llvm-hs/llvm-hs-quote/issues/8/comments","events_url":"https://api.github.com/repos/llvm-hs/llvm-hs-quote/issues/8/events","html_url":"https://github.com/llvm-hs/llvm-hs-quote/issues/8","id":294638020,"number":8,"title":"Antiquoter `$instr:` error, \"Couldn't match expected type ‘AST.Instruction’ ...\"","user":{"login":"nwtgck","id":10933561,"avatar_url":"https://avatars1.githubusercontent.com/u/10933561?v=4","gravatar_id":"","url":"https://api.github.com/users/nwtgck","html_url":"https://github.com/nwtgck","followers_url":"https://api.github.com/users/nwtgck/followers","following_url":"https://api.github.com/users/nwtgck/following{/other_user}","gists_url":"https://api.github.com/users/nwtgck/gists{/gist_id}","starred_url":"https://api.github.com/users/nwtgck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nwtgck/subscriptions","organizations_url":"https://api.github.com/users/nwtgck/orgs","repos_url":"https://api.github.com/users/nwtgck/repos","events_url":"https://api.github.com/users/nwtgck/events{/privacy}","received_events_url":"https://api.github.com/users/nwtgck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-06T05:37:08Z","updated_at":"2018-02-06T10:00:12Z","closed_at":null,"author_association":"NONE","body":"Hi, developers of llvm-hs-quote.\r\n\r\n## Environment\r\n\r\nllvm-hs-quote: 1e0cf2e0c47be573c2e0b46cb018a9e924451da9  and f73459f2e94cb189badab8dd420b897a2e4b8222 (Latest)\r\nresolver: lts-10.2 (same version as llvm-hs-quote)\r\n\r\n## Problem\r\n\r\n I'd like to use `$instr` but the following code has a compile error.\r\n\r\n### My code\r\n\r\n```hs\r\n-- (COMPILE ERROR:  Couldn't match expected type ‘AST.Instruction’ ...)\r\nmodule5 :: AST.Instruction -> AST.Module\r\nmodule5 instruction = [Quote.LLVM.llmod|\r\n  ; ModuleID = 'simple module'\r\n  define i32 @myfunc(){\r\n  entry:\r\n    $instr:instruction\r\n  }\r\n|]\r\n```\r\n\r\n### Compile error message\r\n\r\n```txt\r\n• Couldn't match expected type ‘AST.Instruction’\r\n                  with actual type ‘Either AST.Instruction b0’\r\n    • In the pattern: Left ins_amXd\r\n      In a case alternative:\r\n          Left ins_amXd\r\n            -> return\r\n                 [((AST.Global.BasicBlock n_amXc) [AST.Do ins_amXd])\r\n                    (AST.Do $ ((AST.Br (AST.Name \"nextblock\")) []))]\r\n      In a stmt of a 'do' block:\r\n        case x2'_amXb of\r\n          Left ins_amXd\r\n            -> return\r\n                 [((AST.Global.BasicBlock n_amXc) [...])\r\n                    (AST.Do $ ((AST.Br (AST.Name \"nextblock\")) []))]\r\n          Right term_amXe\r\n            -> return [((AST.Global.BasicBlock n_amXc) []) (AST.Do term_amXe)]\r\n...\r\n```\r\n\r\n\r\n## Passed Code\r\n\r\nI tried to reducing error. Finally I got the following code. The code has no compile error, but this is what I want. In the code, I used `Either a Terminator` instead of `Instruction`.\r\n\r\n```hs\r\n-- COMPILE PASS\r\nmodule2 :: AST.Terminator -> AST.Module\r\nmodule2 terminator =\r\n  let\r\n     terminatorEither = Right terminator\r\n  in\r\n  [Quote.LLVM.llmod|\r\n    ; ModuleID = 'simple module'\r\n    define i32 @myfunc(){\r\n    entry:\r\n      $instr:terminatorEither\r\n    }\r\n  |]\r\n```\r\n\r\nCould you tell how to fix this problem?"},"comment":{"url":"https://api.github.com/repos/llvm-hs/llvm-hs-quote/issues/comments/363371580","html_url":"https://github.com/llvm-hs/llvm-hs-quote/issues/8#issuecomment-363371580","issue_url":"https://api.github.com/repos/llvm-hs/llvm-hs-quote/issues/8","id":363371580,"user":{"login":"sdiehl","id":236767,"avatar_url":"https://avatars3.githubusercontent.com/u/236767?v=4","gravatar_id":"","url":"https://api.github.com/users/sdiehl","html_url":"https://github.com/sdiehl","followers_url":"https://api.github.com/users/sdiehl/followers","following_url":"https://api.github.com/users/sdiehl/following{/other_user}","gists_url":"https://api.github.com/users/sdiehl/gists{/gist_id}","starred_url":"https://api.github.com/users/sdiehl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdiehl/subscriptions","organizations_url":"https://api.github.com/users/sdiehl/orgs","repos_url":"https://api.github.com/users/sdiehl/repos","events_url":"https://api.github.com/users/sdiehl/events{/privacy}","received_events_url":"https://api.github.com/users/sdiehl/received_events","type":"User","site_admin":false},"created_at":"2018-02-06T10:00:12Z","updated_at":"2018-02-06T10:00:12Z","author_association":"OWNER","body":"Great, I'll add this example to the README so there isn't any confusion in the future."}}
{"actor":{"display_login":"sdiehl"}}