RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.19.2 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 276 seconds]
mgarciaisaia1 has left #crystal-lang [#crystal-lang]
Liothen has quit [Changing host]
Liothen has joined #crystal-lang
oddmunds1 has quit [Ping timeout: 276 seconds]
oddmunds1 has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Philpax has joined #crystal-lang
snsei has joined #crystal-lang
Philpax has quit [Ping timeout: 265 seconds]
Philpax has joined #crystal-lang
Guest11464 has quit [Remote host closed the connection]
soveran has joined #crystal-lang
ssvb has joined #crystal-lang
soveran has quit [Ping timeout: 265 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 255 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 264 seconds]
soveran has joined #crystal-lang
ryanf has joined #crystal-lang
<ryanf> is there a way to create a singleton object with a unique type?
<ryanf> I want a pattern like scala's "sealed trait Foo; case class FooOne(anAttribute: String) extends Foo; case object FooTwo extends Foo"
soveran has quit [Ping timeout: 240 seconds]
<ryanf> which is basically a union type where some members are singletons and others are classes
<ryanf> I'm not sure what the nicest way in Crystal is to accomplish the same goal
eizua has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
<FromGitter> <raydf> Hi ryanf, do you try any code in particular, maybe you could share a snippet in play.crystal-lang.org
soveran has joined #crystal-lang
Masaaki has joined #crystal-lang
<Masaaki> How to debug a crystal program, does it have any tutorials?
<FromGitter> <raydf> Masaaki you could output debug symbols at build time. But i haven't tested any tools with it, maybe someone else has more experience with debuging with symbols
soveran has quit [Ping timeout: 240 seconds]
<FromGitter> <raydf> You can work as any dynamic language
matp_ is now known as matp
<FromGitter> <raydf> using puts, pp, and interpolating variables with to_s or .to_json.
<Masaaki> Sometimes error messages from runtime or compile-time are not friendly.
<FromGitter> <raydf> Yes, there's a lot of work to be made before 1.0 release.
<FromGitter> <raydf> could you share the error and maybe we could help you.
<FromGitter> <raydf> For profiling you can do this in macos: http://www.mikeperham.com/2016/06/24/profiling-crystal-on-osx/
<FromGitter> <raydf> In my experience there's a lot of errors thrown around type safety of union types or casting.
<Masaaki> Thanks, puts or pp is good enough in most cases, but I still want a single-step debugger in some tricky problem.
<FromGitter> <raydf> Embracing the nil value is very valuable at runtime for "bug less" software.
snsei has quit [Remote host closed the connection]
<FromGitter> <raydf> Ex: ⏎ ```@test.try &.["test"]?.try &.as_h?.try &.["test_array"]?``` [https://gitter.im/crystal-lang/crystal?at=57e75346240a335f12eb132a]
<Masaaki> Like GDB.
<FromGitter> <raydf> The core team have the debug tooling in the roadmap, but right now has a low priority against another items in the roadmap.
<ryanf> raydf: I ended up finding a working solution, but still curious whether what I originally wanted is possible: https://play.crystal-lang.org/#/r/1apl/edit
soveran has joined #crystal-lang
<FromGitter> <raydf> There's some code that doesn't take advantage of type inference. See https://play.crystal-lang.org/#/r/1apm
soveran has quit [Ping timeout: 240 seconds]
<FromGitter> <raydf> For singleton mehtods you could use ⏎ ``` ⏎ class test ⏎ def self.work_method ⏎ pp "work_method" ... [https://gitter.im/crystal-lang/crystal?at=57e7581d57bec07c30f17de1]
Masaaki has quit [Ping timeout: 240 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
<FromGitter> <raydf> Sorry, my bad, i read too fast about the singleton object :).
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
mgarciaisaia has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
eizua has quit [Quit: Leaving]
<ryanf> unrelated question: why doesn't this work? https://play.crystal-lang.org/#/r/1aps
hellyeah has joined #crystal-lang
<hellyeah> hey anyone around?
<dostoyevsky> hellyeah: Mostly FromGitter ...
<hellyeah> "FromGitter"
<hellyeah> what does it mean?
soveran has quit [Ping timeout: 240 seconds]
<hellyeah> you mean github community?
<dostoyevsky> Forward git commit messages
<hellyeah> aha
<hellyeah> chat screen
<hellyeah> ic
<hellyeah> do you know "express"?
<hellyeah> one of node moule
<hellyeah> module*
mgarciaisaia has left #crystal-lang [#crystal-lang]
<FromGitter> <ujifgc> Hello. I'm looking at https://github.com/crystal-lang/crystal/blob/471cf5fdd4cc0042be924d84506f907c76d0f007/src/string.cr#L1164-L1178 ⏎ Is it correct to write like this `while to_unsafe[bytesize - 1 - excess_right].unsafe_chr` without checking if the index is inside the string? As I understand it eventually accesses the pointer beyond the string data.
<FromGitter> <raydf> ryanf, that looks like a bug, maybe open an issue?
<FromGitter> <raydf> hellyeah, this https://expressjs.com/?
<hellyeah> i wonder crystal is like express. In express you construct http server and you use http method like "get"
<hellyeah> FromGitter: yeah it is that
<FromGitter> hellyeah, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<ryanf> raydf: huh, interesting. I did find that it works if I use `include Base(CommandOptions)` instead of subclassing
<hellyeah> FromGitter: okey you are bot
<FromGitter> hellyeah, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<FromGitter> <raydf> see this project https://github.com/sdogruyol/kemal
<FromGitter> <raydf> @ryanf, yes use composition instead of all the generics for the moment.
<FromGitter> <raydf> but this looks like a correct generics case, so maybe the core team could give feedback why doesn't work.
<FromGitter> <raydf> @ryanf, you can run it like this: https://play.crystal-lang.org/#/r/1aqg
<FromGitter> <raydf> the problem is in the abstract classes inheritance with delegating instance variable type.
<FromGitter> <raydf> @hellyeah see this project https://github.com/sdogruyol/kemal
<FromGitter> <raydf> if you need low level usage of the http_server you can read: https://crystal-lang.org/docs/overview/http_server.html
<ryanf> raydf: good point, thanks! that actually works great
<ryanf> I'll update the issue
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
ponga has joined #crystal-lang
phase_ has joined #crystal-lang
eizua has joined #crystal-lang
phase_ has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
eizua has quit [Quit: Leaving]
pawnbox has quit [Ping timeout: 265 seconds]
pawnbox has joined #crystal-lang
eizua has joined #crystal-lang
matp_ has joined #crystal-lang
matp has quit [Ping timeout: 252 seconds]
matp_ is now known as matp
coderobe has joined #crystal-lang
<RX14> i wish random actually worked with Int32s
<RX14> it should at least raise when rand() is going to overflow
bjz has quit [Max SendQ exceeded]
bjz has joined #crystal-lang
ponga has quit [Read error: Connection reset by peer]
ponga has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 265 seconds]
Philpax has quit [Ping timeout: 244 seconds]
sandelius has joined #crystal-lang
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sandelius has joined #crystal-lang
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
sandelius has joined #crystal-lang
sandelius has quit [Client Quit]
sandelius has joined #crystal-lang
pawnbox has joined #crystal-lang
<crystal-gh> [crystal] grosser closed pull request #3344: allow calling raise without arguments (master...grosser/raise) https://git.io/viAu6
eizua has quit [Remote host closed the connection]
coderobe has quit [Remote host closed the connection]
coderobe has joined #crystal-lang
kulelu88 has joined #crystal-lang
masukomi has joined #crystal-lang
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<masukomi> I went away for a few weeks and it appears "@foo = nil as String?" is no longer a thing. I tried replacing it with "@foo : String? = nil" and that seemed to mostly work but in one case i'm getting "instance variable @foo of ChangelogDatabase was inferred to be Nil, but Nil alone provides no information"
<masukomi> not sure what the correct new syntax is and I'm not finding anything in the docs about initializing nils other than "@foo = nil"
<masukomi> can anyone tell me what the new syntax is?
<masukomi> @foo = nil.as(String?) ---- is that the new hotness?
<hellyeah> i need to discover what crystal is about
snsei has joined #crystal-lang
<masukomi> ... about having the beauty of ruby combined with the benefits of static typing and fast runtime
<masukomi> did that answer your question @hellyeah ?
<masukomi> i'm really not getting why sometimes @foo : String? = nil is ok and sometimes it complains
<masukomi> just been swapping the complainers to nil.as(String?)
<BlaXpirit> masukomi, nah something is wrong. i mean, you did replace the syntax correctly
<BlaXpirit> but .as(Anything?) seems weird
<masukomi> i agree. i don't like it.
<masukomi> I'll double check...
<BlaXpirit> masukomi, you should proceed with `@foo : String? = nil` and then solve whatever problem comes next
<masukomi> @found_path : String? = nil
<masukomi> is giving me
<masukomi> instance variable @found_path of ChangelogDatabase was inferred to be Nil, but Nil alone provides no information
<masukomi> this is the entire method
<masukomi> def initialize(@launch_dir : String)
<masukomi> @found_path : String? = nil
<masukomi> end
<BlaXpirit> weird
<BlaXpirit> masukomi, oh you're putting that inside the method?
<BlaXpirit> you should put @found_path : String? outside the initialize
<masukomi> oh.
<masukomi> why does it make a difference?
<masukomi> or more... why is what i was doing illegal
<BlaXpirit> masukomi, i dunno, type annotations are not allowed inside methods
<masukomi> but... what if i'm defining a local variable that only exists within the scope of the method?
<BlaXpirit> masukomi, then you don't need type annotations at all
<masukomi> that.... that doesn't sound right to me. I mean, how does it being inside a method change the fact that the compiler needs to know what's legal to assign to it or not
<masukomi> are they like.. magically typed if limited to a single method?
<masukomi> er.. magically dynamically typed instead of statically
<BlaXpirit> masukomi, sounds like you haven't been here in the old days
<masukomi> nah, i wasn't.
<masukomi> to me the type annotations are always nice because they give other developers clues as to what to expect (regardless of if the compiler needs it or not)
<BlaXpirit> Crystal has this algorithm that determines the smallest union of types that the variable could have at this point
<BlaXpirit> in the past there were no type annotations even for instance variables!
<masukomi> bah.
<BlaXpirit> whatever types happen to appear in that spot are added to the union
<masukomi> so, what's the argument for / thinking behind the current inconsisnency of sometimses you put 'em and sometimes you don't ?
<BlaXpirit> that global magic is gone now
<masukomi> <-- not a fan of inconsistence
<masukomi> inconsistency ;)
<BlaXpirit> but for locally scoped things it's totally cool
<BlaXpirit> masukomi, what inconsistency in particular, i don't understand
<masukomi> Sometimes crystal wants me to make type annotations, sometimes it gets mad at me for making them.
<masukomi> i feel like they should always be acceptable even if not necessary
<BlaXpirit> masukomi, it doesn't get mad at you
<BlaXpirit> yes, maybe you're right that it should always be acceptable. but that's not the case right now
<BlaXpirit> but the consistence is there, type annotations are simply not allowed in method bodies
<masukomi> good to know. should i file a ticket with some (hopefully good) reasons why consistency is good and should be supported or is this a dead horse i'd just be beating more?
<BlaXpirit> masukomi, don't phrase it with "consistency" because again, i still don't see anything inconsistent
<BlaXpirit> i only agree that annotations for local variables should be supported
<masukomi> k
<BlaXpirit> >> def f; a : Int32; end
<DeBot> BlaXpirit: #=> nil - https://carc.in/#/r/1asb
<BlaXpirit> wait what
<BlaXpirit> >> def f; a : Int32; end; f()
<DeBot> BlaXpirit: declaring the type of a local variable is not yet supported - https://carc.in/#/r/1ase
<BlaXpirit> masukomi, it explicitly says "not yet supported" so uh safe to assume the developers are aware of this
<masukomi> that would have been a useful compiler error for it to give me
<masukomi> i just tried yours locally and it did give me that error. something about my code didn't result in that message
sandelius has joined #crystal-lang
<BlaXpirit> masukomi, well it's the '@' part
<masukomi> no. i've got an example with no @ that also has the problem
<masukomi> thanks for the help BlaXpirit
kulelu88 has quit [Ping timeout: 272 seconds]
snsei has quit [Remote host closed the connection]
kulelu88 has joined #crystal-lang
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sandelius has joined #crystal-lang
masukomi has quit [Quit: masukomi]
sooli has joined #crystal-lang
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sooli has quit [Remote host closed the connection]
sandelius has joined #crystal-lang
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
phase_ has joined #crystal-lang
greenbig- is now known as greenbigfrog
jadams has joined #crystal-lang
snsei has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
<FromGitter> <crisward> Anyone using crystal-db ?
<FromGitter> <crisward> or json mapping?
<FromGitter> <barisbalic> @crisward you mean the JSON mapping macro?
<FromGitter> <crisward> yes
<FromGitter> <barisbalic> I have used it, why's that?
<FromGitter> <crisward> I'm using it to map out some database results. But I'd like to only return the results in the select, but I need the selected fields even if they're null.
<FromGitter> <crisward> At the moment, I can only get it to return either all the fields in the map, or all the fields with a value.
<FromGitter> <barisbalic> You can have nilable fields... do you have a gist you can share?
<FromGitter> <crisward> I'll create one.
pawnbox has quit [Remote host closed the connection]
<FromGitter> <barisbalic> Ahh okay, I thought you were deserialising JSON, then from what you just said, I would expect that to work.
<FromGitter> <crisward> It does, but it doesn't give me null for the second company, just misses the field out. If I put `emit_null: true` on each field in the map I get null, but I get it every time, even if I don't select it.
<FromGitter> <barisbalic> I will have to look at DB mapping to say any more, but that doesn't sound like it should happen
soveran has joined #crystal-lang
havenwood has quit [Quit: mIRC 5.91 (16 bit) for Microsoft © Windows For WorkGroups 3.11®]
<FromGitter> <barisbalic> @crisward you should clone the repo and run the test suite, https://github.com/crystal-lang/crystal-db/blob/master/spec/mapping_spec.cr#L104 suggests it should work exactly as you expect
soveran has quit [Ping timeout: 255 seconds]
havenwood has joined #crystal-lang
havenwood has quit [Changing host]
havenwood has joined #crystal-lang
<FromGitter> <crisward> I am sure you're right, just hoping for a quick answer from someone who's been there and done that. I'll play with their tests and see if I can re-create the issue.
hellyeah has quit [Ping timeout: 260 seconds]
<FromGitter> <barisbalic> Okay sorry I couldnt be more help
Guest9173 is now known as adam12
soveran has joined #crystal-lang
<FromGitter> <crisward> @barisbalic That's ok, I appreciate the help.
phase_ has quit [Remote host closed the connection]
phase_ has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
jamie-discord has joined #crystal-lang
jamie-discord is now known as jamie-discord1
jamie-discord1 has quit [Remote host closed the connection]
jamie_ca is now known as jamie_ca_
jamie_ca has joined #crystal-lang
phase_ has quit [Ping timeout: 255 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
Philpax has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 240 seconds]
Philpax_ has quit [Ping timeout: 265 seconds]
<crystal-gh> [crystal] asterite pushed 4 new commits to master: https://git.io/vixcX
<crystal-gh> crystal/master 0328d97 Ary Borenszweig: String#rstrip: fixed potential unsafe access past string data
<crystal-gh> crystal/master c1920c6 Ary Borenszweig: Removed extra comment
<crystal-gh> crystal/master 5de901d Ary Borenszweig: Fixed #3341: incorrect cast behaviour on type change
onethirtyfive has joined #crystal-lang
<travis-ci> crystal-lang/crystal#4340d7c (master - Slice#to_s: use Bytes as a name if T is UInt8 (easier to copy-paste)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/162650548
soveran has joined #crystal-lang
soveran has joined #crystal-lang
onethirtyfive has quit [Ping timeout: 240 seconds]
soveran has quit [Ping timeout: 240 seconds]