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