Git Product home page Git Product logo

Comments (7)

JeffreyBenjaminBrown avatar JeffreyBenjaminBrown commented on June 1, 2024

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.

from toodles.

aviaviavi avatar aviaviavi commented on June 1, 2024

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?

from toodles.

JeffreyBenjaminBrown avatar JeffreyBenjaminBrown commented on June 1, 2024

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.

from toodles.

aviaviavi avatar aviaviavi commented on June 1, 2024

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.

from toodles.

JeffreyBenjaminBrown avatar JeffreyBenjaminBrown commented on June 1, 2024

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)

from toodles.

aviaviavi avatar aviaviavi commented on June 1, 2024

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 :)

from toodles.

aviaviavi avatar aviaviavi commented on June 1, 2024

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

from toodles.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.