Comments (3)
Here is a simple example of why we need the ViewPatterns
approach:
> let x = [expr| 1 |]
> let y = [stmt| $x; |]
<interactive>:42:9: error:
• Exception when trying to run compile-time code:
Subst x
Code: Language.Haskell.TH.Quote.quoteExp stmt " $x; "
• In the quasi-quotation: [stmt| $x; |]
Even more insidiously (check -ddump-splices
and you'll see the error is "leaking")
> let x = [expr| 1 + 2 |]
> let y = [expr| $x * 3 |]
<interactive>:11:15: error:
• Couldn't match expected type ‘Language.Rust.Data.Position.Span’
with actual type ‘Language.Rust.Syntax.AST.Expr
Language.Rust.Data.Position.Span’
• In the fifth argument of ‘Language.Rust.Syntax.AST.Binary’, namely
‘x’
In the expression:
(Language.Rust.Syntax.AST.Binary
[]
Language.Rust.Syntax.AST.MulOp
x
(Language.Rust.Syntax.AST.Lit
[]
(Language.Rust.Syntax.AST.Int
Language.Rust.Syntax.AST.Dec
3
Language.Rust.Syntax.AST.Unsuffixed
(Language.Rust.Data.Position.Span
(Language.Rust.Data.Position.Position 6 11 21)
(Language.Rust.Data.Position.Position 7 11 22)))
(Language.Rust.Data.Position.Span
(Language.Rust.Data.Position.Position 6 11 21)
(Language.Rust.Data.Position.Position 8 11 23)))
x)
In an equation for ‘y’:
y = (Language.Rust.Syntax.AST.Binary
[]
Language.Rust.Syntax.AST.MulOp
x
(Language.Rust.Syntax.AST.Lit
[]
(Language.Rust.Syntax.AST.Int
Language.Rust.Syntax.AST.Dec
3
Language.Rust.Syntax.AST.Unsuffixed
(Language.Rust.Data.Position.Span
(Language.Rust.Data.Position.Position 6 11 21)
(Language.Rust.Data.Position.Position 7 11 22)))
(Language.Rust.Data.Position.Span
(Language.Rust.Data.Position.Position 6 11 21)
(Language.Rust.Data.Position.Position 8 11 23)))
x)
from language-rust.
Alright. I've mulled over this for a week and I've come up with a new approach, which isn't a hack:
- wrap all recursive ASTs in
m
(sodata ExprT m a = PlusT (m (ExprT m a)) (m (ExprT m a)) a...
) - update production rules to be parametrized over
Context m => ExprT m Span
whereContext
defines functions that need to look at the contents of parsed values (like the path case of patterns which checks for one identifier patterns) - make type synonyms (
type Expr = ExprT Identity
) and patterns (pattern Plus x y = PlusT (Identity x) (Identity y)
). This also means fixing how Haddock handles pattern synonyms - re-make
Quote
!
This may take some time...
from language-rust.
This won't make the 0.1.0.0 release. Instead, Language.Rust.Quote
quasiquoters will not support $x
or $x:ty
splices/extractors.
from language-rust.
Related Issues (20)
- Parse 'asm' macros
- Fix macros
- Multiline strings
- Attributes
- Parsing and Resolving range expressions
- Performance testing
- Special support for `InlineAsm` and `GlobalAsm`.
- Show expected tokens on failed parses HOT 1
- Clean up parsing expressions HOT 1
- Decide what to do around `mod ...;`
- Benchmark pretty-printing
- Backpack `InputStream` related functions
- It 2018 why are you using String? HOT 2
- Macros 2.0
- Bare trait object edge with leading paren
- C-compatible variadics
- Generic associated types
- Hackage release for ghc-8.8? HOT 1
- Float lexing is slightly wrong
- Does not build with `transformers-0.6.*` (GHC 9.6) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from language-rust.