return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<crystal-gh>
[crystal] lipanski opened pull request #5726: Introduce a parallel! macro to re-raise exceptions from fibers (master...parallel_raise) https://git.io/vAltz
qard has quit [Quit: qard]
<crystal-gh>
[crystal] CaDs opened pull request #5727: Handle [CMD/CTRL]+S on Playground (master...feature/playground_binding_cmd_s_and_ctrl_s_to_run_code) https://git.io/vAlqY
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 276 seconds]
devil_tux has quit [Quit: leaving]
maattdd_ has joined #crystal-lang
sevensidedmarble has quit [Quit: WeeChat 2.0-dev]
<watzon>
Papierkorb: I fixed several bugs. Arrays now generate correctly. I decided that rather than having them generate classes they'd do NamedTuples
<Papierkorb>
NamedTuples aren't storage structures, they're transfer structures.
<Papierkorb>
don't use them outside of macros or mass-passing (named) arguments to functions
<watzon>
Do you think I should use a Hash instead?
<Papierkorb>
No, it should simply be a normal class
<Papierkorb>
Not to mention that typing stuff[:like_this] isn't crystal-y
radagast_04 has quit [Ping timeout: 268 seconds]
<watzon>
True
<watzon>
I am pretty happy with how Arrays are working now though. Granted there are probably some edge cases that I haven't found yet, but it works nicely
<watzon>
I'm planning on adding some toggles soon so that you can turn on things like `allNillable` to make everything nilable, or `compact` to remove the extra whitespace
<Papierkorb>
Ideally, the generated output would be used by the programmer to further enhance it
<Papierkorb>
E.g. adding verifications, or transformations (String -> Time)
<watzon>
Right, that is the general idea
<maattdd_>
Papierkorb: Actually coming from Ruby, I'm more used to foo[:bar] than foo.bar
<Papierkorb>
maattdd_: That's a ruby paradigm though, and it has always sucked, even there
<maattdd_>
But I think I've found a compiler bug by abusing usage of NamedTuple
<Papierkorb>
Typing foo.bar is so much faster
<maattdd_>
(a crash during a GC reclaim)
<Papierkorb>
maattdd_: Quite possible, if you can reduce it, please open a github issue showcasing it
<maattdd_>
I will convert the code to plan class and see if it resolves it
<maattdd_>
s/plan/plain
<watzon>
Papierkorb: I agree, symbols have never been my favorite thing
alex`` has quit [Ping timeout: 276 seconds]
hightower2 has quit [Ping timeout: 260 seconds]
<watzon>
The only problem I have with having an object inside of an array generate a class is that said object doesn't have a key attached to it, which means I have to generate a random name for the class
<watzon>
It's also a lot harder to merge similar ones, so if two objects are just one property off they'll become completely different classes
<Papierkorb>
just count upwards, or maybe something like "<Parent>Child<Count>"
<Papierkorb>
Of course, but even if you'd merge, you wouldn't know if they're actually supposed to inherit from one another anywa
<Papierkorb>
y
<watzon>
True
maattdd_ has quit [Ping timeout: 260 seconds]
faustinoaq has joined #crystal-lang
radagast_04 has joined #crystal-lang
woodruffw has quit [Ping timeout: 276 seconds]
woodruffw has joined #crystal-lang
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
mooe has quit [Quit: Connection closed for inactivity]
<FromGitter>
<bararchy> without this change I can't make this example work
<RX14>
but you can do it
<FromGitter>
<bararchy> and with it, half of Crystal breaks
<FromGitter>
<bararchy> how ?
<RX14>
i mean what's the usecase anyway
<Papierkorb>
I still wonder why that dumpsterfire got merged
<RX14>
because it's not a dumpsterfire and it makes a lot of practical sense
<FromGitter>
<bararchy> well, I need to "shove" a `Char|String` instead of each parts of the JSON schema values, and then get back an array of each new "composition"
<RX14>
we need to go up a level of "why"
<RX14>
maybe quite a few
<FromGitter>
<bararchy> if you mean "what I need it for", then it's part of NexPloit, our solution for vunrebility scanning, this is an easy way to inject payloads into a JSON schema to test API's for crashes
<FromGitter>
<bararchy> part of REST fuzzing
<FromGitter>
<bararchy> I did it until now using gsub and string replacment, but it's a pain
<FromGitter>
<bararchy> and Regexp will crash sometimes when getting wierd payloads
<RX14>
i mean i'd probably reach for a pullparser here
<FromGitter>
<bararchy> pullparser ?
<RX14>
yeah
<RX14>
it's simple
<RX14>
you just use a pullparser and json writer in sync
<RX14>
and you count the "value" tokens
<RX14>
such as strings, numbers, etc and keep replacing them when pushing out json
<RX14>
hmm
<RX14>
it's harder than that
<RX14>
but it's simpler in my head than oprypin's solution
<Papierkorb>
modifying the pull parser isn't fun. Question is how that's formatted, if that's still even JSON or not
<RX14>
i didn't mean modify anything
<RX14>
@bararchy do you even fuzz by removing keys entirely?
<RX14>
because that solution doesn't cover that
<FromGitter>
<bararchy> yeha
<RX14>
good
<RX14>
@bararchy in 0.24.1 you'd use `JSON::Type` and parse_raw
<RX14>
@bararchy you can do it just fine with 0.24.1 without a pullparser
<RX14>
except the memory usage is far higher
<RX14>
since you're creating every single permutatin in memory
<RX14>
which is fairly ugly
<FromGitter>
<bararchy> it's fine, we got "endless" amount of it :)
rohitpaulk has quit [Ping timeout: 255 seconds]
<RX14>
...
<RX14>
try that with a 1gb json document
<FromGitter>
<bararchy> each instance is 128Gb of RAM
<RX14>
you will end up with more memory usage than there are atoms in the universe
<RX14>
i suspect
<RX14>
the whole thing "feels" O(2^n) memory usage or something insane
<FromGitter>
<bararchy> For now this is the least of my worries, but TBH I still didn't understand how you would suggest to do it, can you show me a small example? or did you just meant change those little things in oprypin's example (JSON::Any, JSON::Type) and the .to_h
<RX14>
yes
<RX14>
i'm suggesting two things
<RX14>
how to adapt oprypin's example for 0.24.1
<Yxhuvud>
otoh, rehashing after every change seems also very expensive
<FromGitter>
<bararchy> RX14 it works great, thanks for that :)
<RX14>
np
<hightower2>
If I want to "alias" method Some::Module::long_name() to shortname(), what's my best bet to do that?
alex`` has joined #crystal-lang
<lvmbdv>
hightower2: proc assignment
<lvmbdv>
but you can only call it with shortname.call()
<lvmbdv>
shortname = ->A::B::long_name()
<hightower2>
Yes, that doesn't allow me to call just shortname(), it requires me to do .call()
rohitpaulk has joined #crystal-lang
<RX14>
no
<RX14>
hightower2, just private alias Foo Some::Module
<RX14>
then use Foo.long_name
<RX14>
you can alias out long module chains
<RX14>
but nothing more
<hightower2>
Ok, thanks
radagast_04 has quit [Ping timeout: 240 seconds]
hightower2 has quit [Ping timeout: 255 seconds]
hightower2 has joined #crystal-lang
<FromGitter>
<aisrael> Pardon my ignorance, but what’s the easiest way to convert an `Array` to a `Tuple`? Use case: dynamic arguments to `DB#exec(sql, *args)`
<oprypin>
aisrael, you can't, that's kinda the point
<oprypin>
on the other hand, db exec has no business accepting only a tuple
<oprypin>
aisrael, does it perhaps have a different way to accept arguments?
<FromGitter>
<aisrael> Which is probably the only way to go if whatever you’re calling only accepts `*args` but not `args : Array)`
<oprypin>
aisrael, glad that you went through the experience because even if there was an automated way to convert an array to a tuple, that's what it would boil down to
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<aisrael> Is there an easy way for a class with declared `YAML.mapping(…)` to be built/constructed from a `YAML::Any`? That is, am mid way through (manually) parsing a complex YAML, but I want to extract a simple object from it (that has a `YAML.mapping(…)`)...
faustinoaq has joined #crystal-lang
<FromGitter>
<aisrael> Can I create a `YAML::PullParser` from an already parsed YAML node (a `YAML::Any`), or do I have to dump that node and its children to a string, then `Foo.from_yaml(s)` it?
<FromGitter>
<aisrael> Ok, I just found out I could do `Foo.from_yaml(node.to_yaml)` which actually makes a lot of sense when you read it :D Just has some string conversion & parsing overhead but I’ll live with that for now
<oprypin>
well it's what you said "dump that node and its children to a string, then ..."
<oprypin>
yes it's bad and yes it should be improved
<FromGitter>
<aisrael> Gotcha. Just wondering if there was a better way than brute force ;)
alex`` has quit [Ping timeout: 255 seconds]
alex`` has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
faustinoaq has quit [Quit: IRC client terminated!]
woodruffw has quit [Ping timeout: 256 seconds]
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
woodruffw has joined #crystal-lang
faustinoaq has joined #crystal-lang
ua has quit [Remote host closed the connection]
ua has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
faustinoaq has joined #crystal-lang
rohitpaulk has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
DTZUZU has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
DTZUZU has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
rohitpaulk has joined #crystal-lang
faustinoaq has joined #crystal-lang
bijan_ has joined #crystal-lang
moei has joined #crystal-lang
woodruffw has quit [Ping timeout: 264 seconds]
bijan_ has quit [Quit: Shutting Down Interwebs...Done.]