ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.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> <tenebrousedge> somewhat. Any recursive function is isomorphic to some other non-recursive function
<FromGitter> <tenebrousedge> you can trade elegance for stack frames
<FromGitter> <ilanpillemer> and not using up the stack
<FromGitter> <tenebrousedge> s'what I mean
<FromGitter> <ilanpillemer> maybe delete should use the spaceship too
<FromGitter> <tenebrousedge> The truth is out there
<FromGitter> <ilanpillemer> and insert
<FromGitter> <tenebrousedge> `when 1,0`
<FromGitter> <ilanpillemer> 0,-1
<FromGitter> <tenebrousedge> you're doing `other <=> value` ?
alex`` has quit [Quit: WeeChat 2.6]
<FromGitter> <ilanpillemer> Iโ€™ve updated the exercism
<FromGitter> <ImAHopelessDev_gitlab> <=> wtf is that
<FromGitter> <ilanpillemer> its a spaceship!
<FromGitter> <ilanpillemer> ๐Ÿ‘พ
<FromGitter> <tenebrousedge> now I want to program in Emojicode
<FromGitter> <ilanpillemer> check out `smiley.c`
<FromGitter> <ImAHopelessDev_gitlab> less than or equal to, but also equals to greater?
<FromGitter> <tenebrousedge> it's trinary
<FromGitter> <ilanpillemer> https://gist.github.com/anastasop/3739562
<FromGitter> <tenebrousedge> returns `-1` for less than, `0` for equality, and `1` for greater than
<FromGitter> <ilanpillemer> it really makes the semantics of the code clearer
<FromGitter> <ImAHopelessDev_gitlab> hmmm
alex`` has joined #crystal-lang
<FromGitter> <ilanpillemer> oooh.. I can get rid of the ugly brackets all over the place!
<FromGitter> <ilanpillemer> `become left.not_nil! if parent.nil?`
<FromGitter> <tenebrousedge> you noted how I did the delete `case` statement? Not that that's something to emulate, but it's good to know the technique
<FromGitter> <ilanpillemer> yes. I liked that.
<FromGitter> <ilanpillemer> I didnโ€™t know that was possible.
<FromGitter> <ilanpillemer> using assignment for Nil checks and then pattern matching is an interesting idiom too.
<FromGitter> <ilanpillemer> I didnt know you could pattern match on classes
<FromGitter> <ilanpillemer> that could be really neat for simple parsers.
<FromGitter> <tenebrousedge> yep, case equality is convenient
<FromGitter> <tenebrousedge> did you also happen to take a look at `Enum` ?
<FromGitter> <ilanpillemer> I skim read it.. I saw you can give them methods too.
<FromGitter> <tenebrousedge> I suppose. It's also possible to change their type (default is `Int32`, most things probably only need `UInt8`)
<FromGitter> <ilanpillemer> your search kind of loses the performance of binary search.
<FromGitter> <tenebrousedge> yes
<FromGitter> <ilanpillemer> as you make it an array and then iterate!
<FromGitter> <tenebrousedge> I'm lazy
<FromGitter> <ilanpillemer> lol
<FromGitter> <ilanpillemer> same with the iterator I guess too
<FromGitter> <tenebrousedge> I like my `Enumerable` data structures
<FromGitter> <ilanpillemer> I guess you want iterators for infinite things
<FromGitter> <tenebrousedge> or things of uncertain length
<FromGitter> <ilanpillemer> kind of like a generator
<FromGitter> <tenebrousedge> yes
<FromGitter> <tenebrousedge> going back to the protein-encoding problem
<FromGitter> <ilanpillemer> gnight! that was fun. tomorrow evening I will start in the react one.
<FromGitter> <tenebrousedge> good luck :/
<FromGitter> <ilanpillemer> have you done that one yet?
<FromGitter> <tenebrousedge> I've wrestled with certain parts. Some things I want to do are probably impossible
<FromGitter> <ilanpillemer> So I will start wrangling with it tomorrow evening..
<FromGitter> <tenebrousedge> I recommend a stiff drink
<FromGitter> <ilanpillemer> Gin, lime and tonic!
<FromGitter> <tenebrousedge> it won't help the coding but it might take some of the pain of the problem away
<FromGitter> <ilanpillemer> I was trying to see how drunk I could get and solve AoC problems a few weeks ago.
<FromGitter> <ilanpillemer> Managed to do one in a bleary state.
<FromGitter> <ilanpillemer> Admittedly not a difficult one
<FromGitter> <tenebrousedge> well, let me know how this one goes
hypercore has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 246 seconds]
_whitelogger has joined #crystal-lang
chemist69 has quit [Ping timeout: 246 seconds]
chemist69 has joined #crystal-lang
alex`` has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 240 seconds]
<FromGitter> <wwselleck> Say I wanted to create a function that took an object that looked something like this (pseudocode) โŽ โŽ ```code paste, see link``` โŽ โŽ And then I'd have to construct the class, making sure to pass the argument in the correct order. [https://gitter.im/crystal-lang/crystal?at=5d9d5ef997358746731f3851]
ht_ has joined #crystal-lang
ht_ has quit [Quit: ht_]
absolutejam4 has joined #crystal-lang
DTZUZO_ has quit [Ping timeout: 268 seconds]
t1|Mike has quit [Quit: ZNC 1.7.1 - https://znc.in]
t1|Mike has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> https://crystal-lang.org/api/0.31.1/toplevel.html#record(name,*properties)-macro @wwselleck ?
<FromGitter> <absolutejam_gitlab> or just a tuple?
<FromGitter> <absolutejam_gitlab> / namedtuple
<FromGitter> <absolutejam_gitlab> probably a record for brevity and reusability though
absolutejam4 has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
tdc has quit [Ping timeout: 268 seconds]
t1|Mike has quit [Remote host closed the connection]
t1|Mike has joined #crystal-lang
<FromGitter> <bew> @Blacksmoke16 thanks for the note on `setter` I updated my comment to add this!
rohitpaulk has quit [Ping timeout: 240 seconds]
absolutejam4 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
absolutejam4 has quit [Ping timeout: 240 seconds]
absolutejam4 has joined #crystal-lang
tdc has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 265 seconds]
absolutejam4 has joined #crystal-lang
tdc has quit [Ping timeout: 250 seconds]
vegai has joined #crystal-lang
DTZUZO_ has joined #crystal-lang
alex`` has joined #crystal-lang
coderobe has quit [Read error: Connection reset by peer]
coderobe has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 245 seconds]
absolutejam4 has joined #crystal-lang
<FromGitter> <Blacksmoke16> ๐Ÿ˜ฎ
<FromGitter> <Blacksmoke16> am i famous? :p
rohitpaulk has joined #crystal-lang
tdc has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <repromancer_gitlab> Trying to follow along with Scott Wlaschin's F# book using Crystal, and there's this generic type definition that looks like this: โŽ โŽ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9de2bf874aeb2d23170f0b]
tdc has quit [Quit: Leaving]
<FromGitter> <repromancer_gitlab> this is the closest I seem to have gotten so far: https://play.crystal-lang.org/#/r/7qt7
<FromGitter> <Blacksmoke16> could just do โŽ โŽ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9de34f7aa5602ffc97fc0f]
<FromGitter> <Blacksmoke16> or is `type PlaceOrder = Command<UnvalidatedOrder>` how F# handles inheritence?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7qt8
<FromGitter> <repromancer_gitlab> I believe that's more or less the same as Crystal's `alias`
<FromGitter> <Blacksmoke16> can just define the initializer in the parent and it will be in the children
<FromGitter> <repromancer_gitlab> I actually did do exactly that at first, and not that I think about it, it may the correct analog the the F# code.
<FromGitter> <repromancer_gitlab> I'll try to explain why I thought this was wrong. One second.
<FromGitter> <Blacksmoke16> if you need the child to define its own initializer ( say for custom ivars or something), then you would do like `super data`
<FromGitter> <repromancer_gitlab> Originally I wrote this out, and since the book hadn't specified yet what the `ChangeOrder` and `CancelOrder` would take, I just made a union called `Order`: โŽ โŽ https://play.crystal-lang.org/#/r/7qtu
<FromGitter> <Blacksmoke16> should they be their own types, vs another property on `Order` like `status`?
<FromGitter> <repromancer_gitlab> When I noticed that the union `OrderTakingCommand` was only a union of two distinct types, I got all weirded out, but actually I'm pretty sure the F# type system would do the same thing at this level of specificity.
<FromGitter> <repromancer_gitlab> Yes, that's the line of thinking in the book.
<FromGitter> <j8r> You can use an enum
<FromGitter> <j8r> instead of records, and then the alias can be removed
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7qtx
<FromGitter> <j8r> ๐Ÿ’ฏ
<FromGitter> <absolutejam_gitlab> Writing js ๐Ÿ”ซ
<FromGitter> <absolutejam_gitlab> `const isEmpty = require('loadash.isempty');` โŽ I need to import this?!
cpt_yossarian has joined #crystal-lang
<FromGitter> <repromancer_gitlab> Unfortunately for my purposes (following along with the book), the different order states need to actually be distinct types. XD Though I agree, if I was just doing things a conventional way, your Enum suggestion would be the best choice. :)
<FromGitter> <Blacksmoke16> whats the reason?
<FromGitter> <repromancer_gitlab> I think I'm actually on the right track, though, going with your original suggestion @Blacksmoke16
<FromGitter> <absolutejam_gitlab> and getting `undefined` if I try to access an object key that doesn't exist. There's parts I start to like then I Just get sad
<FromGitter> <repromancer_gitlab> I think I was just overthinking it
snapcase_ has joined #crystal-lang
alex``` has joined #crystal-lang
confact_ has joined #crystal-lang
woodruffw has quit [Ping timeout: 268 seconds]
mjblack has quit [Ping timeout: 268 seconds]
confact has quit [Ping timeout: 268 seconds]
badeball has quit [Ping timeout: 268 seconds]
alex`` has quit [Ping timeout: 268 seconds]
snapcase has quit [Ping timeout: 268 seconds]
confact_ is now known as confact
<FromGitter> <j8r> @repromancer_gitlab you know you can add class methods to the enum also
<FromGitter> <repromancer_gitlab> The thesis of the book is to have the compiler enforce business rules via the type system, "making illegal states unrepresentable", that sort of thing.
<FromGitter> <Blacksmoke16> isnt that what an enum is
<FromGitter> <Blacksmoke16> would prevent you from setting `status` to anything that isn't defined in the enum
<FromGitter> <Blacksmoke16> also would handle typos as it would error if you did like `:cancelled`
<FromGitter> <Blacksmoke16> even tho its "right"
<alex```> does "credit" take a "s" in "Give credit to A and B" ?
<alex```> or it's singular
<FromGitter> <absolutejam_gitlab> singular
<FromGitter> <repromancer_gitlab> Right, but in this case I need a struct that can contain fields.
<alex```> thanks absolutejam4
<FromGitter> <repromancer_gitlab> https://www.youtube.com/watch?v=Up7LcbGZFuo
<FromGitter> <Blacksmoke16> you can add methods to your enum
<FromGitter> <repromancer_gitlab> ^ this talk (by the book's author) explains what I'm after
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7qu2
<FromGitter> <Blacksmoke16> but fair enough
<FromGitter> <repromancer_gitlab> the problem is that an Enum can't be used to model several distinct Structs underneath each key
<FromGitter> <Blacksmoke16> true
<FromGitter> <repromancer_gitlab> I need what's called a "choice type" in ML languages, and in Crystal, a union of distinct classes/structs is closer to that than an Enum
<FromGitter> <Blacksmoke16> also cant use an enum members as a type restriction
<FromGitter> <repromancer_gitlab> right, exactly
<FromGitter> <repromancer_gitlab> I'm basically trying to see how much of OCaml/F#'s compiler-guaranteed-correctness that I can get out of Crystal, which I realize doesn't have exactly this sort of thing in mind.
<FromGitter> <repromancer_gitlab> probably the biggest hurdle will be that `case` doesn't enforce exhaustive matching for union types (and I think it's only being considered as an option for Enum types)
<FromGitter> <Blacksmoke16> there is an issue about that atm
<FromGitter> <repromancer_gitlab> Oh, I just noticed "It would *also* work for enums"
<FromGitter> <repromancer_gitlab> so it is for unions in general, plus Enum
<FromGitter> <Blacksmoke16> i meant you can do โŽ โŽ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9deb5c7aa5602ffc98370f]
<FromGitter> <Blacksmoke16> something like that?
<FromGitter> <repromancer_gitlab> Basically, I need the compiler to be able to warn me when I expand an existing union type.
<FromGitter> <repromancer_gitlab> so if `Order` is `UnvalidatedOrder | ValidatedOrder`, and I have a `case order when Unvalidated etc ...` somewhere, and I add some other state to the `Order` alias, I need the compiler to tell me "hey, your new Order subtype is not handled in that case statement you wrote months ago"
<FromGitter> <repromancer_gitlab> which that RFC will definitely solve
<FromGitter> <absolutejam_gitlab> I ran into this a while back and saved an example
<FromGitter> <absolutejam_gitlab> https://play.crystal-lang.org/#/r/7qu8
<FromGitter> <absolutejam_gitlab> is that to be expected?
<FromGitter> <repromancer_gitlab> (even if it's not the word `case`)
<FromGitter> <absolutejam_gitlab> The compiler not catching that?
<FromGitter> <ImAHopelessDev_gitlab> show me on the doll where classes hurt you
<FromGitter> <ImAHopelessDev_gitlab> @absolutejam_gitlab can you link that twitter thread?
<FromGitter> <repromancer_gitlab> @absolutejam_gitlab what is the compiler not catching?
<FromGitter> <absolutejam_gitlab> `String + 10`
<FromGitter> <absolutejam_gitlab> It throws a runtime error
<FromGitter> <repromancer_gitlab> I see this on the page you linked: โŽ โŽ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9ded6004592546721fb537]
<FromGitter> <repromancer_gitlab> oh, I'm sorry
<FromGitter> <repromancer_gitlab> is that a runtime error?
<FromGitter> <repromancer_gitlab> I thought it was the compiler.
<FromGitter> <absolutejam_gitlab> i might be wrong
<FromGitter> <absolutejam_gitlab> I saved a snippet that I half remember a while back
<FromGitter> <absolutejam_gitlab> trying to be useful
<FromGitter> <absolutejam_gitlab> and I've just remembered
<FromGitter> <absolutejam_gitlab> I could be comepletely wrong
<FromGitter> <Blacksmoke16> thats deff a compiler error
<FromGitter> <absolutejam_gitlab> I had an instance like that example, maybe I've misremembered it
<FromGitter> <absolutejam_gitlab> or maybe I never had the issue originally
<FromGitter> <repromancer_gitlab> I never read this text before, lol "Showing last frame. Use --error-trace for full trace."
<FromGitter> <absolutejam_gitlab> oh no, I think I remember what it was
<FromGitter> <absolutejam_gitlab> if you comment out the last line
<FromGitter> <absolutejam_gitlab> it passes compliation
<FromGitter> <absolutejam_gitlab> eventhough it has a bad code path in the case statement
<FromGitter> <absolutejam_gitlab> I think I tested similar in Go and it was caught
<FromGitter> <repromancer_gitlab> I think this is because Crystal does not bother to check dead code.
<FromGitter> <absolutejam_gitlab> Doesn't really help that i'm throwing old, incorrect info out
<FromGitter> <repromancer_gitlab> Since that line will never be run, it's not checked.
<FromGitter> <absolutejam_gitlab> But it could be run based on outside factors, which is why I wasn't sure if it was just how the compiler did htings
<FromGitter> <absolutejam_gitlab> things*
<FromGitter> <absolutejam_gitlab> or could it?
<FromGitter> <absolutejam_gitlab> Probably not, because the instance exists but nothing is actually calling the method on it
<FromGitter> <absolutejam_gitlab> Alright, I'll pipe down.
<FromGitter> <repromancer_gitlab> That's definitely a concern, if you're only writing a library for use elsewhere, for example. I believe the consensus is ensure checking by writing a test suite.
<FromGitter> <repromancer_gitlab> if you have tests calling your functions, they'll no longer be dead code as far as the compiler is concenred.
<FromGitter> <repromancer_gitlab> at least when the tests are compiiled
<FromGitter> <kinxer> That's why library shards (ideally) need to have specs with more-or-less exhaustive code coverage.
<FromGitter> <absolutejam_gitlab> yeah, fair enough
<FromGitter> <absolutejam_gitlab> half the shards don't even have a README
<FromGitter> <kinxer> I evidently didn't read what @repromancer_gitlab had just sent...
<FromGitter> <Blacksmoke16> i blame gitter
<FromGitter> <kinxer> I'll just say I'm helping lend credence to those words. :P
<FromGitter> <repromancer_gitlab> lol, well at least I've contributed something today to make up for my bikeshedding
<FromGitter> <ImAHopelessDev_gitlab> gitter has an annoying bug where sometimes the scroll goes down but displays only half of the message. so i click on a pm and back t the crystal chat and it fixes it lol
alex``` has quit [Ping timeout: 276 seconds]
alex``` has joined #crystal-lang
alex``` has quit [Ping timeout: 265 seconds]
alex`` has joined #crystal-lang
ht_ has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 240 seconds]
alex`` has quit [Quit: WeeChat 2.6]
<FromGitter> <Blacksmoke16> if i had a twitter id reply with the blog post showing how kinda slow it is :p https://twitter.com/mitchellh/status/1181721128340819970
<FromGitter> <Blacksmoke16> vs `oq`
<FromGitter> <tenebrousedge> well, someone with golang plastered all over their profile is probably a lost cause anyway
<FromGitter> <Blacksmoke16> i mean he apparently prefers that python yq versus the one written in go so there is still hope ;P
gangstacat has quit [Quit: ฤœis!]
<FromGitter> <ImAHopelessDev_gitlab> @tenebrousedge ROFL
gangstacat has joined #crystal-lang
dwdv_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
absolutejam4 has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> I mean, he is CTO/founder of HashiCorp
<FromGitter> <absolutejam_gitlab> which is like 99% Go
<FromGitter> <tenebrousedge> I forgive Hashicorp for their gobsession
<FromGitter> <absolutejam_gitlab> @Blacksmoke16 I know it was only the other day we discussed this
<FromGitter> <absolutejam_gitlab> but did you mention a way to make `YAML Serializable` decide on the target class based on a field value?
<FromGitter> <Blacksmoke16> yes, my shard will support it
<FromGitter> <Blacksmoke16> the key is to do all that after the data has been parsed, so then you have access to the key/values and stuff
<FromGitter> <absolutejam_gitlab> Still WIP?
<FromGitter> <Blacksmoke16> that part is yea, but if you want to try out whats there can use https://github.com/Blacksmoke16/CrSerializer/tree/refactor that branch
<FromGitter> <Blacksmoke16> can generate the docs locally as everything is documented there
<FromGitter> <Blacksmoke16> er actually it only supports JSON atm :girm
rohitpaulk has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
<FromGitter> <andrius> In your opinion, which web framework is better choice?
<FromGitter> <Blacksmoke16> depends what your goal is
<FromGitter> <absolutejam_gitlab> Amber looks like the answer to the likes of Django/Rails
<FromGitter> <absolutejam_gitlab> Lucky looks interesting though
ht_ has quit [Quit: ht_]
<FromGitter> <Blacksmoke16> i been rethinking how i picture Athena
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/athena/issues/34 is anyone has any additional thoughts
<FromGitter> <ilanpillemer> God of Athens? Queen of Wisdom?
<FromGitter> <ilanpillemer> Born from the forehead of Zeus?
<FromGitter> <Blacksmoke16> you got my reference :P is meant for JSON APIs so yea haha
<FromGitter> <ilanpillemer> I actually was at the British Museum looking at the Parthenon recently.
<FromGitter> <ilanpillemer> Is there such a think as a default method on a class instance?
<FromGitter> <tenebrousedge> probably not
<FromGitter> <tenebrousedge> can you elaborate?
<FromGitter> <ilanpillemer> trying to work out how to specify the signature for this
<FromGitter> <ilanpillemer> ``` output = React::ComputeCell.new(input) { |v| v + 1 }```
<FromGitter> <tenebrousedge> &block : Int32 -> Int32
<FromGitter> <Blacksmoke16> can prob just be `&`
<FromGitter> <Blacksmoke16> dont need `block` if its not captured?
<FromGitter> <tenebrousedge> the block needs to be captured, pretty sure
<FromGitter> <Blacksmoke16> unless you're using the variable `block` i dont think so
absolutejam4 has quit [Ping timeout: 240 seconds]
<FromGitter> <ilanpillemer> ```Error: no overload matches 'React::ComputeCell.new' with type React::InputCell```
<FromGitter> <tenebrousedge> yes, but I'm pretty sure it's required by the problem contstraints
<FromGitter> <ilanpillemer> so input is an `InputCell`
<FromGitter> <Blacksmoke16> whats the block do?
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9e4e1f49c7720aaf953a87]
<FromGitter> <tenebrousedge> it can also be a `ComputeCell`
<FromGitter> <Blacksmoke16> storing some execution to run later?
<FromGitter> <tenebrousedge> yes, it's a callback
<FromGitter> <Blacksmoke16> ah, then in that case it should be
<FromGitter> <ilanpillemer> hmm.. not trying to link to a solution
<FromGitter> <ilanpillemer> just to the exercise
<FromGitter> <tenebrousedge> the exercise definition isn't public
<FromGitter> <tenebrousedge> for some reason
<FromGitter> <ilanpillemer> "mplement a basic reactive system. โŽ โŽ Reactive programming is a programming paradigm that focuses on how values are computed in terms of each other to allow a change to one value to automatically propagate to other values, like in a spreadsheet. โŽ โŽ Implement a basic reactive system with cells with settable values ("input" cells) and cells with values computed in terms of other cells ("compute"
<FromGitter> ... cells). Implement updates so that when an input value is changed, values propagate to reach a new stable system state. ... [https://gitter.im/crystal-lang/crystal?at=5d9e4e6eb385bf2cc6a27d58]
<FromGitter> <tenebrousedge> the value returned by the cell is supposed to change when its dependencies change
<FromGitter> <ilanpillemer> I am just trying to work out the method signature.
<FromGitter> <ilanpillemer> so it takes one ore morel cell, and a lambda to apply to those cells and put into itself, the compute cell.
<FromGitter> <tenebrousedge> one or more cells, yes
<FromGitter> <ilanpillemer> and it needs to remember that lambda, so it can reapply
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7qxs so like that?
<FromGitter> <tenebrousedge> no, it can't store just the value
<FromGitter> <tenebrousedge> probably this is meant to emulate redux to some degree
<FromGitter> <ilanpillemer> it needs a name.. โŽ โŽ ``` def initialize(@cell : InputCell, &block : Int32 -> Int32)``` [https://gitter.im/crystal-lang/crystal?at=5d9e4fa6464b432fc1ec4b7c]
<FromGitter> <ilanpillemer> that at least passes...
<FromGitter> <tenebrousedge> until you get to this test (https://github.com/exercism/crystal/blob/master/exercises/react/spec/react_spec.cr#L42)
<FromGitter> <ilanpillemer> I know
<FromGitter> <ilanpillemer> so I guess it needs an Array?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7qy0
<FromGitter> <Blacksmoke16> so yea store the callback
<FromGitter> <ilanpillemer> yeah.. but I need one more cells, and one or more inputs
<FromGitter> <tenebrousedge> you can capture one or more arguments using `*@cells`
<FromGitter> <tenebrousedge> but that doesn't help you for the `Proc`
<FromGitter> <tenebrousedge> and you might think that you could solve this using generics
<FromGitter> <tenebrousedge> ```class ComputeCell(T) โŽ def initialize(*@cells, &@block : T -> Int32)``` โŽ โŽ But this does not work [https://gitter.im/crystal-lang/crystal?at=5d9e508a92920c36a13f3cec]
<FromGitter> <ilanpillemer> I think I need that drink now
<FromGitter> <tenebrousedge> ๐Ÿ˜
<FromGitter> <ilanpillemer> so how do you specify one or more Int32 for the input for the Proc?
<FromGitter> <Blacksmoke16> afaik you cant
<FromGitter> <ilanpillemer> seems to be a tuple
<FromGitter> <ilanpillemer> so maybe you could put int a tuple with default values
<FromGitter> <Blacksmoke16> you can convert a tuple to an array
<FromGitter> <tenebrousedge> tuples have a definite size
<FromGitter> <Blacksmoke16> nvm, the other way around
<FromGitter> <Blacksmoke16> a tuple from an array
<FromGitter> <tenebrousedge> I don't think that there's any way of avoiding overloading initialize
<FromGitter> <tenebrousedge> I'd like to be wrong about that
alex`` has quit [Quit: WeeChat 2.6]
<FromGitter> <Blacksmoke16> yea idt there is a way to set the type of a tuple to be n number of T
<FromGitter> <Blacksmoke16> er variable number of T
<FromGitter> <repromancer_gitlab> @ilanpillemer you could define a generic `NonEmptyArray(T)` and require a `NonEmptyArray(Int32)` as one of your arguments
<FromGitter> <repromancer_gitlab> or just an `Array(Int32)` argument type?
<FromGitter> <ilanpillemer> will that accept an Int32?
<FromGitter> <ilanpillemer> ```Array(Int32) -> Int32) โŽ end``` [https://gitter.im/crystal-lang/crystal?at=5d9e5286874aeb2d231a36ba]
<FromGitter> <ilanpillemer> nope
<FromGitter> <tenebrousedge> right
<FromGitter> <ilanpillemer> and if I do this..
<FromGitter> <repromancer_gitlab> sorry, I've probably missed something
<FromGitter> <ilanpillemer> ``` def initialize(*@cell : InputCell, &@callback : (Int32, Int32?) -> Int32)```
<FromGitter> <tenebrousedge> @repromancer_gitlab problem specs here (https://github.com/exercism/crystal/blob/master/exercises/react/spec/react_spec.cr#L42)
<FromGitter> <ilanpillemer> I get this..
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9e52e0464b432fc1ec609f]
<FromGitter> <Blacksmoke16> well yea, is possible the 2nd value in the tuple is nil
<FromGitter> <ilanpillemer> if its not passed, its a Nil
<FromGitter> <repromancer_gitlab> oh, I see, sorry, I thought this was a free-form implementation you were discussing XD
<FromGitter> <ilanpillemer> so how do you specify one or more Int32 as input for a Proc?
<FromGitter> <ilanpillemer> I am bamboozled.
<FromGitter> <Blacksmoke16> i dont think you can
<FromGitter> <Blacksmoke16> would have to accept an array
<FromGitter> <ilanpillemer> I assume someone has done this exercise, and its not a test on my sanity.
<FromGitter> <tenebrousedge> oh yes; they overloaded `initialize` generally
<FromGitter> <ilanpillemer> if so, it must be possible somehow.. maybe using some darker aspects of the language.
<FromGitter> <ilanpillemer> so I need to provide a new rather than use initialize?
<FromGitter> <ilanpillemer> and allocate memory and all?
<FromGitter> <ilanpillemer> or provide two initializes?
<FromGitter> <ilanpillemer> hmm
<FromGitter> <tenebrousedge> it is possible to do this in other situations : consider the `Enumerable` methods
masterdonx2 has quit [Ping timeout: 240 seconds]
<FromGitter> <tenebrousedge> they use generics
<FromGitter> <tenebrousedge> but I haven't found a way to make those work here
MasterdonX has joined #crystal-lang
<FromGitter> <tenebrousedge> so I have my *sauce espagnole* and another batch of beef stock. I'm not wild about the idea of making *demi glace* tonight, but it sounds better than working on this React problem
<FromGitter> <tenebrousedge> @ilanpillemer how's it coming?
<FromGitter> <ilanpillemer> I am about to stop for tonight
<FromGitter> <ilanpillemer> trying to work out if its possible using `Proc`
<FromGitter> <ilanpillemer> I have gone down a lot of dead ends
<FromGitter> <tenebrousedge> I think that if it is possible, it requires generics
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9e5c22874aeb2d231a7e2e]
<FromGitter> <tenebrousedge> but I'm not sure that's a thing here
<FromGitter> <ilanpillemer> this is my latest error
<FromGitter> <ilanpillemer> at least its a prettier error
<FromGitter> <tenebrousedge> yup, I tried that one too
<FromGitter> <ilanpillemer> I guess you cant make Int32 a tuple type
<FromGitter> <tenebrousedge> you can, but tuples are a fixed size
<FromGitter> <tenebrousedge> either `{Int32}` or `{Int32, Int32}`
<FromGitter> <ilanpillemer> it seems to fail for the Int32 then
<FromGitter> <ilanpillemer> but the splat works for InputCells
<FromGitter> <tenebrousedge> yes
<FromGitter> <ilanpillemer> so what is different between InputCells and Int32
<FromGitter> <tenebrousedge> one's in a proc signature
<FromGitter> <tenebrousedge> procs have to have defined arguments, at least at compile time
<FromGitter> <tenebrousedge> I wonder if you could do something heinous with `method_missing`
<FromGitter> <ilanpillemer> ok. gin time.
<FromGitter> <tenebrousedge> haha
<FromGitter> <tenebrousedge> it's a three-pipe problem
<FromGitter> <ilanpillemer> exercism lists it as `easy`.
<FromGitter> <tenebrousedge> their classification system is absurd and without reference to reality
<FromGitter> <tenebrousedge> but it's easier if you resign yourself to using two `initialize` methods
<FromGitter> <ilanpillemer> I tried to do that. It seemed to ignore one?
<FromGitter> <ilanpillemer> maybe I should go back to that
<FromGitter> <tenebrousedge> it should distinguish between the two based on the signature of the block
<FromGitter> <ilanpillemer> actually, youโ€™re right its a new error
<FromGitter> <tenebrousedge> yay new errors!
<FromGitter> <tenebrousedge> they're so much newer than the old errors
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9e5fe40459254672230e60]
<FromGitter> <ilanpillemer> this one now fails!
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9e5ff99735874673268c3c]
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9e60280e67130aae445d5a]
<FromGitter> <ilanpillemer> I now need to overload with ComputCells I guess
<FromGitter> <tenebrousedge> ```alias Cell = InputCell | ComputeCell โŽ def initialize(*args : Cell)``` [https://gitter.im/crystal-lang/crystal?at=5d9e60545173c33ca19a2743]
<FromGitter> <tenebrousedge> you may be able to just omit the type restriction, too
<FromGitter> <ilanpillemer> yay!
<FromGitter> <ilanpillemer> now getting nicer errors
<FromGitter> <ilanpillemer> ok. At least I now have my initialising working, and starting to feel the gin too.
<FromGitter> <ilanpillemer> what does exercism classify as hard?
<FromGitter> <tenebrousedge> I have no idea
<FromGitter> <ilanpillemer> Maybe the travelling saleman
<FromGitter> <tenebrousedge> it doesn't have any hard problems for the Crystal track
<FromGitter> <tenebrousedge> but `Forth` is also listed as easy
<FromGitter> <ilanpillemer> yes, I noticed. Forth is on the list for after React
<FromGitter> <tenebrousedge> which technically requires that you create a full programming language
<FromGitter> <ilanpillemer> yes, super easy
<FromGitter> <ilanpillemer> I always wanted to write a programming language easily
<FromGitter> <ilanpillemer> so I am glad it will be easy
<FromGitter> <tenebrousedge> there are easier and harder ways to approach it. I recommend a dual-mode interpreter rather than a two-pass interpreter
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 250 seconds]
alex`` has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> you can convert a tuple to array https://play.crystal-lang.org/#/r/7qyc
alex`` has quit [Quit: WeeChat 2.6]
<FromGitter> <nsuchy> @robacarp How would you recommend adding a container to docker-compose to run a worker script for mosquito?