pepeiborra / haskell-src-exts-util

Utility code for working with haskell-src-exts
BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

Add more things to isAtom #5

Closed ndmitchell closed 6 years ago

ndmitchell commented 6 years ago

The following things seem to be atomic to me, so probably should be marked as such. I've given the constructor name, and a small example expression.

OverloadedLabel #foo
IPVar ?foo
RecUpdate foo{foo = foo}
ParArrayFromTo [:foo .. foo:]
ParArrayFromThenTo [:foo, foo .. foo:]
ParArrayComp [:foo| foo:]
VarQuote 'foo
TypQuote ''foo
BracketExp [| foo |]
SpliceExp $foo
QuasiQuote [foo|foo|]
TypeApp @foo
XETag <foo foo = foo foo />
XExpTag <% foo %>
ExprHole _
ParArray
ParComp
ndmitchell commented 6 years ago

I created this list using the script https://gist.github.com/ndmitchell/da7159d724e634c3e2a0599a11bd2ae3

ndmitchell commented 6 years ago

Doing Pat, I found:

PAsPat foo@foo
PIrrPat ~foo
PXETag <foo foo = foo foo />
PXPatTag <% foo %>
PQuasiQuote [$foo|foo|]
PBangPat !foo
ndmitchell commented 6 years ago

Note that Lit and PLit are probably atomic for non-negative numbers, whereas currently via isLexeme (a probably redundant function that should be inlined) they are returned as True.

pepeiborra commented 6 years ago

That script could be turned into a TH computation to keep isAtom in sync with haskell-src-exts.

ndmitchell commented 6 years ago

The script is useful, but it’s only a first approximation - it needs humans to check it. But an entry in the test suite might be reasonable.

I’m also somewhat weary of TH as it always causes build issues for someone somewhere.