RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.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> <mjago> @bew That looks like a very useful shard 👍 .I use ncurses and do terminal stuff knowing it is ineffective on some terminals 😟 So I'll certainly take a look thanks
cozachk has quit [Quit: Leaving]
duane has quit [Ping timeout: 260 seconds]
duane has joined #crystal-lang
duane has quit [Ping timeout: 256 seconds]
duane has joined #crystal-lang
wontruef_ has joined #crystal-lang
wontruefree has quit [Ping timeout: 248 seconds]
duane has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> As explained in the readme it's definitely not finished, and not yet usable (I miss the parameterized string capability parser & executor, that it needed for some actions)
<FromGitter> <bew> I plan to do a few pure Crystal shards to make terminal apps, so i started with the most basic one (this one), next I want to do a shard for terminal input *à la* libtermkey, then finally a shard like termbox or similar, then maybe build on that
duane has joined #crystal-lang
wontruef_ has quit [Quit: bye]
<FromGitter> <bew> @mjago if you can try to use it and give some feedback it would be great 👍
duane has quit [Ping timeout: 240 seconds]
duane has joined #crystal-lang
alex`` has quit [Ping timeout: 276 seconds]
duane has quit [Ping timeout: 240 seconds]
duane has joined #crystal-lang
akaiiro has quit [Ping timeout: 265 seconds]
akaiiro has joined #crystal-lang
GoldenBear_ has joined #crystal-lang
GoldenBear has quit [Ping timeout: 264 seconds]
duane has quit [Ping timeout: 276 seconds]
<FromGitter> <icyleaf> docker hub added alpine 3.8: https://github.com/docker-library/official-images/pull/4501
DTZUZO has joined #crystal-lang
<FromGitter> <bew> shouldn't this work? https://carc.in/#/r/4gi3 : calling a macro on a generic type (but I give the type)
<FromGitter> <rishavs> What is the correct way to access nested hashes? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but if I try; ... [https://gitter.im/crystal-lang/crystal?at=5b3f04819b82c6701ba6c493]
<FromGitter> <talbergs> on line 79 https://carc.in/#/r/4gi6 it complains that it can't infet type of clas variable, how so? I know I can't typehint at `|var : Type|`
<FromGitter> <bew> @talbergs the error is about class variables, not block variables or anything, please provide the full error
alex`` has joined #crystal-lang
<FromGitter> <bew> @rishavs this is because https://carc.in/#/r/4gi8 : the type of an Hash's item is the union of the types of all hash items, the compiler can't know that you didn't change the value associated with `"payload"`.
<FromGitter> <bew> @rishavs here the type of the value associated with `"payload"` is `Hash(String, String)`, if you really need to use a nested Hash (which I doubt..) you can check like this: `if (value = store["payload"]).is_a?(Hash(String, String)) && (value["status"] == "error"); ...; end`
lvmbdv has joined #crystal-lang
<FromGitter> <rishavs> Thanks @bew . Coming from a JS background I am way too spoiled by using json structures without putting any thought into them. :D
<FromGitter> <bew> maybe you can use multiple classes instead of nested hashes, so you could do `if store.payload.status == "error"; ...; end`
<FromGitter> <rishavs> I think, I will stay away from nested hashes for a while till I get better at typed programming.
<FromGitter> <bew> it depends on what this 'hash' is for, how it's meant to be used, etc..
<FromGitter> <rishavs> Its essentially a datastore which is created with every request coming into my server
<FromGitter> <rishavs> I keep by transitional states here, like the currentuser for the context and some data I need to transform my views
<FromGitter> <bew> yeah json structures are way too permissive, and not type-safe at all btw, it's a big change when you come to a static typed language. Also Hash is not meant to be used like json structs at all
<FromGitter> <rishavs> Learning that the hard way :(
<FromGitter> <bew> does the keys of this state changes a lot or are they always the same?
<FromGitter> <bew> (read between the lines: can you make it a class?)
<FromGitter> <rishavs> keys stay the same for all my controllers but the values can range from a string, nil or a structured object (hashes or arrays). I actually started with making it a class but decided to go for a simple hash as I felt that a hash might be lighter (since I am creating this object on every http request)
<FromGitter> <bew> well, a Hash is a class too, and accessing fields is a lot slower than accessing class fields
<FromGitter> <rishavs> yeah, you are right. Gonna try the class based store for now.
akaiiro has quit [Ping timeout: 265 seconds]
ua has quit [Quit: Leaving]
Yxhuvud has quit [Read error: Connection reset by peer]
Yxhuvud has joined #crystal-lang
ua has joined #crystal-lang
Groogy has joined #crystal-lang
<FromGitter> <j8r> @bew nice :D
<Groogy> Yo! o/
<Groogy> got a fresh arch install at work ^^
lvmbdv has quit [Ping timeout: 268 seconds]
<FromGitter> <Qwerp-Derp> I've fixed up my library! It evals markup and works properly now! :D
<FromGitter> <Qwerp-Derp> If anyone wants to make suggestions to my library please don't hesitate to do so
<FromGitter> <Qwerp-Derp> Now all I have to do is create a markup library, and I'm good to go!
lvmbdv has joined #crystal-lang
Raimondii has joined #crystal-lang
lvmbdv has quit [Ping timeout: 264 seconds]
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
lvmbdv has joined #crystal-lang
<FromGitter> <Artmann> Hi, I'm trying out Crystal a bit and I have a question about how you handle array access. ⏎ ⏎ In Ruby I can do this ⏎ ⏎ ```list = [] ⏎ a = list[0] || "Foo"``` ... [https://gitter.im/crystal-lang/crystal?at=5b3f3bb63572e970c17ad493]
<FromGitter> <Artmann> Just found `[]?` :) ⏎ ⏎ ```delay = args[0]? ? args[0].to_i : 0 ⏎ priority = args[1]? ? args[1].to_i : 1024``` [https://gitter.im/crystal-lang/crystal?at=5b3f3d7a9b82c6701ba743d4]
Groogy has quit [Quit: WeeChat 2.1]
<FromGitter> <bcardiff> `a = list[0]? || "Foo"` should to it also. @Artmann no need for the ternary operator. Also `Array#fetch` is there
<FromGitter> <mamantoha> Hi. Does Crystal support freezing variables? For example, I want to set some `@var` from a parameter in the class initializer, and then if someone tries to reassign it an error will occur.
<lvmbdv> no but it would be trivial to implement in a setter
<lvmbdv> or just don't define a setter, if you don't want it to change, ever
<FromGitter> <Artmann> @bcardiff Thanks :)
<crystal-gh> [crystal] sdogruyol closed pull request #6332: Add XML::Reader ParserOptions Support (master...xml-reader-parser-options) https://git.io/fbpBm
<travis-ci> crystal-lang/crystal#e153291 (master - Add XML::Reader ParserOptions Support (#6332)): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/400856148
<DeBot> https://github.com/crystal-lang/crystal/pull/6332 (Add XML::Reader ParserOptions Support)
scooter_de has joined #crystal-lang
<FromGitter> <sroller> is there a better introduction on how to use shards? I found the documentation rather spotty.
<FromGitter> <sroller> everything described there doesn't start at the "dummy level", which would be me.
<FromGitter> <hugoabonizio> @sroller check this https://crystal-lang.org/docs/guides/writing_shards.html
<FromGitter> <hugoabonizio> for usage there's this straightfoward example https://github.com/crystal-lang/shards#usage
<FromGitter> <hugoabonizio> do you have any specific issue?
<FromGitter> <hugoabonizio> the documentation seems to be stucked (may be a good sign that it's intuitive) https://github.com/crystal-lang/shards/issues/11
<FromGitter> <sroller> thanks. I don't have any specifics. I just got stuck in my very first attempt to write some script to access Postgres. The demo code didn't work out of the box but assumed something to be done in the shards.yml but then failed to compile.
<FromGitter> <sroller> I poked around in other repos and got it up and running. Will have a look at the urls you provided. Thank you!
<crystal-gh> [crystal] asterite opened pull request #6341: Fix: missing virtual types in literal type guessing (master...bug/5342-guess-literals-virtual) https://git.io/fNeJH
<FromGitter> <hugoabonizio> if you get some problem, feel free to ask here!
<travis-ci> crystal-lang/crystal#e153291 (master - Add XML::Reader ParserOptions Support (#6332)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/400856148
<DeBot> https://github.com/crystal-lang/crystal/pull/6332 (Add XML::Reader ParserOptions Support)
<FromGitter> <j8r> Hi, how can I write to STDOUT, and then clean what was printed. I guess I have to use a buffer, and then wipe it out?
<FromGitter> <hugoabonizio> @j8r check if this helps you https://github.com/askn/spinner/blob/master/src/spinner.cr
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
scooter_de has quit [Ping timeout: 252 seconds]
wontruefree has joined #crystal-lang
wontruefree has quit [Quit: bye]
<crystal-gh> [crystal] asterite opened pull request #6342: Don't merge tuple metaclasses through instance types (master...bug/5384-tuple-metaclass-merge) https://git.io/fNeYl
<FromGitter> <MrSorcus> `See Time::Format for details.` ⏎ ⏎ But 0.25.0 has no any info in api doc - https://crystal-lang.org/api/0.25.0/Time.html ...
<FromGitter> <MrSorcus> Oh, looks like that fixed in 0.25.1
wontruefree has joined #crystal-lang
<FromGitter> <j8r> @hugoabonizio exactly what I need, thanks :D
<FromGitter> <MrSorcus> https://crystal-lang.org/api/0.24.0/Time/Format.html ⏎ Why patterns removed from api doc in 0.25.X?
<FromGitter> <j8r> the solution is: `print "\u000d"` :)
<FromGitter> <j8r> @hugoabonizio This seems to work only for one line, but not for multi line
<FromGitter> <j8r> The idea is to draw all the terminal, and flush all after (like `vi` does)
akaiiro has joined #crystal-lang
shalmezad has joined #crystal-lang
<FromGitter> <MrSorcus> How can i convert `2018-06-28T12:29:25` to timestamp? ⏎ `Time.parse(date, "%FT%T").epoch_ms` it doesn't work now...
<FromGitter> <j8r> no nathanj, I'm already using it and it uses C under the ground
<FromGitter> <j8r> I would like to move out of Termbox to be fully Crystal 😄
duane has joined #crystal-lang
<FromGitter> <Blacksmoke16> @MrSorcus `p Time.parse("2018-06-28T12:29:25", "%FT%T", Time::Location.load_local).epoch_ms`
<FromGitter> <Blacksmoke16> need to provide a TZ in the string or set what tz it should be
wontruefree has quit [Quit: bye]
<FromGitter> <MrSorcus> > @MrSorcus `p Time.parse("2018-06-28T12:29:25", "%FT%T", Time::Location.load_local).epoch_ms` ⏎ ⏎ Thank you 😸
<FromGitter> <Blacksmoke16> that will load whatever tz your system is set to, if you require something else can change it
<nathanj> j8r: in that case you will have to perform the escape sequences yourself. google "ansi escape sequences" and also look at https://github.com/antirez/kilo which is a super simple editor
<FromGitter> <Blacksmoke16> `Time::Location::UTC` for UTC
<FromGitter> <MrSorcus> > that will load whatever tz your system is set to, if you require something else can change it ⏎ > `Time::Location::UTC` for UTC ⏎ ⏎ Ok. Thanks 😄 [https://gitter.im/crystal-lang/crystal?at=5b3f8c40f1664406611f3a88]
<FromGitter> <j8r> nathanj I prefer to refer to termbox.c instead, it's far simpler/shorter. I've the idea of how they do, but get yet how to do in crystal (but in C i will be able to do so)
<FromGitter> <j8r> omg kilo.c is a 1200 lines file x(
<pippin> j8r: my entry in set of small single file libraries for terminal handling in C: https://github.com/hodefoting/nchanterm
duane has quit [Ping timeout: 245 seconds]
Nik736 has joined #crystal-lang
Nik736 has quit [Client Quit]
wontruefree has joined #crystal-lang
<FromGitter> <Daniel-Worrall> is `raise` a Crystal keyword
<FromGitter> <Daniel-Worrall> I have just started work on an editor plugin for Crystal for context
<FromGitter> <bew> pippin nice one, i'll keep that in mind ;)
duane has joined #crystal-lang
<FromGitter> <hugoabonizio> @Daniel-Worrall `raise` is a method on top level namespace https://crystal-lang.org/api/0.25.0/toplevel.html#raise%28exception%3AException%29%3ANoReturn-class-method
<FromGitter> <Daniel-Worrall> gotcha
<FromGitter> <silasb> hey guys. I'm super confused on why this doesn't work: https://play.crystal-lang.org/#/r/4gmf
<FromGitter> <Daniel-Worrall> What's the expected output
<FromGitter> <silasb> I expect it to compile, but it doesn't. I get `undefined method 'from' for Blah::ASTNode2:Class`
<FromGitter> <silasb> oops this is my latest version: https://play.crystal-lang.org/#/r/4gmo
<FromGitter> <silasb> what's weird is that I have this line of code: `ASTNode2.from([nil, Blah::Arguments.new, Blah::Block])` in my code and it works, but when I was writing tests I couldn't get it to compile.
akaiiro has quit [Ping timeout: 260 seconds]
<FromGitter> <Blacksmoke16> did you define a `from` method in your code?
<FromGitter> <silasb> Nope. Shouldn't `alias` give hints to the compiler to change it to the `Tuple` type which defines `from`
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Daniel-Worrall> If I had to guess, the compiler checks methods on the alias before replacing the alias names
<FromGitter> <Daniel-Worrall> This doesn't come up when you do something like `ary = [] of AliasArray`
<FromGitter> <Daniel-Worrall> The same happens when it's not in a module
<FromGitter> <bew> Note: iirc `from` is a macro
<FromGitter> <Daniel-Worrall> It doesn't work with `#new` either
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.25.1/Tuple.html#from%28array%3AArray%29%3Aself-class-method
<FromGitter> <bew> Ah it's not
<FromGitter> <bew> Either way, yeah looks like a bug
<FromGitter> <Daniel-Worrall> Ah, you're passing in a class when it expects an instance
<FromGitter> <Daniel-Worrall> The error should be a lot more clear though
<FromGitter> <Daniel-Worrall> Actually, that doesn't help
<FromGitter> <silasb> what's weird is that I have this throughout my code. It works fine. When I started testing my code I ran into this issue. ⏎ ⏎ is there a way to look at the macro compilation phase?
<crystal-gh> [crystal] hugoabonizio opened pull request #6343: Remove leftover debug messages in raise.cr (master...doc/remove-leftover-messages) https://git.io/fNe8P
<FromGitter> <Daniel-Worrall> Wait... You have ASTNode2 as a Tuple of more ASTNode2's
<FromGitter> <Daniel-Worrall> Isn't that broken recursion since it's not nilable
<FromGitter> <silasb> yep, it's been working for a while now. I haven't build large structures with it, mostly 3 layers deep and it's worked.
<FromGitter> <silasb> https://play.crystal-lang.org/#/r/4gng this how I'd typically do this.
<FromGitter> <silasb> it's like the macro compilation phase is broken once I cross namespace boundaries
<FromGitter> <bew> Why you talk about the macro compilation phase?
<FromGitter> <silasb> I was assuming that `alias` was a macro, but I could be wrong.
<FromGitter> <bew> alias is not a macro
<FromGitter> <bew> It's a keyword
<FromGitter> <silasb> Should I open this up as a bug?
<FromGitter> <bew> I think you can yes
<FromGitter> <bew> Try to make a minimal example
duane has quit [Ping timeout: 260 seconds]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
akaiiro has joined #crystal-lang
akaiiro has quit [Ping timeout: 248 seconds]
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
shalmezad has quit [Quit: Leaving]
duane has quit [Ping timeout: 240 seconds]
duane has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
bmcginty has quit [Ping timeout: 260 seconds]
<crystal-gh> [crystal] chris-huxtable closed pull request #5627: Adds System Users and Groups (master...users-groups) https://git.io/vNVfn
lvmbdv has quit [Quit: Leaving.]
<FromGitter> <mjago> @j8r yes 0x0D is the same as \r (carriage return). I always grab libcurses when I'm wanting to do that sort of thing - there is a fairly complete crystal binding (but C again I suppose)
lvmbdv has joined #crystal-lang
thews has quit [Ping timeout: 264 seconds]
lvmbdv has quit [Remote host closed the connection]
thews has joined #crystal-lang
thews has quit [Changing host]
thews has joined #crystal-lang
Yxhuvud has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
<FromGitter> <j8r> Ok I got it, thanks you :)
wontruef_ has joined #crystal-lang
wontruefree has quit [Ping timeout: 260 seconds]
duane has quit [Ping timeout: 256 seconds]
Raimondii has joined #crystal-lang
duane has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
alex`` has quit [Quit: WeeChat 2.1]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
bmcginty has joined #crystal-lang
<crystal-gh> [crystal] ysbaddaden closed pull request #6341: Fix: missing virtual types in literal type guessing (master...bug/5342-guess-literals-virtual) https://git.io/fNeJH
<crystal-gh> [crystal] asterite opened pull request #6346: Fix: incorrect debug info for closured self (master...bug/6195-incorrect-debug-info) https://git.io/fNeAv
<crystal-gh> [crystal] ysbaddaden closed pull request #6342: Don't merge tuple metaclasses through instance types (master...bug/5384-tuple-metaclass-merge) https://git.io/fNeYl
akaiiro has joined #crystal-lang
<crystal-gh> [crystal] asterite opened pull request #6347: Error if using `return` inside a constant's value (master...bug/5391-return-from-constant) https://git.io/fNeAi
wontruef_ has quit [Quit: bye]
wontruefree has joined #crystal-lang
<travis-ci> crystal-lang/crystal#8acbd26 (master - Merge pull request #6341 from asterite/bug/5342-guess-literals-virtual): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/401084923
<DeBot> https://github.com/crystal-lang/crystal/pull/6341 (Fix: missing virtual types in literal type guessing)
wontruefree has quit [Quit: bye]
<travis-ci> crystal-lang/crystal#13edef6 (master - Merge pull request #6342 from asterite/bug/5384-tuple-metaclass-merge): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/401086314
<DeBot> https://github.com/crystal-lang/crystal/pull/6342 (Don't merge tuple metaclasses through instance types)
zachk has joined #crystal-lang
zachk has quit [Changing host]
zachk has joined #crystal-lang
<crystal-gh> [crystal] asterite opened pull request #6348: Fix access of class vars from generic metaclass (master...bug/3719-class_var_from_generic_metaclass) https://git.io/fNejU