I'm Giacomo, I love functional programming and learning new things ✨
@gleam-lang core team member 💕
✨ A package to help you easily pretty print structured data
Home Page: https://hexdocs.pm/glam/
License: Apache License 2.0
I'm Giacomo, I love functional programming and learning new things ✨
@gleam-lang core team member 💕
I could add a "useful resources" section to list all the tutorials/examples/libraries that use glam
Ideally I should add at least a couple more tutorials before doing that, a list with a single bullet point would be sad :(
I'm weak for packages with logos like Nakai and I'd love to add one here as well
Also if I ever do this I should remember to use it for the social preview
I'd like to add some tests for the examples that are shown in the library.
This would be beneficial in two ways:
I feel like this shouldn't be too complicated, especially if one has already walked through the package's tutorials.
Basically, what one would need to do is:
x_to_doc
functions to test publictests
folder to add the tests for each pretty printer@bcpeinhardt pointed out that it may be handy to have a doc.nest_docs
that can take a list of documents and concat them together adding a given nesting. This would be analogous to doc.append
/doc.append_docs
Closing this issue would require
doc.nest_docs
functionI think the function should have the following signature:
pub fn nest_docs(docs: List(Document), by nesting: Int) -> Document { ... }
And the implementation could be as simple as concatenating the docs and wrapping everything with a doc.nest
. There should be some tests to check that it works properly, though :)
I should add support for zero width strings, that is strings that are simply appended to the text without increasing the width of the string. This would be really useful to properly handle ansi color codes
Since this package is so similar to Elixir's Inspect.Algebra
I could add more tests taking as a reference the ones they use. The API is quite similar so it wouldn't be too hard to port those
Adding this shouldn't be too hard if you can read a bit of Elixir.
Basically, what one would need to do is:
Inspect.Algebra
's testsglam/doc_test
moduleInspect.Algebra
's documentationInspect.Algebra
's functions into the corresponding glam
one. The API is quite similar but things may have different namesIt would be lovely to add a debug
function that turns a document into a pretty document showing its structure with a nice format to help debugging complex documents.
Informally:
doc.group(•) ~> [•]
doc.concat([•,…,•]) ~> • . … . •
doc.nest(•, by: n) ~> ⟨•⟩ⁿ
doc.break(•, •) ~> {•, •}
doc.flex_break(•, •) ~> {•, •}
doc.from_string(•) ~> "•"
doc.force_break(•) ~> force(•)
doc.lines(n) ~> lfⁿ
An example with a concrete document:
[
doc.from_string("foo"),
doc.space,
doc.from_string("bar"),
[
doc.from_string("baz"),
doc.space,
doc.from_string("foo again"),
]
|> doc.concat
|> doc.nest(by: 1)
|> doc.group
]
|> doc.join(with: doc.line)
|> doc.nest(by: 12)
|> doc.debug
|> doc.to_string(45)
// ->
// ⟨
// "foo" . lf . {" ", ""} . lf . "bar" . lf .
// [ ⟨ "baz" . {" ", ""} . "foo again" ⟩¹ ]
// ⟩¹²
Maybe since doc.space
is quite common it could be turned into something shorter like ~
:
// ->
// ⟨
// "foo" . lf . ~ . lf . "bar" . lf .
// [ ⟨ "baz" . ~ . "foo again" ⟩¹ ]
// ⟩¹²
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.