Comments (4)
No, you can't use an operator like that, that's why it's not
documented ;). Doing so would require knowing all of the precedence
levels, which is not available to the TH code involved. You can
instead do something like this:
$if (>) (length list) 2
$if isValid $ (+) a b
On Tue, Mar 15, 2011 at 8:36 PM, scan
[email protected]
wrote:
Another issue I have found, not documented, is using an operator in an $if, like so:
$if (length list) > 2
$if isValid (a+b)And other examples (with ==) and such... they all produce the error 'Unexpected >' or 'Unexpected =' and so on. Is that intended? If I define a function
let eq = (==)
It works fine, and operators are just functions, so shouldn't that work?
Reply to this email directly or view it on GitHub:
https://github.com/snoyberg/hamlet/issues/13
from shakespeare.
Is that a general restriction or can that be solved?
from shakespeare.
I don't think it's solvable, but more to the point, I don't want to solve it. I think allowing arbitrary infix syntax is a bad direction for Hamlet. I agree 100% that it would be useful in many situations, but it also leads to some ambiguity. For example, the same Hamlet template could have different meanings depending on which modules are in scope when it is called.
On the other hand, we could simply force all operators to have the same precedence rules, but then it won't line up with the Haskell code.
from shakespeare.
Yes, ok, thanks. It makes sense there, after all, it makes no difference for the program, only to the programmer.
from shakespeare.
Related Issues (20)
- Caret Interpolation with justVarInterpolation HOT 1
- cli
- Lucius and Cassius `&` not documented
- Lucius Cassius Comment syntax not documented HOT 5
- CSS Math HOT 1
- Hamlet puts <title> to <body> HOT 5
- Julius: async function cannot be parsed HOT 6
- shakespeare escape bug in #\" HOT 2
- [lucius] @supports mixing problem? HOT 4
- Test failure with GHC 9 HOT 6
- Build error with aeson-2 HOT 1
- `$maybe` and `$forall` unsupported in `Text.Shakespeare.Text` HOT 2
- fails to build with aeson-2.0 HOT 5
- Mixins should respect rule order HOT 1
- I18N, allow multiline messages in translation files
- Support lens operators in templates
- Julius arrow function with curly brace body is compiled to expression even if it's not an expression HOT 2
- Surprising behaviour of Scientific arithmetic inside a template HOT 1
- Cannot have two messages with the same parameter name of different types HOT 3
- Inconsistency between `textfile` and `stextfile` HOT 2
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 shakespeare.