ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | 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> <galvertez> so as you can see, the result is used to instantiate the response object. *then* it gets serialized
<FromGitter> <galvertez> what i really want is a proc that will return any type, as long as that type has `#to_json`
<FromGitter> <bew> I repeat, why not serialize in the proc?
<FromGitter> <galvertez> because then it would be `Response(String)` and it would escape the already serlialized json
<FromGitter> <bew> yes, why do you need a Response object ?
<FromGitter> <galvertez> that's how the specification works
<FromGitter> <galvertez> http://www.jsonrpc.org/specification
<FromGitter> <galvertez> i'm implementing this spec
<FromGitter> <bew> why is it a generic?
<FromGitter> <galvertez> because the `result` key is not knowable
<FromGitter> <bew> you could have `result` of Response be the result of the proc call
<FromGitter> <galvertez> until you actually start using it
<FromGitter> <bew> and that be a json object
<FromGitter> <galvertez> that is exactly what i'm trying to do
<FromGitter> <bew> by json object I don't mean a JSON::Any or JSON::Type
<FromGitter> <galvertez> do you mean a string?
<FromGitter> <bew> yeah for example, that's one way to resolve this
<FromGitter> <galvertez> ok... but that would assume that i already know what any user of the shard is going to return.
<FromGitter> <codenoid> hi, is there any "shorthand" for ⏎ ⏎ ```Signal::TERM.trap { exit 1 } ⏎ Signal::KILL.trap { exit 1 } ⏎ Signal::INT.trap { exit 1 }``` [https://gitter.im/crystal-lang/crystal?at=5b0b499ba7abc8692eebbd71]
<FromGitter> <galvertez> if i already serialized the result, then when i serialize the response containing the result, it escapes the already serialized json
<FromGitter> <bew> @codenoid note: you can't catch sigkill, and why do you need to catch them?
<FromGitter> <bew> @galvertez if you don't need to store it, you don't really need to know the type
<FromGitter> <codenoid> to call at_exit,
<FromGitter> <galvertez> the reason `Response(T)` is a generic is because clientside, `T` can be anything with a `JSON.mapping`, so the type needs to be serializable by json. ⏎ i am using `JSON::Any` on serverside, specifically because i agree with you, i don't care about the type. i just need it to exist long enough to be placed inside a response and then serialized.
<FromGitter> <galvertez> this is not the problem i'm having though. a user of this shard will want to write rpc methods (rpc methods being distinct from crystal methods) and the rpc will need to be able to key off of `request.name` to decide what to do. those instructions need to be stored somewhere, so a `{} of String => JSON::Any -> JSON::Any` is necessary.
<FromGitter> <bew> @galvertez https://play.crystal-lang.org/#/r/45pb
<FromGitter> <bew> not perfect, but it can lead you to something ;)
<FromGitter> <bew> and there's no macro ;)
<FromGitter> <galvertez> ok but that's already a closed object
<FromGitter> <bew> you can add the necessary fields line 27
<FromGitter> <galvertez> the `result` key belongs to the `Response` object. and i do not want it to be serialized inside the proc. because then when i serialize the response, it will re-serialize an already serialized json
<FromGitter> <galvertez> mmm
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 260 seconds]
<FromGitter> <galvertez> yeah actually the more i think about it the more i think i can make that work
<FromGitter> <galvertez> so then the proc would actually return a fully serialized response, rather than wishy-washy JSON::Any result object
pabs has quit [Ping timeout: 240 seconds]
<FromGitter> <galvertez> and it would accept the whole request rather than just the params. then the user defines an inner proc which can be more flexible type-wise
<FromGitter> <galvertez> thanks @bew for the consideration
<FromGitter> <galvertez> i don't think we ever got on the same page but you definitely got me thinking of alternatives
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
pabs has joined #crystal-lang
<FromGitter> <bew> you got it :) glad I could help!!
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZO has joined #crystal-lang
<FromGitter> <galvertez> yep, got it working. and without a macro after all
<FromGitter> <galvertez> i somehow got stuck on the idea that the `Response` didn't need to be serialized right away. everything's much easier when the return type is always a `String`
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ is now known as p0p0pr37
<FromGitter> <bew> Hehe, nice ;)
Nathanaelle has quit [Ping timeout: 260 seconds]
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37_ is now known as p0p0pr37
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 260 seconds]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
alex`` has quit [Ping timeout: 252 seconds]
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 248 seconds]
Nathanaelle has quit [Ping timeout: 256 seconds]
Nathanaelle has joined #crystal-lang
ua_ has quit [Ping timeout: 252 seconds]
ua has joined #crystal-lang
Nik736 has joined #crystal-lang
<livcd> /join #windows-server
<FromGitter> <bararchy> A desktop made in python ... and JavaScript.... https://www.phoronix.com/scan.php?page=news_item&px=Linux-Jade-Desktop-Environment
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 256 seconds]
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
DTZUZO has quit [Ping timeout: 276 seconds]
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 245 seconds]
fifr[m] has quit [*.net *.split]
z64 has quit [*.net *.split]
z64 has joined #crystal-lang
fifr[m] has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <fgimian> Hey there guys, hope you're all doing great 😄
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
<FromGitter> <fgimian> I've been working on an idea similar to the following in Python: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0bd8e4361a950a661f4b18]
<FromGitter> <fgimian> this allows you to write a custom handler for different tags in YAML which processes the data and replaces it with something else
<FromGitter> <fgimian> if you've ever used AWS CloudFormation, you'll know all about Intrinsic Functions which also use this approach
<FromGitter> <fgimian> This is how far I've gotten: https://gist.github.com/fgimian/7ac343880045b8d303bf8b260d09cf59
<FromGitter> <fgimian> However, I'm having a few challenges (see the TODOs); any help is greatly appreciated
<FromGitter> <fgimian> Please note that this is being developed directly against Crystal master branch (which has different behaviour to the 0.24.2 release)
p0p0pr37 has quit [Ping timeout: 240 seconds]
p0p0pr37_ is now known as p0p0pr37
Nathanaelle has joined #crystal-lang
alex`` has quit [Ping timeout: 276 seconds]
<FromGitter> <fgimian> I've just solved the first problem after much tinkering
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0be1fd16f6496124e7ba6b]
<FromGitter> <fgimian> onto the next 😄
csk157 has joined #crystal-lang
<FromGitter> <fgimian> Determined the fix for the `super` call for passing control of the block (via https://github.com/crystal-lang/crystal/issues/3581) ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0be861160c567d16e2df42]
<FromGitter> <fgimian> one more TODO to go 😄
Nathanaelle has quit [Ping timeout: 256 seconds]
Nathanaelle has joined #crystal-lang
return0e_ has quit [Ping timeout: 245 seconds]
return0e has joined #crystal-lang
<FromGitter> <Grabli66> Hi! How to filter enumerable of some type to enumerable of another type?
<FromGitter> <aisrael> `.map()`?
<FromGitter> <Grabli66> I dont want nil in new array
<FromGitter> <aisrael> `.compact_map()`?
<FromGitter> <Grabli66> Thanks. It works
<FromGitter> <Grabli66> And why, in the name of God, it returns new array, not a enumerable? :)
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #crystal-lang
<FromGitter> <yxhuvud> Because it is an Enumerable and Enumerable methods tend to compute the result. Iterable support compact_map too, so use that if you don't want the intermediaries
<crystal-gh> [crystal] asterite closed pull request #6128: Fix: detect error when trying to use unbound generic type in instance var (master...bug/5383-unbound-generic-type) https://git.io/vhI3p
<FromGitter> <Grabli66> Cool. It works.
<crystal-gh> [crystal] RX14 reopened pull request #5571: Compiler: ensure parentheses inside assign value (master...bug/5568-op-assign) https://git.io/vN3sf
<crystal-gh> [crystal] RX14 closed pull request #5571: Compiler: ensure parentheses inside assign value (master...bug/5568-op-assign) https://git.io/vN3sf
<FromGitter> <j8r> OMFG @asterite as done a BIG issue cleanup 😱
bmcginty has quit [Ping timeout: 268 seconds]
<FromGitter> <Grabli66> No issue, no problem. :)
<FromGitter> <fgimian> oh wow, down to 519 issues!
<FromGitter> <fgimian> that's like 40 less than an hour ago when I looked right?
bmcginty has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <Grabli66> Then he will merge all pull requests :)
<FromGitter> <vladfaust> The
<FromGitter> <vladfaust> Sorry, mobile gitter sucks!
<RX14> no ary just closed all his issues
<RX14> regardless of if its valid or not
<FromGitter> <j8r> 👍 @vladfaust on mobile it sends the message when we go out the page
<FromGitter> <j8r> @RX14 why?!
<FromGitter> <j8r> he goes to vacations, or sort of?!
<oprypin> i think people should shout if something was closed incorrectly
Nathanaelle has quit [Ping timeout: 252 seconds]
<oprypin> eh it's not so bad
<oprypin> mostly things that only asterite would know how to implement, anyway :|
<oprypin> mostly agree
<FromGitter> <manveru> so... i was asking the other day how to make an array like `Array(String | Int32)` but that doesn't fail compilation just because it's `["hi"]` and not `["hi", 1]`, does anyone know a solution to that?
<oprypin> manveru, so what, you want to make it fail compilation?
<FromGitter> <drujensen> #2549 as well
<DeBot> https://github.com/crystal-lang/crystal/issues/2549 (Make `responds_to?` match all arguments)
<oprypin> agree
<FromGitter> <manveru> oprypin: more if there's a better way to write such things: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0c0bf3ba1a351a68cde1f7]
<FromGitter> <manveru> or is that standard
<FromGitter> <j8r> @manveru you will quickly learn to avoid as much as possible union type - they are harder to handle 😄
<oprypin> so, first of all, above you'll see an issue about removing recursive aliases. but they do work. i just still don't quite get what you're trying to achieve
<FromGitter> <yxhuvud> @manveru either Array(String | Int32).new or ["foo"] of String | Int32
<oprypin> probably mainly because on mobile and gitter shows 10 characters of code width-wise
<FromGitter> <manveru> heh
<FromGitter> <yxhuvud> also aliases doesn't handle generic arguments very well
<FromGitter> <manveru> well, my version compiles fine, and it works well, it's just a bit annoying
<oprypin> definitely should just be Array(Array(String | TableRowLink))
<oprypin> then see yxhuvud's advice
<oprypin> or just make that class support the case of string and all unions are gone
<FromGitter> <manveru> TableRowLink is an alias for NamedTuple(text: String, href: String)
snsei has joined #crystal-lang
<oprypin> should have been a struct
<FromGitter> <drujensen> What about creating a class or structure for TableRowLink
<FromGitter> <drujensen> lol
<oprypin> and instead of String you use a TableRowLink without a link. and uh rename it to not contain 'link' in the name
<FromGitter> <drujensen> nilable
<oprypin> i just had a sudden realization
<oprypin> are unions always code smells just like namedtuples?
<FromGitter> <drujensen> hhmm
<FromGitter> <drujensen> I use them from db queries where I don’t know the type being returned and allow for multiple types. DB::Types for example
<FromGitter> <drujensen> how would you recommend doing that?
<FromGitter> <drujensen> also great for duck typing
<FromGitter> <drujensen> but in theory I could create a base class
<oprypin> well alright, "just like namedtuples" means it's fine for passing things in and out of methods, but perhaps not for storage
<FromGitter> <manveru> what's wrong with named tuples?
<oprypin> their only designed purpose is to store keyword arguments of methods, and for every other case there are better alternatives.
DTZUZO has joined #crystal-lang
<FromGitter> <drujensen> Each data structure has a purpose and clean code will always define its classes/structures to represent that data. Using a `NamedTuple` in many cases does not reflect the purpose of the data being stored. It is better to define a class or structure with a well defined name that reflects that data. `Dog(name: String, age:Int)` instead of `NamedTuple(name:String, age:Int)`
<oprypin> that, and `dog[:age]` is annoying
<FromGitter> <drujensen> haha, true
alex`` has quit [Ping timeout: 240 seconds]
<FromGitter> <fridgerator> I have a strange issue that I haven't been able to figure out. My sqlite specs fail in travis, I cant replicate locally in OSX or Ubuntu.
<FromGitter> <fridgerator> If I add these `puts`, then the specs pass: https://github.com/Crecto/crecto/blob/master/spec/transactions_spec.cr#L34-L38
<FromGitter> <fridgerator> If I remove them, the specs fail with a `UNIQUE constraint failed: users.unique_field` : https://travis-ci.org/Crecto/crecto/jobs/384773177
<FromGitter> <fridgerator> some kind of weird race condition?
<FromGitter> <S-YOU> How about puts without interpolations like `#{}` or even LibC.printf("test\n")?
<FromGitter> <S-YOU> #{} involve string builder, and puts itself involve FileDescriptor, which related to Fiber and may be even Stack Switching..
csk157 has quit [Ping timeout: 252 seconds]
<FromGitter> <S-YOU> Or may be database didn't flush fast enough on that file system and Repo.all(User) could give some time to it.
moei has quit [Read error: Connection reset by peer]
moei has joined #crystal-lang
Nathanaelle has joined #crystal-lang
<crystal-gh> [crystal] bcardiff opened pull request #6141: Fix #6136. Remove no longer used Dockerfile (master...fix/dockerfile) https://git.io/vhYKT
alex`` has joined #crystal-lang
faustinoaq has joined #crystal-lang
faustinoaq has quit [Ping timeout: 252 seconds]
<FromGitter> <fridgerator> I'll have to try using different puts methods. The hardest part is I can't replicate locally 😅
Nathanaelle has quit [Ping timeout: 245 seconds]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
<FromGitter> <r00ster91> Hello i'm trying to use Crystal on Windows. I followed the steps on https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows. ⏎ When i'm cloning the Crystal repository and then doing this in it: `bin/crystal build --cross-compile --target x86_64-pc-windows-msvc hello_world.cr` then i'm getting a big error. Here's a part of the error: ⏎ ⏎ ```while requiring "c/dlfcn": can't find file 'c/dlfcn'```
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
faustinoaq has joined #crystal-lang
<FromGitter> <codenoid> you need to puts your life
<FromGitter> <fridgerator> what? ^
<oprypin> r00ster91, it is quite possible that it is broken
<FromGitter> <r00ster91> :(
<oprypin> r00ster91, see https://pryp.in/blog/23/how-to-build-video-games-for-windows-using-crystal.html git checkout a3279079a68fae9cb2057ee3ba8c3b32e328e4dc is a good commit
<RX14> yeah master is broken on windows
<RX14> check out my windows branch on my fork
<RX14> I broke it when I changed File::Stat to File::Info
<RX14> on friday I have my last exam
<RX14> and after that I will be aple to work on windows again
<RX14> then we'll have two people working on windows over the summer
<FromGitter> <r00ster91> thats nice
<FromGitter> <fridgerator> isn't bcardiff full time crystal now?
<RX14> yes
<FromGitter> <fridgerator> awesome
<RX14> thats the second person
<FromGitter> <fridgerator> fantastic
<RX14> today he's picked up my work for the 0.25.0 chanelog
<RX14> after we get 0.25.0 out the door we should be getting progress
<crystal-gh> [crystal] RX14 closed pull request #6141: Fix #6136. Remove no longer used Dockerfile (master...fix/dockerfile) https://git.io/vhYKT
<FromGitter> <fridgerator> Sounds like windows support is the priority?
<RX14> for me
<RX14> for bcardiff he'll be working on various things
<FromGitter> <Grabli66> Nobody works on parallelism? 😟
<FromGitter> <r00ster91> well rx14 made a parallelism shard
<RX14> "various things" could well include parallelism
<RX14> I don't know it's status
<FromGitter> <fridgerator> I can already run servers in parallel thanks to SO_REUSE_PORT so I dont need it, but I understand its importance for other types of tasks
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 245 seconds]
Nathanaelle has joined #crystal-lang
Ven`` has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Ven` has joined #crystal-lang
Ven`` has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Nik736 has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Ven` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<crystal-gh> [crystal] chris-huxtable opened pull request #6142: Fixes documentation of Char.hex? (master...char-documentation) https://git.io/vhY5I
snsei has quit [Remote host closed the connection]
<FromGitter> <bararchy> I'm happy @ysbaddaden continued to work on GC (https://github.com/ysbaddaden/gc)
<FromGitter> <faustinoaq> 😄 🎉
snsei has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 245 seconds]
Nathanaelle has joined #crystal-lang
<FromGitter> <r00ster91> hopefully! because as you can see here: https://github.com/crystal-lang/crystal/issues/5271 the immix seems to be much better than the boehm
<FromGitter> <codenoid> hi
<FromGitter> <codenoid> how i can do Time.now + 15.minutes
<FromGitter> <codenoid> and get the epoch time
<FromGitter> <codenoid> *datetime
<FromGitter> <codenoid> i have no idea
<FromGitter> <codenoid> stuck for 2 days
<FromGitter> <bew> Define "datetime"
<RX14> >> (Time.now + 15.minutes).epoch
<DeBot> RX14: # => 1527540227_i64 - https://carc.in/#/r/45yx
<FromGitter> <codenoid> cool rx14
<FromGitter> <codenoid> so easy in crystal
<FromGitter> <codenoid> it's mindblowing
<FromGitter> <codenoid> coool
<FromGitter> <codenoid> omgomg
<RX14> how did you spend 2 days on that? lol
<FromGitter> <r00ster91> the code at https://carc.in/#/r/45yx is a bit weird isnt it
<RX14> yes
<FromGitter> <codenoid> actually no, hehe,
Nathanaelle has quit [Read error: Connection reset by peer]
<FromGitter> <fridgerator> hahaha
Nathanaelle has joined #crystal-lang
<FromGitter> <skippi> On the api docs, is there a difference between `# =>` and `# ==` when showing the result of an example?
<RX14> it should always be # =>
<RX14> where did you see the # == ?
<FromGitter> <skippi> I first saw it in on the `Char` docs, but decided to clone the repo and search where it occured. These are the files: ⏎ ⏎ 1) src/char.cr ⏎ 2) src/int.cr ⏎ 3) src/string.cr ... [https://gitter.im/crystal-lang/crystal?at=5b0c6b83b6eece791dbdc0d2]
<FromGitter> <skippi> If it's an inconsistency worth fixing, I can probably send in a PR.
<FromGitter> <skippi> Oh, I guess while we're still on this topic, does `#=>` and `# =>` mean the same thing? ⏎ ⏎ ```foo = 10 ⏎ foo #=> 10 ⏎ foo # => 10``` ⏎ ⏎ Sorry if I'm asking a lot of questions. Working on a project that involves finding out what kind of example documentation is/should be allowed. [https://gitter.im/crystal-lang/crystal?at=5b0c6df993dc78791c918060]
<Yxhuvud> @bararchy: it is a bit strange that the only update since february is to the readme though.
<FromGitter> <bew> `# =>` is the right one @skippi
marrow16180 has joined #crystal-lang
<marrow16180> Hi
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
marrow16180 has quit [Quit: Leaving]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
sz0 has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 245 seconds]
greengriminal has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
snsei has joined #crystal-lang
<faustinoaq> marrow16180, Hi :)
greengriminal has quit [Quit: This computer has gone to sleep]