Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Mario Bašić
    @mabasic
    I'm working on #57, #58 and #61, but I can't assign myself to those issues
    Paul Laffitte
    @paullaffitte
    Hi, I wanted to ask about the idea of implementing a standard testing library for Phel. I would like to work on it so where should I do it? Do you think it's better that it has its own repository or should we keep everything together? For instance it could be beside http.phel and core.phel
    Jose Maria Valera Reales
    @Chemaclass
    I would rather start with that as you mention, something besides http|core.phel, for example, called testing.phel (?). If it gets bigger, we might think about extract it somewhere (in another repo), but, for now, because it's pretty tiny and minimalistic, I would rather vote to have it there, close to the core :)
    btw, kudos to your idea @paullaffitte! Really good and promising idea :)
    Jens Haase
    @jenshaase
    I started working on it this weekend. But found some bugs in the compiler that I had to solve first. Maybe I can do a pull request tomorrow on what I have.
    Jens Haase
    @jenshaase
    @paullaffitte Should we work on proposal for a testing library first? (similar to this jenshaase/phel-lang#52). I think it is faster to discuss the required features before and then implement afterwards.
    Mario Bašić
    @mabasic
    Testing and templating are the two things that are missing atm. Btw it would be cool to have automatic documentation generation from code like go has.
    Phel already has something similar to this for api docs am I right?
    Paul Laffitte
    @paullaffitte
    @jenshaase Indeed, it would be great to write a proposal first.
    Paul Laffitte
    @paullaffitte
    @mabasic Yes, you can see the code that generate this part of the doc in doc/build-api-page.php. But it's not available as a language feature like go seems to have. It would be nice to have a tool doing this that could be used by projects written in Phel.
    Jens Haase
    @jenshaase
    @paullaffitte I added a proposal for a test framework. Please have a look: jenshaase/phel-lang#78
    Paul Laffitte
    @paullaffitte
    I commented it
    I started to work on the set documentation. I think it would fit well between "Array, Table and Struct" and "Destructuring", but this mean updating the weight of all subsequent pages. Should we increment the weight by 10 for each pages instead of 1? This would allow to add a page between two other without having to update all subsequent pages.
    Jens Haase
    @jenshaase
    Please add the set docu to the page "array, table and struct" you can rename the page to "array, table, struct and set"
    Paul Laffitte
    @paullaffitte
    Done
    Jesus Valera Reales
    @JesusValera
    I think we miss to add the apply function into the documentation, it is not even in the API :thinking:
    Jens Haase
    @jenshaase
    I just fixed the last PSALM errors to support error level 2! Thanks to all who improved the code quality towards this.
    Jesus Valera Reales
    @JesusValera
    :dancer: :dancer:
    I create a new PR jenshaase/phel-lang#89
    (It was longer I expected :monkey:)
    Jose Maria Valera Reales
    @Chemaclass

    I just fixed the last PSALM errors to support error level 2! Thanks to all who improved the code quality towards this.

    WOW! Good job there! :D

    Jens Haase
    @jenshaase
    @mabasic I just finished the html template engine. There are not docs yet but maybe you want to check out the tests to get started: https://github.com/jenshaase/phel-lang/blob/master/tests/phel/test/html.phel
    Mario Bašić
    @mabasic
    @jenshaase Great news! I will try it out and let you know
    Mario Bašić
    @mabasic

    @jenshaase Ok, I have tried it. I understand the code and logic behind it and it feels elegant and simple once you wrap your head around it. My issue probably has nothing to do with the html library, but my lack of fp experience.

    How would you print a ul with li defined in an array?

    (def array @["one" "two" "three"])
    
    (print (html [:ul [<somekind of function here or ?>]] ))
    Mario Bašić
    @mabasic
    How would you wrap that in the whole html document? That would be one very huge function code.
    (print (html
        [:html
            [:head
                [:title "Title"]
            ]
            [:body
                [:p "Paragraph"]
            ]
        ]))
    Mario Bašić
    @mabasic
    Maybe functions or tuples which return parts of the code with variables, placeholders for adding more things..
    Jens Haase
    @jenshaase
    (html [:ul (for [x :in array] [:li x])]) should work for the first example
    Mario Bašić
    @mabasic
    Ahaaa. Do the loop and foreach produce the same output as for?
    Jens Haase
    @jenshaase
    second, you can defined functions. (defn base-html [title body] [:html [:head title] [:body body]])
    foreach always returns nil, while for returns an array. loop could work but i'm not sure.
    Mario Bašić
    @mabasic
    Thank you for explaining. I will try again.
    Mario Bašić
    @mabasic

    Ok, got it to work.

    (def array @["jedan" "dva" "tri"])
    
    (defn base-html [title body]
        [:html
            [:head
                [:title title]
            ]
            [:body body]
        ])
    
    (defn ul-html [array]
        [:ul (for [item :in array] [:li item])])
    
    (print (html (base-html "Stranica" (ul-html array))))

    I like it. Good work!

    @jenshaase Do you want me to help with the documentation? Maybe a "templating" chapter?
    I'm going to test testing now :)
    Jesus Valera Reales
    @JesusValera
    Awesome work Jens! :D
    Jens Haase
    @jenshaase
    Hi, just for your info: I was and still am a few days offline. Will merge your pull requests in a few days, hopefully.
    Mario Bašić
    @mabasic
    Good luck!
    Jesus Valera Reales
    @JesusValera
    Have fun!
    Jens Haase
    @jenshaase
    Finally added the documentation for HTML rendering: https://phel-lang.org/documentation/html-rendering/
    Mario Bašić
    @mabasic
    Took a quick look just now. Looks very good. Great job! I see that you have added list rendering 😊 and common use cases. Nice
    Jose Maria Valera Reales
    @Chemaclass
    Nice thing!
    Mario Bašić
    @mabasic
    @jenshaase I was thinking about creating a phel package for the package development documentation. I want it to be something useful. What do you think about a documentation generator or a code formatter for phel written in phel. Would it be doable? Open to suggestions
    Jose Maria Valera Reales
    @Chemaclass
    Actually, a code formatter would be really helpful and good to have. It would certainly help everyone to follow the same convention of writing phel independently from their website editor/ide
    Jens Haase
    @jenshaase
    A code formatter would be great but I think this is not something that can be done in a few hours. But if you like the idea go ahead!
    Jens Haase
    @jenshaase
    If have a few other ideas: A converter from phel datastructures to json and back (I would convert them to plain php arrays and then use json_encode). A wrapper around PDO to query a database. (Equivalent in the clojure world: https://github.com/seancorfield/next-jdbc)
    Mario Bašić
    @mabasic
    I like your ideas. The database wrapper seems interesting to me. Also json idea is nice. I might give it a try. The code formatter is something that I would like phel to have, but since I know nothing about it. It would take a long time.
    I might try writing an API for my website in Phel and then implement the mysql wrapper and maybe json.
    Mario Bašić
    @mabasic
    @jenshaase I have a question related to immutability. In the docs I have found only that there are three mutable data structures: Array, table and struct. Does that mean that there are other immutable or is the rest mutable. I have found in the docs that it says that tuple is an immutable. What is the state with mutability in Phel? Asking just out of curiosity. Also, the basic types are mutable or immutable. I think that that part is unclear in the documentation
    Jens Haase
    @jenshaase
    Only tuples are immutable. Everything else is mutable.
    Mario Bašić
    @mabasic
    I see, thank you.