ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.1 | Fund Crystal's development: | GH: | Docs: | API: | Gitter:
<FromGitter> <faustinoaq> ```[nil, true, 99].all? # => false ⏎ [15].all? # => true``` []
<FromGitter> <faustinoaq> Also `any?`
<FromGitter> <faustinoaq> ```[nil, true, 99].any? # => true ⏎ [nil, false].any? # => false``` []
<FromGitter> <watzon> Well would you look at that
<FromGitter> <watzon> I didn't see it in the api
<FromGitter> <faustinoaq>
<FromGitter> <faustinoaq> @watzon you can use to find things faster
<FromGitter> <watzon> What is this magic?
<FromGitter> <watzon> I didn't know that existed lol
<FromGitter> <faustinoaq> @Thibaut did for the good of all us 😄
<FromGitter> <watzon> Well that's going in the bookmarks bar
crack08 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<FromGitter> <watzon> Heck I may give it a dedicated sticky tab
<FromGitter> <faustinoaq> Yes, just like me. Also I installed the desktop app 👉 ⏎ ⏎ ((
<FromGitter> <watzon> I'm in love
fenicks has quit [Ping timeout: 260 seconds]
<FromGitter> <watzon> Can I also give a big shout out to @greyblake who made `icr`. That tool is f***ing wonderful
deep-book-gk_ has joined #crystal-lang
fenicks has joined #crystal-lang
deep-book-gk_ has left #crystal-lang [#crystal-lang]
<FromGitter> <GetRektByMe> Don't suppose anyone would have an idea what would cause this? ⏎ ⏎ ```code paste, see link``` []
<crystal-gh> [crystal] MakeNowJust opened pull request #4733: Correctly inference nilable variable's type after exception handler (master...fix/crystal/4723-keep-nil-if-read-around-exception-handler)
fenicks has quit [Ping timeout: 240 seconds]
fenicks has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> The combined power of Crystal and d-bus at work
<FromGitter> <GetRektByMe> Why is that enter button so tiny?
<FromGitter> <watzon> Lol idk
<crystal-gh> [crystal] faustinoaq opened pull request #4734: Make sdl samples work on Linux (master...patch-1)
<FromGitter> <faustinoaq> @watzon absolutely amazing 👏
<FromGitter> <faustinoaq> How Did you do that?
<FromGitter> <renich> Hey, Crystalers!
<FromGitter> <renich> I need help
<FromGitter> <fridgerator> razer c library?
<FromGitter> <renich> huh... strange, the screenshot didn't copy all the screen... but just enough, hehe
<FromGitter> <renich> why is the compiler complaining if I am testing for the type?
<FromGitter> <fridgerator> use `.as` there
<FromGitter> <fridgerator> `.as(NiceHash::Mapping::Error)`
<FromGitter> <renich> @fridgerator same result
rohitpaulk has joined #crystal-lang
<FromGitter> <fridgerator> no on line 26
<FromGitter> <renich> @fridgerator same again:
<FromGitter> <fridgerator> no
<FromGitter> <fridgerator> keep it how you had it first
<FromGitter> <renich> ok
<FromGitter> <fridgerator> ad `as ` online 26
<FromGitter> <fridgerator> nope, lol
<FromGitter> <renich> :S
<FromGitter> <renich> sorry
<FromGitter> <fridgerator> add it to the end of the object that is supposed to be a NiceHash::Mapping::EError
<FromGitter> <fridgerator> i'm guessing `
<FromGitter> <renich> @fridgerator that worked. It looks like this:
<FromGitter> <renich> This is kind of odd... It feels like I am repeating myself
<FromGitter> <renich> @fridgerator Thanks a lot, man
<crystal-gh> [crystal] MakeNowJust opened pull request #4735: Tuple: support negative index (master...feature/tuple/support-negative-index)
<FromGitter> <fridgerator> 👍
<FromGitter> <GetRektByMe> @fridgerator Can I just say I'm a pretty big fan of your already
<FromGitter> <GetRektByMe> Just for that Ali-G quote
<FromGitter> <fridgerator> lol, tyty
<FromGitter> <GetRektByMe> Booyakasha fam
<FromGitter> <GetRektByMe> :^)
<FromGitter> <fridgerator> haha
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
pwned has joined #crystal-lang
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 248 seconds]
fenicks has quit [Ping timeout: 255 seconds]
fenicks has joined #crystal-lang
_whitelogger has joined #crystal-lang
pwned has quit [Ping timeout: 260 seconds]
<FromGitter> <watzon> @faustinoaq using d-lib to send messages to the `org.razer` service
<FromGitter> <watzon> We need to make QT bindings for Crystal
<FromGitter> <watzon> @renich why not link to crystal play instead of taking a screenshot?
snsei_ has quit [Remote host closed the connection]
<oprypin> watzon, yeah we do need Qt bindings. do you have knowledge of that?
<FromGitter> <bew> Oohh devdocs is awesome!!
<oprypin> in particular, what if data.result was a function that returns a different type every time? the compiler ain't gonna risk being fooled by that
<oprypin> watzon, also cheers re: dbus also i guess that's kde that you're using?
<crystal-gh> [crystal] Val closed pull request #4531: [release container] update ubuntu LTS to latest (master...update_release_container_to_latest_ubuntu_lts)
<FromGitter> <watzon> oprypin: you are correct dear sir
<oprypin> watzon, what about that Qt though. i'd be scared to do it alone
<FromGitter> <watzon> I would too lol. Especially since I don’t have much C experience. It doesn’t look like linking is really all that difficult though
<FromGitter> <watzon> I just want to be able to write damn GUIs in Crystal!
<oprypin> watzon, problem is it's not a normal C library or even a C++ library
Raimondii has joined #crystal-lang
<FromGitter> <watzon> oprypin: Is it not? I haven't really looked yet
<oprypin> :/ nevermind then
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <watzon> We could also always create bindings with something like CEGUI
<oprypin> nah i'm like Qt or bust
pwned has joined #crystal-lang
crack08 has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <abidon> Hi everyone, just wanted to let you know that I released 3 libraries for crystal on Github, still WIP but already ready for use ⏎ ⏎ 1) ( a binding to the libpq library (postgres) ⏎ 2) crystal-pq ( an alternative to crystal-pg as I'm experiencing a lot of issues with it (it uses ⏎ 3) and
<FromGitter> ... ( a binding to the argon2 library (a replacement for bcrypt) ... []
<FromGitter> <GetRektByMe> Oooh argon
<FromGitter> <watzon> Good job 👍
<FromGitter> <watzon> Question. Is there an existing method in Crystal like numpy's bitwise_or ( Or am I going to have to write my own? Basically I need to turn this `[1, 2], [4, 7]` into this `[5, 7]`
imnotarobot has joined #crystal-lang
imnotarobot has quit [Client Quit]
imnotarobot99 has joined #crystal-lang
<imnotarobot99> is there a list somewhere where i can find all the types like "\n", "\t", "\r" ?
<oprypin> watzon, `[1,2].zip([4,7]).map { |a, b| a | b }`
<oprypin> crystal doesnt duplicate all possible methods as variants that operate on each element of an array
<FromGitter> <watzon> Those are for javascript, but it's pretty comprehensive
<imnotarobot99> thank you
<FromGitter> <watzon> oprypin: Thanks! I forgot all about the zip method
<imnotarobot99> i can go backwards in text with "\b" but how can I go forward again?
snsei has joined #crystal-lang
<oprypin> imnotarobot99, you can only write something, like a space
<oprypin> imnotarobot99, or resort to this non-portable functionality
snsei has quit [Ping timeout: 255 seconds]
<imnotarobot99> oh wow this is giving much more possibilities
<oprypin> only for xterm-compatible terminals
<imnotarobot99> okay
<oprypin> imnotarobot99, what are you trying to do?
<imnotarobot99> im trying out some special characters
<oprypin> so you woke up today and went like i wanna try out some special characters today
<imnotarobot99> exactly
_whitelogger has joined #crystal-lang
Groogy2 has joined #crystal-lang
Groogy has quit [Disconnected by services]
Groogy2 is now known as Groogy
<Groogy> Hai!
Groogy_ has joined #crystal-lang
<FromGitter> <codenoid> ```code paste, see link``` []
<FromGitter> <codenoid> i got that error when compiling basic crystal http code
<FromGitter> <fridgerator> @abidon what issues have you had with crystal of?
<oprypin> codenoid, everyone on ubuntu gets that :(
<FromGitter> <codenoid> :(
<FromGitter> <fridgerator> @codenoid add `--no-debug`
rohitpaulk has joined #crystal-lang
<imnotarobot99> hm "\b" is not deleting the char. Its just going backwards. But how can i delete a char?
<oprypin> imnotarobot99, write a space on top of it
<imnotarobot99> where
<FromGitter> <codenoid> @fridgerator ✨
<Groogy> hm if I want to check if a pointer from a C lib is actually nil how do I do that? I get an error that "the meaning has changed"
<Groogy> oh I should use null instead okay
<oprypin> what kind of error is that
<Groogy> should I also assign it null?
<oprypin> Pointer is an exception to the rule that only `nil` and `false` are falsey in an if. null pointer is also falsey
<oprypin> yeah sure dont use nil? because it can never be nil? good catch by the compiler
<oprypin> Groogy, so use `if @surface` or `unless @surface.null?`
<Groogy> it won't let me use the .null method though since the class doesn't seem to actually be a Pointer type :/
<Groogy> have to manually do Pointer(Void).null to actually access it
<Groogy> meh gonna have to redo the bindings myself later
<oprypin> Groogy, i am not aware of such mysterious problems, I'd need more context to see what has gone wrong.
<Groogy> in the lib definition it's a Void* alias, trying to access LibGLFW3::Window.null nets me a "undefined method"
<Groogy> since it isn't a pointer
<Groogy> eh a Pointer(T)
<Groogy> hmm Pointer doesn't work either because it's a different type :/ so I get an unnessecary union
<oprypin> i wish to see more context, because with how much i've worked with pointers without running into this problem i can't help but wonder
<Groogy> oh it's not aliases, it's type
<Groogy> that's why it's "not a Pointer"
<Groogy> even though it is
<oprypin> i believe that there may be such a bug but perhaps you dont need to suffer from it
<oprypin> Groogy, ok you dont need to set it to null
<Groogy> The finalizer is used elsewhere
<oprypin> the memory is getting deleted right afterwards anyway
<Groogy> to make sure things are destroyed elsewhere
<Groogy> so it does need to
<imnotarobot99> if im using windows, linux subsystem how can I then change the title of the window?
<Groogy> otherwise if you close the application, the GC will first invoke destruction on the backend, without killing the window
<Groogy> and then try to kill the window, where the memory is invalid now
<oprypin> imnotarobot99, you mean terminal window? that's like so inconsequential
<oprypin> Groogy, if you close the application finalizers dont get called
<imnotarobot99> yes terminal window
<Groogy> you probably want to look at TUI libraries
<Groogy> like Ncurses
<oprypin> imnotarobot99, might work
<imnotarobot99> already tried this
<imnotarobot99> not working
<oprypin> imnotarobot99, then you cant
<imnotarobot99> |:
<oprypin> it's abou damn time for TUIs to die though
<Groogy> Hey I'm sitting in Weechat
<Groogy> take that back >:(
<Groogy> you hurt his feelings
<imnotarobot99> can i maybe somehow use windows command in linux subsystem?
<oprypin> imnotarobot99, no
<Groogy> eh no idea
<Groogy> just curioous what are you trying to accomplish?
<oprypin> imnotarobot99, do you realize how pointless all of this is? like do you think there will be some user of your program using linux subsystem for windows who cares about some window title?
<oprypin> Groogy, re: trying to accomplish
<oprypin> ‎[13:15:34] ‎<‎oprypin‎>‎ imnotarobot99, what are you trying to do?
<oprypin> ‎[13:16:14] ‎<‎imnotarobot99‎>‎ im trying out some special characters
<oprypin> ‎[13:16:45] ‎<‎oprypin‎>‎ so you woke up today and went like i wanna try out some special characters today
<oprypin> ‎[13:17:06] ‎<‎imnotarobot99‎>‎ exactly
<Groogy> well then he is just learnign shit and there's nothing bad about that
<FromGitter> <sdogruyol> Hey everyone
<imnotarobot99> what
<Groogy> Hello @sdogruyol
<FromGitter> <sdogruyol> How are you
<FromGitter> <bararchy> Hi @sdogruyol
<FromGitter> <sdogruyol> Hey
<Groogy> I need to assign null to a type'd lib on void* but I can't find any way to actually do that :/
<Groogy> since it is using the "type" keyword it doesn't have anything of Pointer(Void) defined on it
<oprypin> Groogy, would be nice to report that
<Groogy> think there already is?
<Groogy> think saw one weeks ago
<Groogy> gonna double check
<oprypin> Groogy, well you can do this but yeah the problem is definitely there
<Groogy> oh so I could do that for now?
<Groogy> but yeah will put up a report if I don't find a duplicate
<Groogy> there we go
pwned has quit [Ping timeout: 268 seconds]
rohitpaulk has quit [Ping timeout: 240 seconds]
imnotarobot99 has quit [Quit: Page closed]
<oprypin> is there any way to enumerate the types in a tuple type?
<Groogy> hmm the types themselves? In a macro or at runtime?
<oprypin> Groogy, at runtime
<Groogy> tuple.each { |val| puts val.class } would do it wouldn't it?
<oprypin> wait what
<oprypin> what am i missing if it's so simple
<Groogy> the tuple includes Enumerable so that should work
<oprypin> actually you know what? i'd prefer to get the compiletime type
<oprypin> but I don't think a macro is applicable
<Groogy> hmm that's trickier but you should be able to do for; end on a tuple in a {% %} macro
<oprypin> a = {1, "a"} - how to get these types?
<oprypin> if i have it not as a literal
<Groogy> a = create_random_tuple()
<Groogy> kind of thing and you want to know what the type of a[0] is?
<oprypin> for array i have this btw `def type_to_sig(type : Array(T).class) : String forall T ; "a" + type_to_sig(T) ; end`
<oprypin> Groogy, i want to know the type of a[0], a[1], ...
<Groogy> so you want this but to return the union type instead right?
<oprypin> yeah I want a compiletime failure if there's a union anywhere in the tuple which will be ensured by calling a non existent type_to_sig method
<oprypin> Groogy, no this is just what i want. i just call type_to_sig on every tuple member. the catch is that we still dont have the number of items
<Groogy> you could create a validator function that takes the specific types you approve of
<Groogy> a bit C++ over it but should work
<oprypin> I approve a tuple as long as it contains only the exect types that i have
<Groogy> it's how I translate between my own serialization and whatever I choose to output to (in this case YAML)
<Groogy> though that's translation not validation :/
<Groogy> but yeah if you have a seperate function to validate it, that should work. Because if you don't make the argument a union, it won't allow passing a union to it
<oprypin> Groogy, mhm seems this validation is difficult
<oprypin> i'd prefer to have a way to iterate over compile time types in a tuple
<Groogy> oh lol
<Groogy> there is literally just a method for it
<Groogy> though I think something is wrong in my example making it remove the Symbol type in the union
<Groogy> because it won'
<Groogy> won't let me assign symbols to the first element
<oprypin> not entirely fixed then
<Groogy> ah
<oprypin> >> typeof(Tuple(Int32 | UInt8).new(5))
<oprypin> ded bot
<oprypin> result is Tuple(Int32)
<Groogy> but yeah the #types method gives you an enumerable class it seems of the tuple
<Groogy> .each doesn't work but since #[] works you can probably figure out a way to iterate over it
<oprypin> undefined method 'each' for Tuple(Int32 | UInt8):Class
<Groogy> yeah
<oprypin> hm ok yeah
snsei has joined #crystal-lang
<Groogy> also ehm, what are these two newest threads on r/crystal_programming
rohitpaulk has joined #crystal-lang
<oprypin> Groogy, no active moderator there
<oprypin> still not getting it
<oprypin> types returns a tuple of types which doesnt help much
<oprypin> it's actually not a tuple of types, even. something broke
<Groogy> I think it is the class of the Tuple
<oprypin> yeah literally just tuple.types == typeof(tuple)
snsei has quit [Ping timeout: 268 seconds]
<Groogy> hmm
<Groogy> it seems like it will only accept literals for the #[] as well
<Groogy> but I think the .types here is what is used during macros as well
<Groogy> so you could iterate over it in a macro
<oprypin> how can i iterate over something that is not a literal in a macro
<Groogy> hmm
<oprypin> but it's not actually there
<Groogy> well you can apparently iterate over the T
<Groogy> if it has several types in it it seems
<oprypin> Groogy, it can be iterated over in macro context, but apparently the runtime value of T is broken
<oprypin> it seems like the implementor hoped one could iterate over T but that's not what happens
<Groogy> I remember I read somehwere where you could extract the T from a type
<Groogy> by some fancy template magic
<Groogy> ala style C++
<oprypin> then someone changed documentation to what's actually happening without checking if it makes any sense?
<oprypin> this is the fancy template magic ‎[16:52:01] ‎<‎oprypin‎>‎ for array i have this btw `def type_to_sig(type : Array(T).class) : String forall T ; "a" + type_to_sig(T) ; end`
<oprypin> oh my
<oprypin> thanks
<Groogy> Yeah I'm as suprised as well
<Groogy> I just give it a tuple type and it seems to understand how to iterate over the types
<oprypin> yeah it's fine cuz you have access to the T in a macro context
<Groogy> yeah
<Groogy> but I was expecting it to give me Tuple(String, Symbol)
<Groogy> in T
<oprypin> or, u know, just fix it by literally copying that code from specs
<Groogy> haha
<FromGitter> <renich> oprypin: thanks, man.
<FromGitter> <sdogruyol> that's some magic @Groogy
crack08 has quit [Ping timeout: 276 seconds]
<Groogy> gonna start putting together how to manage input now :/
w-p has joined #crystal-lang
<w-p> Can anyone point me in the direction of an example of using PrettyPrint?
<oprypin> w-p, do you want to use it or implement it
<oprypin> use it to print or use it to obtain a string?
<w-p> Use. I really just want to debug the contents of an object...
<oprypin> p obj
<w-p> standby
<oprypin> w-p, and click thru for source code
<w-p> thank you. and i feel stupid. how did i miss that?
<oprypin> i dunno, i found out myself today, it's a new thing and not well documented
<oprypin> `p` used to use `inspect`
<w-p> ha. thanks - that makes me feel a little better.
<w-p> guess the docs need a full-text search
<oprypin> w-p, - also found out today
<oprypin> actually nvm it's not a full text search. what's the point then :|
<w-p> i see. i can't put a space in the searchbox on - lol
<w-p> can no. wierd.
<w-p> thanks anyway
<w-p> oprypin - this kinda works:
<w-p> also, this apparently works: <obj>.pretty_inspect
<oprypin> nice
A124 has quit [Quit: '']
A124 has joined #crystal-lang
tzekid has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest13273
pwned has joined #crystal-lang
snsei has joined #crystal-lang
raz has quit [Ping timeout: 258 seconds]
raz has joined #crystal-lang
raz has joined #crystal-lang
raz has quit [Changing host]
snsei has quit [Remote host closed the connection]
tzekid has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 276 seconds]
<Groogy> huh, arrays in Crystal don't implement a #include? method?
<Groogy> ah nvm it's in enumerable
Guest13273 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest6808
Groogy has quit [Quit: WeeChat 1.9]
rohitpaulk has quit [Ping timeout: 240 seconds]
maa1 has joined #crystal-lang
<maa1> hi
<maa1> I have a question
<maa1> hi internet
<maa1> :)
<maa1> :(
<w-p> ask away dude
<maa1> :)
<maa1> What's crystal use cases?
maa1 has quit [Ping timeout: 260 seconds]
pwned has quit [Ping timeout: 255 seconds]
<FromGitter> <watzon> What's the best way to handle a milti-dimensional array type wise? I can't really do `arr = [] of Array(Array(Int32) | Int32) | int32` because that only handles one level. I need basically need a recursive type or an `Array(Any)`
<FromGitter> <watzon> I found #3031, but has anyone found any workarounds?
<oprypin> watzon, a N-dimensional array would just be how many times Array is repeated - Array(Array(Array(z)))
<oprypin> i dont think you want Array(Int32) | Int32 anywhere there - it would be unusable even if it worked
<oprypin> what are you trying to accomplish?
<oprypin> you could imlpement `MultiDimensionalArray(T, N)` if you really wanted but yeah
<FromGitter> <watzon> Basically I'm trying to recreate `numpy.zeros` where you can give it a sequence of arbitrary length and it will recursively generate a narray for you.
<crystal-gh> [crystal] mverzilli pushed 1 new commit to master:
<crystal-gh> crystal/master a51193a TSUYUSATO Kitsune: Fix '--release' flag place in man page's example...
<oprypin> watzon, if you're gonna recreate numpy, do it like numpy
<oprypin> with a special type based on a contiiguous memory block and multiplication to get indices
<oprypin> you can easily make an Array of a known dimensionality
<travis-ci> crystal-lang/crystal#a51193a (master - Fix '--release' flag place in man page's example): The build passed.
<travis-ci> crystal-lang/crystal#a51193a (master - Fix '--release' flag place in man page's example): The build passed.
<travis-ci> crystal-lang/crystal#a51193a (master - Fix '--release' flag place in man page's example): The build passed.
fenicks has left #crystal-lang [#crystal-lang]
<oprypin> watzon, fun stuff
<FromGitter> <watzon> Damn lol
<oprypin> watzon, but delete to_a and it should be a usable thing
<oprypin> oh goddammit
<FromGitter> <watzon> Lol. That error goes on for days
<FromGitter> <fridgerator> haha
<FromGitter> <watzon> it looks like this may work for me
<FromGitter> <watzon> The `to_a` method doesn't return a multidimensional array, but it seems like it duplicates enough array like functionality
Guest6808 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
deep-book-gk_ has joined #crystal-lang
deep-book-gk_ has left #crystal-lang [#crystal-lang]
<FromGitter> <watzon> Any way to convert an `Int` to bytes?
<FromGitter> <watzon> For instance `1024` should become `\x04\x00`
snsei has joined #crystal-lang