Marking ParsedModule fragments as non-user-originating
Erdi, Gergo
Gergo.Erdi at sc.com
Tue Jul 6 08:07:50 UTC 2021
PUBLIC
Hi,
I'd like to hijack some syntax (like string literals or list patterns) for my own use, and I thought a low-tech way of doing that is to transform the ParsedModule before typechecking. For example, if I have a function `uncons :: Array a -> Maybe (a, Array a)`, I can rewrite the pattern `[x1, x2, x3]` into the view pattern `(uncons -> Just (x1, (uncons -> Just (x2, (uncons -> Just (x3, (uncons -> Nothing)))))))` and let the normal GHC type checker take over from here.
This is working for me so far, except for one problem: the typechecker now complains that the `ViewPatterns` language extension is not turned on. I would like to make the view patterns coming from my ParsedModule rewriter to be exempt from this check (but of course still require the `ViewPatterns` extension for user-originating code). Is there a way to do that? Or would I be better off checking for user-originating view patterns myself before the rewrite and then changing the `DynFlags` to always enable view patterns for typechecking?
Thanks,
Gergo
This email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please delete all copies and notify the sender immediately. You may wish to refer to the incorporation details of Standard Chartered PLC, Standard Chartered Bank and their subsidiaries at https: //www.sc.com/en/our-locations
Where you have a Financial Markets relationship with Standard Chartered PLC, Standard Chartered Bank and their subsidiaries (the "Group"), information on the regulatory standards we adhere to and how it may affect you can be found in our Regulatory Compliance Statement at https: //www.sc.com/rcs/ and Regulatory Compliance Disclosures at http: //www.sc.com/rcs/fm
Insofar as this communication is not sent by the Global Research team and contains any market commentary, the market commentary has been prepared by the sales and/or trading desk of Standard Chartered Bank or its affiliate. It is not and does not constitute research material, independent research, recommendation or financial advice. Any market commentary is for information purpose only and shall not be relied on for any other purpose and is subject to the relevant disclaimers available at https: //www.sc.com/en/regulatory-disclosures/#market-disclaimer.
Insofar as this communication is sent by the Global Research team and contains any research materials prepared by members of the team, the research material is for information purpose only and shall not be relied on for any other purpose, and is subject to the relevant disclaimers available at https: //research.sc.com/research/api/application/static/terms-and-conditions.
Insofar as this e-mail contains the term sheet for a proposed transaction, by responding affirmatively to this e-mail, you agree that you have understood the terms and conditions in the attached term sheet and evaluated the merits and risks of the transaction. We may at times also request you to sign the term sheet to acknowledge the same.
Please visit https: //www.sc.com/en/regulatory-disclosures/dodd-frank/ for important information with respect to derivative products.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20210706/eccb1c77/attachment.html>
More information about the ghc-devs
mailing list