ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <sam0x17> rustdocs handles this particularly well
<FromGitter> <sam0x17> might be something to copy
<FromGitter> <asterite> we need a way for shards to say where is the doc API url, then we'll be able to do interlink
<FromGitter> <watzon> Why not just give the generator the ability to run in the lib folder as well?
<FromGitter> <sam0x17> ^ the latter is what rustdoc does
<FromGitter> <sam0x17> that also has the advantage of pinning to the exact correct revision of all the libs
<FromGitter> <sam0x17> even if one was force-pushed
<FromGitter> <sam0x17> (since then)
<FromGitter> <watzon> It has certain advantages
<FromGitter> <watzon> For instance in my case
<FromGitter> <watzon> Every part of Cadmium is in the Cadmium namespace
<FromGitter> <watzon> So the generator should be able to keep everything grouped together under that namespace in the docs, even though their in separate shards
<FromGitter> <sam0x17> exactly
<FromGitter> <sam0x17> on that note, I was thinking last night my idea about automatically generated bindings from arbitrary rust crates could be facilitated by crawling docs pages to figure out what methods to generate
<FromGitter> <sam0x17> rust is super easy to FFI via crystal
<FromGitter> <sam0x17> so basically autogenerate crystal versions of all public structs (and traits as modules) in the crate, and then autogenerate the FFI code to call/use those from crystal
<FromGitter> <sam0x17> much easier to write something that crawls docs.rs than to write something that parses rust code (or adapt the compiler) xD
sagax has quit [Ping timeout: 244 seconds]
<FromGitter> <watzon> Interesting
<FromGitter> <watzon> Speaking of versioning that's another thing the doc generator needs to support
livcd has quit [Ping timeout: 246 seconds]
alex`` has quit [Ping timeout: 245 seconds]
chemist69 has quit [Ping timeout: 264 seconds]
chemist69 has joined #crystal-lang
<FromGitter> <galvertez> is there anything special about `<library module name>::VERSION` that requires it to be a string? i.e. does shards use it or
DTZUZU has quit [Ping timeout: 272 seconds]
mistergibson has quit [Quit: Leaving]
lvmbdv has quit [Ping timeout: 258 seconds]
lvmbdv has joined #crystal-lang
lvmbdv has quit [Ping timeout: 244 seconds]
DTZUZU has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter> <watzon> @galvertez no it's just a convention that's a holdover from Ruby
sagax has joined #crystal-lang
alex`` has joined #crystal-lang
lvmbdv has joined #crystal-lang
<FromGitter> <asterite> So every shard doc will include docs for transitive dependencies, including the standard library? How do you find out what types are provided by the actual library and not its dependencies? Maybe separated somehow in the left side bar?
<FromGitter> <asterite> And how to avoid including the entire standard library in every shard?
DTZUZO has quit [Ping timeout: 244 seconds]
<FromGitter> <ArtLinkov> Hey all, A question regarding pgsql ⏎ How do I make a query that returns a multi-row object? (I mean without iteration of the query with "something" do |rs| etc...) ⏎ I tried using json serialization, but it only works for queries that return a single row ⏎ example: ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5d63bade4b1189084e687ec5]
<FromGitter> <andrius> Hello, curious what macro arguments shall I use, I want to list embedded classes. Lines 10 and 15: https://play.crystal-lang.org/#/r/7gcv
<FromGitter> <j8r> Don't know if it's possible to list a subclasses of a module/class
<FromGitter> <j8r> it is, wait
<FromGitter> <alehander42> @sam0x17 maybe rust exposes a parser
<FromGitter> <alehander42> most modern languages come with some builtin way to parse themselves
<FromGitter> <Blacksmoke16> i dont think you can get classes that include a given module
<FromGitter> <alehander42> which is better than scraping docs
<FromGitter> <alehander42> (if not, i agree your idea sounds better)
<FromGitter> <andrius> @Blacksmoke16 but subclasses/structs included within a class?
<FromGitter> <Blacksmoke16> i.e. you want an array of all classes that inherit from a parent class?
<FromGitter> <Blacksmoke16> then what @j8r linked would do the job
<FromGitter> <Blacksmoke16> there is also `all_subclasses` that includes subclasses of the direct subclasses
<FromGitter> <alehander42> in anyway, one would need to write the parser in rust itself (or to just expose the parser crates to crystal and write one then), but it should be possible, you can also look at treesitter: iirc it is used succsefully in nim for autogenerating wrappers
<FromGitter> <j8r> got it
alex`` has quit [Ping timeout: 246 seconds]
<FromGitter> <j8r> @andrius https://play.crystal-lang.org/#/r/7gd5
<FromGitter> <andrius> @j8r oh thank you!
<FromGitter> <j8r> note the first isn't exactly what you want
<FromGitter> <j8r> @andrius updated, returns exactly what you want. A bit ugly. For some reasons it doesn't compile online, but locally it works: `{{@type.subclasses.map {|t| t.constants.map { |sub| (t.stringify + "::" + sub.stringify).id } } }}`
<FromGitter> <j8r> in the `subclasses` class method
<FromGitter> <asterite> @ArtLinkov I think it's `db.query_all "...", as: Response`
<FromGitter> <Blacksmoke16> what about `Array(Response).from_rs(db.query "SELECT * FROM table;")`
<FromGitter> <Blacksmoke16> :shrug:
DTZUZO has joined #crystal-lang
<FromGitter> <ArtLinkov> @asterite It works! Thanks! ^^
<FromGitter> <ArtLinkov> As a side note, I coudln't find 'db.query_all' anywhere... I think the Database docs could be made a bit better :)
Liothen has joined #crystal-lang
<FromGitter> <asterite> Yeah, the docs could be improved. The method is listed here: http://crystal-lang.github.io/crystal-db/api/0.6.0/DB/QueryMethods.html (included by `DB::Connection` and others)
<FromGitter> <ArtLinkov> Got it, thanks again
n7olkachev has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
n7olkachev has quit [Quit: WeeChat 2.4]
sz0 has joined #crystal-lang
<FromGitter> <sam0x17> @j8r here is an even more powerful tool for reverse-engineering docker images: https://github.com/wagoodman/dive
woodruffw has quit [Ping timeout: 258 seconds]
woodruffw has joined #crystal-lang
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
woodruffw has quit [Ping timeout: 245 seconds]
woodruffw has joined #crystal-lang
alex`` has joined #crystal-lang
sorcus has joined #crystal-lang
alex`` has quit [Ping timeout: 272 seconds]
alex`` has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <naqvis> Just published *Pure Crystal* Jabber/XMPP library (https://github.com/naqvis/cr-xmpp)
lvmbdv has quit [Ping timeout: 248 seconds]
lvmbdv has joined #crystal-lang
<rkeene> What's the PKCS#11 story like on Crystal ? Just let OpenSSL do it, or is there a library that helps ?
<FromGitter> <asterite> @naqvis awesome!
<FromGitter> <naqvis> Thank you @asterite
sorcus has quit [Quit: WeeChat 2.5]
sorcus has joined #crystal-lang
<FromGitter> <bew> @bcardiff your tweet about unit types, I don't get it is it a new thing?
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <bcardiff> @bew you could say it's a new usage of existing features. While playing with something like unit types, typing `TheUnitType.new` seems redundant. Why we can't type only `TheUnitType` and use it as a value. It turned out that you can. `module TheUnitType; extend self; end;` Then the module turned out to be a value of its own type.
<FromGitter> <watzon> Very cool @naqvis
<FromGitter> <watzon> may actually use that at some point
<FromGitter> <j8r> @sam0x17 It reminds me something, I may have seen it before. Definitely handy and powerful indeed
sagax has quit [Ping timeout: 272 seconds]
sagax has joined #crystal-lang
<FromGitter> <naqvis> thank you @watzon
<FromGitter> <absolutejam_gitlab> wait, so is a module a type/
<FromGitter> <watzon> @absolutejam_gitlab what do you mean?
<FromGitter> <Blacksmoke16> they can be used as an interface yes
<FromGitter> <Blacksmoke16> anything that includes a module is also that module
n7olkachev has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> That's awesome
n7olkachev has quit [Client Quit]
<FromGitter> <Blacksmoke16> depending on the context, sometimes inheritance makes more sense, others (if its just a mixin for example, like `Comparable`) then a module makes more sense
<FromGitter> <absolutejam_gitlab> I like to think of inheritance as pretty vertical but an interface is more horizontal, in that you can just add it in to an existing Class and have it work with a method
<FromGitter> <absolutejam_gitlab> and if you're not in control of the class
<FromGitter> <Blacksmoke16> inheritance is good when there is common logic that is shared between types, and each child is just implementing the logic specific for that type
<FromGitter> <Blacksmoke16> i also like inheritance since you can get the children at compile time
<FromGitter> <Blacksmoke16> which you cant do with modules/annotations (yet)
<FromGitter> <absolutejam_gitlab> TIL
<FromGitter> <Blacksmoke16> custom assertions work since the macro finished would resolve all types before defining the annotations
<FromGitter> <Blacksmoke16> i.e. just by inheriting, it "registers" itself
<FromGitter> <Blacksmoke16> but yea, really depends on the context, but is good to have both at your disposal
<FromGitter> <absolutejam_gitlab> I like it
<FromGitter> <absolutejam_gitlab> I know you've done a blog post, but have you done bits about the auto registering etc?
<FromGitter> <absolutejam_gitlab> It's these pieces that fascinate me
<FromGitter> <absolutejam_gitlab> Hopefully annotations get a bit more spotlight too
<FromGitter> <Blacksmoke16> was planning on a short one to talk about the new pattern i came up with
<FromGitter> <Blacksmoke16> https://gitter.im/crystal-lang/crystal?at=5d5b2c4e9507182477104290 prob already saw it but thats the idea
<FromGitter> <Blacksmoke16> map an annotation to a class then double_splat it to new up the class/struct
<FromGitter> <Blacksmoke16> using inheritance to do the auto registering
<FromGitter> <Blacksmoke16> ☝️ August 19, 2019 7:15 PM (https://gitter.im/crystal-lang/crystal?at=5d5b2d9e4e17537f52651cba) starting here
<FromGitter> <Blacksmoke16> ill prob do one after its released
<FromGitter> <absolutejam_gitlab> these patterns are a really awesome part of Crystal
<FromGitter> <absolutejam_gitlab> Writing something in Golang and I miss this
<FromGitter> <Blacksmoke16> be even better once https://github.com/crystal-lang/crystal/pull/7648 is figured out
<FromGitter> <Blacksmoke16> then, for the cases where the children dont share common logic, i.e. inheritance isnt needed, could just get the array based on types annotated with x
<FromGitter> <Blacksmoke16> but yea, is quite slick
<FromGitter> <tenebrousedge> I wish Crystal had a `method` method
<FromGitter> <Blacksmoke16> that does what?
<FromGitter> <tenebrousedge> well, because this doesn't work ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d644b9ddbf5ae2d42cd1799]
<FromGitter> <tenebrousedge> you get `undefined variable s`
<FromGitter> <tenebrousedge> and a `method` method sounds easier than trying to make that syntax work
<FromGitter> <Blacksmoke16> got an example of what that would look like?
<FromGitter> <watzon> @tenebrousedge so something like this? https://carc.in/#/r/7gh6
<FromGitter> <tenebrousedge> @watzon yes, you can do that inside the block
<FromGitter> <tenebrousedge> but in Ruby you can do ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d645181f2821072aa1c2d21]
<FromGitter> <tenebrousedge> and the `s.downcase.chars` is evaluated outside the block
<FromGitter> <watzon> Hmm interesting
<FromGitter> <tenebrousedge> Crystal can do ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d6452093c1aba311bd80c05]
<FromGitter> <tenebrousedge> it's slightly buggy
<FromGitter> <watzon> I'm confused as to why that works at all, but then I've never really used the `&->` syntax
<FromGitter> <tenebrousedge> ```a = 15; [5, 7, 3].map(&->a.divisible_by?(Int32)) ⏎ #=> [false, false, false]``` [https://gitter.im/crystal-lang/crystal?at=5d64528f022dba538e66e4fc]
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <tenebrousedge> in real code, I find that wanting to do this is often a mistake, where the method should actually be defined elsewhere
<FromGitter> <tenebrousedge> but it's not always convenient to do so
<FromGitter> <tenebrousedge> `method` should probably be doable, at least as a macro
<FromGitter> <tenebrousedge> I think it needs some form of `send`
<FromGitter> <kinxer> I messed with this a little and I can see why you're unhappy with what exists. This is what I got (probably even less performative than @watzon's solution: https://carc.in/#/r/7ghu/edit
<FromGitter> <tenebrousedge> actually that's probably not bad performance-wise
<FromGitter> <kinxer> And if you don't need `ALPHABET` to be an array in the first place, https://carc.in/#/r/7ghw
<FromGitter> <tenebrousedge> yes, sets work for that
<FromGitter> <tenebrousedge> but the problem isn't relevant
<FromGitter> <kinxer> Ah... So this doesn't work for your actual use-case, then?
<FromGitter> <tenebrousedge> just a convenient way to discuss the syntax
<FromGitter> <tenebrousedge> I also don't (currently) have a real use-case, it's just something that I often want to do, that only half-works
gangstacat has joined #crystal-lang
lvmbdv has quit [Ping timeout: 248 seconds]
lvmbdv has joined #crystal-lang
lvmbdv has quit [Ping timeout: 246 seconds]
lvmbdv has joined #crystal-lang
chachasmooth has quit [Ping timeout: 245 seconds]
chachasmooth has joined #crystal-lang