google / google/codeworld

Detection of template haskell can be more precise

Open
#1,073 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Haskell
Stars
1.3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

**Shared Program**: https://code.world/haskell#PvmcFl0m1uGPxR-OH8_lVeQ

**Description**

The detection of template-haskell currently just looks for any of "TemplateHaskell", "QuasiQuote" or "glasgow-exts" as a substring of the source file. This isn't saying exactly what we want. In particular:

1. This might not be sufficient in the future to detect all ways to turn on TemplateHaskell. GHC could add new flag sets that have this effect (in the same way that -fglasgow-exts does now).

2. These strings can sometimes occur in comments, string literals, etc., where they are innocent, but the program is rejected anyway.

Copied from a comment on #1072:

> codeworld-compiler now links ghc-lib-parser, and parseDynamicFilePragma can be used to parse language and options pragmas from the source code into dflags, and then we can check for use of the language flags in the resulting DynFlags value. There's existing code for this in CodeWorld.Compile.Framework ghcParseCode.

@misterbeebee FYI

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.