<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 👍
<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!
<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>
<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!
<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>
<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(
<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>
<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> 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]
<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
<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