jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.9.1 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
trapped has quit [Ping timeout: 272 seconds]
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
nakilon has quit [Ping timeout: 272 seconds]
BlaXpirit has quit [Quit: Konversation]
zodiak has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
McDougal has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
McDougal has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
NeverDie has quit [Ping timeout: 240 seconds]
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
NeverDie has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
nakilon has joined #crystal-lang
nakilon has quit [Ping timeout: 240 seconds]
blue_deref has quit [Quit: bbn]
blue_deref has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
McDougal has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
McDougal has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
leafybas_ has quit [Remote host closed the connection]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
aemadrid has quit [Remote host closed the connection]
ponga has quit [Remote host closed the connection]
mroth has quit [Remote host closed the connection]
buggs has quit [Quit: WeeChat 0.4.2]
lokulin has joined #crystal-lang
nakilon has joined #crystal-lang
nakilon has quit [Ping timeout: 252 seconds]
jwaldrip has quit [Quit: Be back later ...]
jwaldrip has joined #crystal-lang
jwaldrip has quit [Ping timeout: 260 seconds]
leafybas_ has joined #crystal-lang
zz_Cidan is now known as Cidan
leafybas_ has quit [Ping timeout: 250 seconds]
Cidan is now known as zz_Cidan
zz_Cidan is now known as Cidan
McDougal has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
McDougal has joined #crystal-lang
NeverDie has quit [Read error: Connection reset by peer]
McDougal has quit [Quit: Textual IRC Client: www.textualapp.com]
NeverDie has joined #crystal-lang
Cidan is now known as zz_Cidan
leafybas_ has joined #crystal-lang
leafybas_ has quit [Ping timeout: 244 seconds]
ponga has joined #crystal-lang
blue_deref has quit [Quit: bbn]
nakilon has joined #crystal-lang
nakilon has quit [Ping timeout: 260 seconds]
jwaldrip has joined #crystal-lang
jwaldrip has quit [Remote host closed the connection]
trapped has joined #crystal-lang
BlaXpirit has joined #crystal-lang
leafybas_ has joined #crystal-lang
leafybas_ has quit [Ping timeout: 244 seconds]
hangyas has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox_ has quit [Remote host closed the connection]
nakilon has joined #crystal-lang
<nakilon> Error: SHA256 mismatch
leafybas_ has joined #crystal-lang
<nakilon> had to do brew uninstall
<nakilon> what do I use instead of Set.new? a Hash?
<BlaXpirit> nakilon, what do you want to do?
<BlaXpirit> >> Set.new
<DeBot> BlaXpirit: instantiating 'Set(T):Class#new()' - http://carc.in/#/r/m2c
<BlaXpirit> right, right
<BlaXpirit> >> Set(Int).new
<DeBot> BlaXpirit: can't use Int as generic type argument yet, use a more specific type - http://carc.in/#/r/m2d
<BlaXpirit> >> Set(Int32).new
<DeBot> BlaXpirit: # => Set{} - http://carc.in/#/r/m2e
<nakilon> nice that it exists -- I just didn't see it in crystal-lang.org/docs
<nakilon> still not sure where can I "see all the types I may use while coding in Crystal"
<BlaXpirit> nakilon, http://crystal-lang.org/api/
<nakilon> oh, thx
<nakilon> in Ruby I have a code smth like this: my_function(some_arg, l1, l2, l3), where l1, l2, l3 are lambdas
<nakilon> how do I do it in Crystal properly?
<nakilon> and with minimal effort
<nakilon> Syntax error in ./main.cr:38: unterminated parenthesized expression --- f [start, ""], (lambda do |(state, _)|
<nakilon> oh maybe it's because of |()| -- i remmeber it didn't work in Crystal
<nakilon> nvm
Ven_ has joined #crystal-lang
<nakilon> yay, I cna't use _ as identifier? (
<RX14> >> 1.tap { |_| puts _ }
<DeBot> RX14: can't read from _ - http://carc.in/#/r/m2g
<RX14> :C
<RX14> >> 1.tap { |a| puts a }
<DeBot> RX14: 1 - more at http://carc.in/#/r/m2h
<RX14> >> 1.tap { |a| a }
<DeBot> RX14: # => 1 - http://carc.in/#/r/m2i
<RX14> >> 1.tap { |_| _ }
<DeBot> RX14: can't read from _ - http://carc.in/#/r/m2j
<RX14> >> _
<DeBot> RX14: can't read from _ - http://carc.in/#/r/m2k
<RX14> I used _ as "ignored variable" in blocks
<nakilon> what's wrong with this? http://carc.in/#/r/m2l
<RX14> for any variable i didn't actually use
<nakilon> RX14, I use it also for temp vars, that aren't used anymore alrady 5 chars of code after that point
<nakilon> now would use 't' ..D
<RX14> nakilon, hmmn, I have no idea what's going on there
<RX14> nakilon, http://carc.in/#/r/m2q
<RX14> that works
<RX14> http://carc.in/#/r/m2r this works
<RX14> you need brackets in the function call it looks like
<RX14> might be a bug
<nakilon> passing lambda to function also works
<RX14> nakilon, yeah, you just need to use brackets when calling the function
<nakilon> should I report?
Philpax has joined #crystal-lang
<RX14> might as well
<RX14> actually
<RX14> probably not
<nakilon> jhass, hi, what do you think about http://carc.in/#/r/m2l
* nakilon didn't work with Crystal for 2-3 months, so is not sure about syntax anymore anyhow
Philpax has quit [Client Quit]
Ven_ has quit [Read error: Connection reset by peer]
<RX14> i feel like making something in crystal
Ven_ has joined #crystal-lang
ponga has quit [Remote host closed the connection]
nakilon_ has joined #crystal-lang
nakilon has quit [Ping timeout: 246 seconds]
mroth has joined #crystal-lang
Ven_ has quit [Read error: Connection reset by peer]
Ven_ has joined #crystal-lang
aemadrid has joined #crystal-lang
<jiriki> asdf
Ven_ has quit [Read error: Connection reset by peer]
Ven_ has joined #crystal-lang
Ven_ has quit [Read error: Connection reset by peer]
Ven__ has joined #crystal-lang
leafybas_ has quit [Remote host closed the connection]
Ven__ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ponga has joined #crystal-lang
hangyas has quit [Quit: hangyas]
<jokke> can i raise a method missing error from a method_missing macro?
leafybas_ has joined #crystal-lang
A124 has joined #crystal-lang
leafybas_ has quit [Remote host closed the connection]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
<jhass> jokke: dunno, I'd probably just use {{raise}}
<jhass> nakilon_: looks like a parser bug, yeah
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
leafybas_ has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
leafybas_ has quit [Ping timeout: 240 seconds]
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
<nakilon_> Proc([] of (Array | String), Bool).new{ |t| state, _ = t -- expecting token 'CONST', not '[]'
NeverDie has quit [Quit: http://radiux.io/]
<nakilon_> what's wrong with my syntax?
<BlaXpirit> nakilon_, uhhhhhhhhhh
<BlaXpirit> does Proc([1,2,3]) make sense to you?
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
<nakilon_> BlaXpirit, I want a lambda that accepts an array of two elements (array and string) and returns bool
<BlaXpirit> nakilon_, coming from ruby? -_-
<BlaXpirit> what purpose does this array serve in your process of thought?
<nakilon_> from ruby
<nakilon_> it's a "state of the game" for A.I.
<nakilon_> my ruby program finds solution in 5-10 minutes, and I want faster
<BlaXpirit> what you have is not applicable to Crystal on multiple levels, i don't know where to begin
<nakilon_> the deep walking function should teke the initial state and several lambdas that describe data transformation
<nakilon_> how is it not applicable? _Oo
<jhass> [] of ... is the equivalent to Array(...).new
<jhass> notice the .new
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<nakilon_> i'm feeling have no clue in Crystal type definitions ..\ for example, the ruby lambda is 'lambda do |(state, _)|', where state is an array and _ is a string, that I'll omit in that lambda but it doesn't matter, since the deep-walking function should know what the lambda is doing
<nakilon_> it should know here only that it returns bool
<nakilon_> so I do in crystal : '->(t : Array){' and get 'cannot be used as a Proc argument type yet, use a more specific type'
<jhass> so, do that
<jhass> don't use Array
<jhass> use Array(Whatever)
<BlaXpirit> i'm afraid this is not just an array of some type
<BlaXpirit> just an attempt at misuse
<BlaXpirit> nakilon_, have you read the introduction/documentation to Crystal?
<nakilon_> I thought this means I should switch to Proc.new syntax, so I do 'Proc.new(([] of Array | String), Bool){' and get 'can't use Array(T) in unions yet, use a more specific type'
<jhass> no, it doesn't mean that
<nakilon_> ok
<jhass> it means what it says, use a more specific type in place of the generic
<nakilon_> ->(t : Array of Array | String){ --- expecting token 'IDENT', not 'Array'
<BlaXpirit> nakilon_, have you read the introduction/documentation to Crystal?
<nakilon_> BlaXpirit, had
NeverDie has joined #crystal-lang
<nakilon_> I see no chapter on complex types definitions
<jhass> Array of ... doesn't make any sense
<BlaXpirit> well you're just putting random words together and trying to apply sloppy practices from ruby
<jhass> I just gave you an example above
<jhass> Array(Whatever)
<nakilon_> every C/C++ book has a chapter on those things how to build complex definitions
<jhass> or Array(Array(????)|String)
<jhass> note the ???? are because I can't guess what you want there
<nakilon_> hmmm that array is a nested of array of arrays ..D just a minute
<jhass> alias MyDataStuff = Array(MyDataStuff)|String if I had to guess from your vague description
<jhass> -> (t : MyDataStuff)
<nakilon_> seems like ->(t : Array(Array(Array(Array(Symbol | Int32))) | String)){ did the job -- i'll look into further exceptions
<jhass> at least make an alias for that
<nakilon_> alias is like typedef? cool
<jhass> but you're probably far better off with doing a (couple of) wrapper structs for your data
<jhass> There's also a Matrix class, but I'll stop guessing whatever your datastructure looks like now
<BlaXpirit> I'm pretty sure the outermost is actually {Array(...), String}
<BlaXpirit> but whatever
pawnbox_ has joined #crystal-lang
blue_deref has joined #crystal-lang
pawnbox_ has quit [Remote host closed the connection]
zz_Cidan is now known as Cidan
leafybas_ has joined #crystal-lang
leafybas_ has quit [Ping timeout: 260 seconds]
NeverDie has quit [Quit: http://radiux.io/]
NeverDie has joined #crystal-lang
Locke23rus has joined #crystal-lang
Locke23rus has quit [Remote host closed the connection]
NeverDie_ has joined #crystal-lang
NeverDie has quit [Ping timeout: 240 seconds]
NeverDie_ has quit [Client Quit]
NeverDie has joined #crystal-lang
NeverDie has quit [Max SendQ exceeded]
NeverDie has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/v8Rfz
<crystal-gh> crystal/master 235f134 Ary Borenszweig: Fixed #1875: parser bug related to call, fun literal and do
Cidan is now known as zz_Cidan
<travis-ci> manastech/crystal#235f134 (master - Fixed #1875: parser bug related to call, fun literal and do): The build passed. https://travis-ci.org/manastech/crystal/builds/89959513
<DeBot> https://github.com/manastech/crystal/issues/1875 (function doesn't accept lambda as a parameter)
<nakilon_> hm
<nakilon_> alias State = Array(Array(Tuple(Symbol, Int32, Int32)))
<nakilon_> ->(state : State,
<nakilon_> state.flat_map do |col| -- in ./main.cr:47: instantiating 'Hash(Int32 | Symbol, Array(Array(Int32 | Symbol)))#each()'
<nakilon_> it thinks about my tuple as about heterogenuos array
<nakilon_> and then .map(&.last).sort says it can't - Int32#<(other : Symbol)
<jhass> please provide a runnable example that reproduces
<nakilon_> k
<nakilon_> yeah i've described the problem with mistake
<nakilon_> problem is somewhere around .map
<nakilon_> [color, i] is (Int32 | Symbol)
<nakilon_> seems like .last of it is that tye to, so the .map(&.last) isn't sortable array
<nakilon_> *type
<RX14> nakilon_, why not use a record instead of a tuple
<nakilon_> RX14, what is that?
<jhass> nakilon_: you're not passing tuples. I'm a bit surprised it passes through the type restriction
<nakilon_> jhass, when initializing 'start'?
<RX14> tbh that code is unreadable
<RX14> and I can't be assed to try
<nakilon_> sorry for not solving bubble sort algorithms
<jhass> no idea where n is supposed to come from
<nakilon_> just a second
<RX14> nakilon_, http://crystal-lang.org/api/toplevel.html#record%28name%2C%2Aproperties%29-macro
<nakilon_> seems working; weird, that it doesn't see 'n' in my code too, while it's declared higher
<RX14> this is a record BTW
<RX14> but i guess tuples are better here
<RX14> kinda
<RX14> for a while
<nakilon_> RX14, thx for the link
<nakilon_> yay, flatten(n) isn't yet implemented (
<nakilon_> is there a nice way to translate '.tap &method(:puts)' to crystal?
<RX14> .tap &.puts?
<RX14> >> "a".tap &.puts
<DeBot> RX14: undefined method 'puts' for String - http://carc.in/#/r/m3p
<RX14> oh
<RX14> hmmn
<RX14> >> "a".tap { |a| puts a }
<DeBot> RX14: a - more at http://carc.in/#/r/m3q
<RX14> >> "a".tap &puts
<DeBot> RX14: expected a function type, not Nil - http://carc.in/#/r/m3r
<nakilon_> and what about .with_index?
<nakilon_> state.flat_map.with_index do
<RX14> >> "a".tap puts
<DeBot> RX14: wrong number of arguments for 'String#tap' (1 for 0) - http://carc.in/#/r/m3s
<nakilon_> how do I translate this?
<nakilon_> i see this method in specs, but: 'Array(Array({Symbol, Int32, Int32}))#flat_map' is expected to be invoked with a block, but no block was given
leafybas_ has joined #crystal-lang
<nakilon_> looks like .flatten isn't an iterator
<nakilon_> i mean flat_map
<RX14> nakilon_, well, it could be
leafybas_ has quit [Ping timeout: 272 seconds]
<nakilon_> seems like Tuple is immutable _<>
<RX14> well yeah
<RX14> >> [1, 2].with_index.flat_map
<DeBot> RX14: undefined method 'with_index' for Array(Int32) - http://carc.in/#/r/m3y
<nakilon_> and seems like .concat can't concat complex types
<RX14> >> [1, 2].each_index.flat_map
<DeBot> RX14: 'Array::IndexIterator(Int32)#flat_map' is expected to be invoked with a block, but no block was given - http://carc.in/#/r/m3z
<nakilon_> also about above: undefined method 'with_index' for Array(Array({Symbol, Int32, Int32}))
<RX14> each_index
<RX14> and it only returns the index
<RX14> not the object
<RX14> yeah, doesn't look possible
<nakilon_> is my gist related to https://github.com/manastech/crystal/pull/1091 ?
<nakilon_> forget about my gist )
leafybas_ has joined #crystal-lang
<nakilon_> whats wrong with this? http://carc.in/#/r/m40
<nakilon_> without 'next [] ...' it doesn't faik
<nakilon_> *faik
<nakilon_> **fail
<nakilon_> oh, nesting i guess
<nakilon_> seems like 'next [] of Array(State | String) if col.empty?' works, but there is warning: Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file /tmp/llvm20150726-4892-1fwslb7/llvm-3.6.2.src/lib/IR/Instructions.cpp, line 281.
<RX14> sounds like a bug to me
NeverDie has quit [Quit: http://radiux.io/]
NeverDie has joined #crystal-lang
NeverDie has quit [Max SendQ exceeded]
NeverDie has joined #crystal-lang
<nakilon_> someone explain me why this differs:
<nakilon_> ruby vs crystal, String#scan
<RX14> >> "asdf" * 0
<DeBot> RX14: # => "" - http://carc.in/#/r/m45
<RX14> >> "a" * 0
<DeBot> RX14: # => "" - http://carc.in/#/r/m46
<RX14> oic
<RX14> >> "a" * 2
<DeBot> RX14: # => "aa" - http://carc.in/#/r/m47
<nakilon_> i guess i use matchdata incorrectly
<nakilon_> this is not good, that behaviour diffes
<nakilon_> yay, we don't allow to enlarge Arrays by []= to the far index?
<nakilon_> >> a = [1]; a[3] = 2
<DeBot> nakilon_: Index out of bounds (IndexError) - http://carc.in/#/r/m48
<nakilon_> I do this to make arrays transposable
<nakilon_> jhass, can you comment this please?
<jhass> crystal arrays do not autogrow, that is intentional
<nakilon_> what should I do instead?
<jhass> append elements explicitly
<nakilon_> max = large.map(&.size).max
<nakilon_> large.each{ |col| col[max - 1] = col[max - 1] }
<jhass> maybe on of the #fill APIs work too, I don't remember
<jhass> that's... reverse?
<nakilon_> that's adding Nils to the end of lines until array becomes transposable
<nakilon_> for example, for printing
<nakilon_> yay, no overload matches 'Array(Int32)#fill' with types Nil, Range(Int32, Int32)
<jhass> you need to create your array to allow nils if you want to allow nils
<nakilon_> how do I append nil? ..(
<nakilon_> ok
<jhass> the initial type must allow it
<nakilon_> then it's not only simple vector isn't autogrowing, but the whole array would need another instance for my case (
<nakilon_> probbaly
<nakilon_> or actually I can fill it not nils but smth already known
A124 has quit [Quit: '']
A124 has joined #crystal-lang
zz_Cidan is now known as Cidan
Cidan is now known as zz_Cidan
<nakilon_> in my case it results in large.each{ |col| col.concat [{:"", 0}] * (max - col.size); }
<nakilon_> and when I print that array it smells like: t[0] == :"" ? " " :
<nakilon_> damn, I made this program in 6 hours and translating for already the same amount of time ..D
buggs has joined #crystal-lang
<nakilon_> works only few times faster than Ruby ..( I guess I miss something important
<CompanionCube> did you build with --release
<jokke> jhass: what do you think: Is this is a bug or a feature?
<jokke> >> "foo".match(/foo(bar)?/).not_nil![1]
<DeBot> jokke: Nil assertion failed (Exception) - http://carc.in/#/r/m4a
<CompanionCube> nakilon_, ^
<jokke> imho that should return nil
<jokke> because the capture group does exist
<jokke> it's just empty
<jhass> >> "foo".match(/foo(bar)?/)
<DeBot> jhass: # => #<Regex::MatchData "foo" 1:nil> - http://carc.in/#/r/m4b
<jokke> yes
<jhass> >> "foo".[/foo(bar)?/, 1]
<DeBot> jhass: Syntax error in eval:21: expecting any of these tokens: IDENT, +, -, *, /, %, |, &, ^, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ||, &&, ===, [], []=, []?, ! (not '[') - http://carc.in/#/r/m4c
<jhass> er
<jhass> >> "foo"[/foo(bar)?/, 1]
<DeBot> jhass: Nil assertion failed (Exception) - http://carc.in/#/r/m4d
<jhass> >> "foo"[/foo(bar)?/, 1]?
<DeBot> jhass: # => nil - http://carc.in/#/r/m4e
<jokke> note where the nil assertion is failing
<jhass> we only have #[], making it nilable would be annoying
<jhass> so we also have #[]?
<jhass> the compiler doesn't magically know that if you pass 1 to #[] it's an optional group and nilable
<jokke> yeah i guess it would be annoying
Ven has joined #crystal-lang
<jokke> ok what about ""?
<jokke> naah
<jhass> we had that, it was bad
<jokke> that'd be even more annoying
<jokke> ok thanks for your input
<jokke> i'm writing a standalone router for crystal btw!
<jokke> that's how i stumbled across this
<jokke> "/foo/:bar(/:baz)"
<jokke> params["baz"]
<nakilon_> CompanionCube, tried with --release now
<CompanionCube> faster?
<nakilon_> $ crystal build --release main.cr $ time ./main
<nakilon_> I didn't spot the difference ..\
<CompanionCube> odd, because that turns on optimizations
<nakilon_> this is the diff (could have some mistakes, because I edited in manually a bit after generating) https://gist.github.com/Nakilon/f82356e04ff0ec7320eb
<nakilon_> i'll measure time without --release
<nakilon_> almost all lines had to be rewritten (
<nakilon_> the most annoying part was no splatting in blocks
<nakilon_> CompanionCube, 5m56.764s vs 4m38.665s
<CompanionCube> that's a decent difference
<CompanionCube> 51s saved by a flag
<nakilon_> only 20%
<nakilon_> with that compile time increased by 10 or 20 seconds
<nakilon_> from... <1s ?
<nakilon_> and it's 3m53.233s in Ruby!
<nakilon_> wtf
Ven has quit [Read error: Connection reset by peer]
Ven_ has joined #crystal-lang
Ven_ has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
BlaXpirit has quit [Quit: Konversation]
BlaXpirit has joined #crystal-lang
McDougal has joined #crystal-lang
leafybas_ has quit [Remote host closed the connection]
leafybas_ has joined #crystal-lang
BlaXpirit has quit [Remote host closed the connection]
Ven has quit [Read error: Connection reset by peer]
BlaXpirit has joined #crystal-lang
Ven has joined #crystal-lang
McDougal has left #crystal-lang ["Textual IRC Client: www.textualapp.com"]
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Client Quit]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
McDougal has joined #crystal-lang
McDougal has left #crystal-lang [#crystal-lang]
Ven has joined #crystal-lang
Ven has quit [Client Quit]
trapped has quit [Quit: Textual IRC Client: www.textualapp.com]