<FromGitter>
<Blacksmoke16> i've never even seen one :S
_whitelogger has joined #crystal-lang
renich has quit [Ping timeout: 246 seconds]
renich has joined #crystal-lang
zorp has quit [Ping timeout: 240 seconds]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 246 seconds]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter>
<wyhaines> I cut my teeth on an Apple ][+
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
renich has quit [Quit: Leaving.]
zorp has joined #crystal-lang
postmodern has joined #crystal-lang
<postmodern>
is there some way to make an object that implicitly can convert or act like an Int32?
Liothen has quit [Ping timeout: 260 seconds]
Liothen has joined #crystal-lang
zorp has quit [Ping timeout: 240 seconds]
zorp has joined #crystal-lang
postmodern has quit [Quit: Leaving]
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
<FromGitter>
<naqvis> idt crystal (unlike some other langs) has some mechanism for such implicit conversion
<jhass>
yeah, no coercion in Crystal (yet)
alexherbo2 has joined #crystal-lang
<yxhuvud>
tbh I don't see the need for it. It was one of those funky ideas in ruby that seemed neat but never ended up doing much of anything (especially as most developers don't knows the rules around it)
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
alexherbo2 has joined #crystal-lang
zorp has quit [Ping timeout: 264 seconds]
<riffraff169>
type coercion also has lots of gotchas and funky cases that make troubleshooting hard to find when it goes wrong
deavmi has quit [Quit: Eish! Load shedding.]
<riffraff169>
how do i force an int to Int16, or am i better off leaving at Int32? I have the following:
<riffraff169>
@opcodes = {} of String => Array(Int16)
deavmi has joined #crystal-lang
<riffraff169>
but trying to set: myclass.opcodes["BRK"] = [0,-1,-1,-1,-1]
<riffraff169>
gives me the following error: Error: no overload matches 'Hash(String, Array(Int16))#[]=' with types String, Array(Int32)
<riffraff169>
unless im reading the error wrong, that means it is getting an Int32, and doesnt automatically cast to Int16...so what is the best way to do this?
<riffraff169>
make hash have Int32? create something to do type coercion (is that possible, like in julia)?
<FromGitter>
<naqvis> `Int32` is default, so when you don't annotate they default to Int32. For your use case you can do ⏎ `myclass.opcodes["BRK"] = Array(Int16){ 0,-1,-1,-1,-1}`
<riffraff169>
ah, ok, thanks
<riffraff169>
ill figure this out
<FromGitter>
<Blacksmoke16> other option is adding that `of Int16` to the end of the array
<yxhuvud>
I assume you know of Int#to_i16 ?
<FromGitter>
<Blacksmoke16> yes, but not the best solution in this context
<jhass>
Int16[1, 2, 3] is a thing too
<jhass>
and to be complete, [1i16, 2i16, 3i16]
<yxhuvud>
I think you could do Array(Int16){1,2,3} too though I'd have to verify. :D
<yxhuvud>
oh you mentioned that variant already :)
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
alexherbo2 has joined #crystal-lang
Elouin has quit [Quit: So long and thanks for all the fish!]
Elouin has joined #crystal-lang
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo20 is now known as alexherbo2
<riffraff169>
yeah, the Array(Int16) was best, because the data in the array isnt static
<riffraff169>
would be interesting if there were monad classes (there may be and i dont know), so I could to Maybe/Either....my int16 is only int16 because the main data is 0-255 (int8), but i need a "not found" type
<riffraff169>
using -1, other people would use string "none" (ive seen it before)
<riffraff169>
but my program is very basic right now, no shards or anything
<riffraff169>
im not advanced in crystal programming yet...i suppose i should research that now
<riffraff169>
also, is case the best way to do pattern matching? i have a big if block with matching against either a char (string of 1 character), or a regex....now i do realize that most times cases and such basically get converted to if else, just seems inelegant
<riffraff169>
im using StringScanner#scan to do my matching
<FromGitter>
<throwaway4rust> It would be nice if we had patreon to hire someone to finally port it
<FromGitter>
<throwaway4rust> @bcardiff Would this be possible?
<FromGitter>
<throwaway4rust> I am sure we can hire someone if people pitch money...
<FromGitter>
<Blacksmoke16> then you also have to content with those that would think "why spend time working on windows when you could be doing x"
<FromGitter>
<Blacksmoke16> contend*
<FromGitter>
<Blacksmoke16> i.e. something more useful, like MT, or compile speeds etc
<FromGitter>
<throwaway4rust> I mean that fund would be used specifically for hiring a person to port Crystal on Windows
<FromGitter>
<throwaway4rust> and the contributors would mainly be people that are interested in Crystal on Windows
<FromGitter>
<Blacksmoke16> assuming its not a totally brand new person the same idea still applies, one less person able to work on other things.
<FromGitter>
<throwaway4rust> could be a new to hire a new person
<FromGitter>
<throwaway4rust> could be a fund*
<FromGitter>
<Blacksmoke16> doesnt hurt to ask
<jhass>
IMO Maybe(T) is just T?, Either(E,T) is just E|T, List(T) ist just Array(T?)
<riffraff169>
Maybe(T) is either Just(T) (T), or Nothing(T), which is nothing...methods working on those will skip Nothing or Error, and only act on Just or Right (in the case of Either(E,T), which is Left (Error) or Right (value) )
<riffraff169>
you can chain methods using .fmap (with crystal monads, other languages actually have more methods), which will skip the errors or nothings
<jhass>
yeah, I don't see the point of all that noise
<riffraff169>
fmap is flat_map...regular map would fail because it would wrap a Maybe into another Maybe, causing nesting issues
<riffraff169>
Rusts Option and Result types are pretty cool
<jhass>
it makes sense if it's a language feature and as a language feature it barely makes sense outside FP oriented languages. I think what people actually want when going to these weird "monad" libraries is reactive programming (http://reactivex.io/)
<riffraff169>
not always useful, i agree
<jhass>
Rust doesn't have union types, that's why it makes sense in Rust
<riffraff169>
enums are the closest
<jhass>
(automatic union types I should say)
<riffraff169>
which basically result and option are, provided enums
<riffraff169>
i was just thinking about returning data from my list...i only need an Int8 really, but that is for the regular data...then need to be able to signify an error...a result would work, or returning extra data (like go), or expanding the range to Int16 and returning a value outside my normal data for error
<riffraff169>
the latter is what im doing
<jhass>
well don't be afraid to use exceptions if the error is rather uncommon
<FromGitter>
<Blacksmoke16> raise an exception?
deavmi has quit [Read error: Connection reset by peer]
<jhass>
that's what they're there for
deavmi_ has joined #crystal-lang
<jhass>
If it's common, don't be afraid to return Int8|Error and have the caller deal with it
<FromGitter>
<grkek> What is the cause of this `Undefined method 'final' for OpenSSL::Digest`
<FromGitter>
<grkek> ?
<jhass>
I think it got renamed or so?
<FromGitter>
<Blacksmoke16> the method `final` doesn't exist on the type `OpenSSL::Digest`
<FromGitter>
<Blacksmoke16> :S
<jhass>
or digest API still is a mess honestly
<FromGitter>
<grkek> the 0.34.0 doesn't have the final method
<FromGitter>
<grkek> and 0.35.0
<FromGitter>
<grkek> has one?
<FromGitter>
<grkek> since I am able to compile on 0.35.1
<FromGitter>
<grkek> and not on 0.34.0
<jhass>
maybe, there's been some changes to digest inbetween iirc
<FromGitter>
<grkek> I told him to upgrade the crystal from 0.34.0
<jhass>
yeah, makes sense to require latest Crystal in the current state of the ecosystem :)
<FromGitter>
<grkek> I thought of my comment as a bit of irresponsible but this is still pre 1.0.0 release of crystal so the latest you will have the better it will be for everyone right?
<jhass>
latest shards enforces Crystal versions if you give a crystal: attribute in your shard.yml (it supports range restrictions such as >=)
<jhass>
right :)
<FromGitter>
<grkek> Oh that is so good I was about to comment on that, thank you! :)
<riffraff169>
i may have to look at exceptions...ideally this part one generate any errors, but still, who knows
<FromGitter>
<kingsleyh> @watzon hey - I could use a hand if you have any time - I'm trying to get mining working in my Mint app which is embedded inside Electron
Human_G33k has quit [Ping timeout: 258 seconds]
HumanG33k has joined #crystal-lang
deavmi_ has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
postmodern has joined #crystal-lang
<postmodern>
how does one install vim-crystal into ~/.vim/pack? Their README doesn't really mention what directory structure or location for the install?
<FromGitter>
<mtsmmp_gitlab> guys
<FromGitter>
<mtsmmp_gitlab> hello
<FromGitter>
<mtsmmp_gitlab> quick question again
<FromGitter>
<Blacksmoke16> hi
<FromGitter>
<mtsmmp_gitlab> hey
<FromGitter>
<mtsmmp_gitlab> when i do someclass_with_data.to_json it returns me this
<FromGitter>
<mtsmmp_gitlab> ```code paste, see link```
<FromGitter>
<mtsmmp_gitlab> which is totally correct... the problem is that it comes as a string
<FromGitter>
<Blacksmoke16> so?
<FromGitter>
<mtsmmp_gitlab> i need it as a nametuple like this
<FromGitter>
<mtsmmp_gitlab> ```code paste, see link```
<FromGitter>
<Blacksmoke16> why?
<FromGitter>
<mtsmmp_gitlab> just because
<FromGitter>
<Blacksmoke16> you have the obj, just use that
<FromGitter>
<mtsmmp_gitlab> yeah
<FromGitter>
<mtsmmp_gitlab> but no way to convert it fast like to_json but receive a namedtuple?
<jhass>
nope gotta roll your own. You can peak into the code for JSON::Serializable if you need to do it a lot
<FromGitter>
<Blacksmoke16> not by default
<FromGitter>
<mtsmmp_gitlab> ok
<FromGitter>
<mtsmmp_gitlab> i thought i could
<FromGitter>
<mtsmmp_gitlab> ill just use the object then
<FromGitter>
<Blacksmoke16> but id ask why you need to do that in the first place...
<FromGitter>
<Blacksmoke16> yes, that would be the better approach
<FromGitter>
<mtsmmp_gitlab> > but id ask why you need to do that in the first place... ⏎ ⏎ nothing special