Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude tags #35

Open
JeffreyBenjaminBrown opened this issue Oct 29, 2018 · 7 comments
Open

exclude tags #35

JeffreyBenjaminBrown opened this issue Oct 29, 2018 · 7 comments
Labels
enhancement New feature or request

Comments

@JeffreyBenjaminBrown
Copy link

The filter function in toodles blows my mind. I love being able to do that.

But it would be nice to be able specify "show me everything except bla".

More generally, a boolean logic would be awesome -- something like Apache Lucene, which lets you ask for "bob AND NOT (speed OR search)". Or, perhaps more natural, it could read like Haskell: "bob && not (speed || search)".

@JeffreyBenjaminBrown
Copy link
Author

For the general query language problem, Text.Megaparsec.Expr is extremely well suited. It lets you define unary and binary operators of various precedence levels. If I can figure out how to contribute I plan to try to write this with it.

@aviaviavi aviaviavi added the enhancement New feature or request label Oct 30, 2018
@aviaviavi
Copy link
Owner

I like it! While I can see the benefit (and fun!) of building this into the backend, I'm thinking it might be a pre-optimization. To me it sounds easier to just add this new logic to the frontend, and avoid the back-and-forth to the server. What do you think?

@JeffreyBenjaminBrown
Copy link
Author

I don't know what you mean. Are you saying just provide two windows, one for include and one for exclude? Or do you mean to parse boolean queries, just not in the backend? I'm not yet close enough to the code to know what to call back end and front end.

@aviaviavi
Copy link
Owner

I meant the latter. The javascript that powers the web UI of toodles should be able to handle this, so I was suggesting there might not be any Haskell to write here, at least not at first.

@JeffreyBenjaminBrown
Copy link
Author

It could be done in Javascript, I agree -- but why? It'd be far more code, and less safe, and harder to learn or modify. Megaparsec.Expr lets you write a parser for unary and binary operators of different precedence levels in as little as this much code:

expr = makeExprParser term table <?> "expression"

term = parens expr <|> integer <?> "term"

table = [ [ prefix  "-"  negate
          , prefix  "+"  id ]
        , [ postfix "++" (+1) ]
        , [ binary  "*"  (*)
          , binary  "/"  div  ]
        , [ binary  "+"  (+)
          , binary  "-"  (-)  ] ]

binary  name f = InfixL  (f <$ symbol name)
prefix  name f = Prefix  (f <$ symbol name)
postfix name f = Postfix (f <$ symbol name)

@aviaviavi
Copy link
Owner

aviaviavi commented Nov 10, 2018

Apologies for the late response here, must have missed the notification of your reply.

I'm on board with your suggestion.

Just for context on I was coming from: currently the UI does this filtering right now, so the Haskell code is not involved. So I was questioning if the complexity of the parsing you are describing even justifies the complexity of simply going back and forth with the server at all. Sounds like it does though :)

@aviaviavi
Copy link
Owner

@JeffreyBenjaminBrown let me know if you need any help getting this working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants