<FromGitter>
<Blacksmoke16> so if you wanted to have a custom assertion you just inherit from the base, implement your two methods, and define the fields if any by making them ivars in your initializer
<FromGitter>
<Blacksmoke16> giving them defaults if they are optional fields on the annotation
<FromGitter>
<Blacksmoke16> not sure how to handle custom generic values yet tho (if its even possible)
<FromGitter>
<Blacksmoke16> `@message = message || error_message` a bit cleaner
_whitelogger has joined #crystal-lang
<FromGitter>
<tenebrousedge> @Blacksmoke16 how do you serialize procs though?
<FromGitter>
<Blacksmoke16> I'd be curious to see an example of it
alex`` has quit [Ping timeout: 248 seconds]
ht_ has joined #crystal-lang
<FromGitter>
<renich> I've created a yaml using the YAML.mapping macro. Is there a way to iterate over what I have? For exmaple: `my_yaml.each do |k, v|...`
ht_ has quit [Remote host closed the connection]
<FromGitter>
<absolutejam_gitlab> A
<FromGitter>
<absolutejam_gitlab> Sorry, fell
<FromGitter>
<absolutejam_gitlab> Asleep
<FromGitter>
<absolutejam_gitlab> @Blacksmoke16 I'm deserializing a yaml openapi spec then, as I parse the generated object tree, some of the objects can I include other objects properties
<FromGitter>
<absolutejam_gitlab> So I wanna be able to
<FromGitter>
<absolutejam_gitlab> Read properties from other classes essentially
<FromGitter>
<absolutejam_gitlab> As in type, name, etc
<FromGitter>
<renich> I have a yaml file created with mapping. On the other hand, I have all the keys of that yaml in an array. I want to use `keys.each do |k|...` and build a csv row like: `csv.row location, hostname, k, yaml.$k`. My problem is that last one. I dunno how to pass the value of `k` to `yaml.` in order for it to get the value of that key.
<FromGitter>
<renich> I want to dereference a variable and use it as the property name of `yaml`.
<FromGitter>
<absolutejam_gitlab> If you are spitting out the yaml, does that mean you have the original data structure?
<FromGitter>
<absolutejam_gitlab> So, could you store a k/v hash instead of just values?
<FromGitter>
<renich> @absolutejam_gitlab yes, I do. But I created a `keys` method on the YAML.mapping definition.
<FromGitter>
<renich> The thing is that I need to flatten in a special way a 3D array so it fits into a CSV (2D)
<FromGitter>
<renich> btw, the `keys` method returns an array of strings and hashes and arrays of hashes.
rohitpaulk has quit [Remote host closed the connection]
devil_tux has joined #crystal-lang
_whitelogger has joined #crystal-lang
devil_tux has quit [Ping timeout: 245 seconds]
devil_tux has joined #crystal-lang
<FromGitter>
<absolutejam_gitlab> tackling this another way
<FromGitter>
<absolutejam_gitlab> wait
<FromGitter>
<absolutejam_gitlab> nevermind.
<FromGitter>
<absolutejam_gitlab> Can I have a class that inherits from multiple parents?
<FromGitter>
<absolutejam_gitlab> I know with Modules you can `extend`/`require`
<FromGitter>
<rogerwelin_gitlab> Hi all! I'm dealing with json where I some fields are unknown. In the example below the "check google" and "check redis" are totally unknown. However the keys below it are known (Name & Status). ⏎ Ideally I want to use json mapping to return a known type but I don't know how to do that with unknown keys, is that possible? I could return JSON::Any, however I'm having a hard time grokking that one.
<FromGitter>
<rogerwelin_gitlab> @naqvis thanks, I've looked at that doc, but this example, you know the key of a, which I don't. I could leave everything unmapped, but the type A cannot be iterated either. must I add an enumerable for A then?
<FromGitter>
<absolutejam_gitlab> Or I think you could make that a Hash with known classes beneath
<FromGitter>
<tenebrousedge> @absolutejam_gitlab No, Crystal does not support multiple inheritance, except insofar as that can be accomplished by modules. But what do you need MI for that isn't adequately solved by modules?
<FromGitter>
<naqvis> @rogerwelin_gitlab `Unmapped` values are stored in `Hash`, so you could either provide any wrapper against that or you can simply work on that `Hash`
<FromGitter>
<absolutejam_gitlab> trying to whip up and example
<FromGitter>
<Blacksmoke16> let me catch up
<FromGitter>
<absolutejam_gitlab> actually, I think I may be wrong
<FromGitter>
<Blacksmoke16> would be like `.unmapped_values` or something
<FromGitter>
<Blacksmoke16> but prob easier to just define the type as a hash
<FromGitter>
<rogerwelin_gitlab> @Blacksmoke16 yeah, that would be ideal, however I don't quite how to achieve that when I don't know the name of the key
<FromGitter>
<Blacksmoke16> you dont have to know it
<FromGitter>
<absolutejam_gitlab> But obviously that won't work, derp
<FromGitter>
<naqvis> @rogerwelin_gitlab you can access unmapped keys via property `json_unmapped`
<FromGitter>
<naqvis> Macro will inject this key in your class
<FromGitter>
<rogerwelin_gitlab> @naqvis ah thanks, just found it in the docs :)
<FromGitter>
<naqvis> ywc
<FromGitter>
<rogerwelin_gitlab> @Blacksmoke16 awesome, exactly what I was after. much appreciated
<FromGitter>
<Blacksmoke16> np
devil_tux has joined #crystal-lang
lucasb has joined #crystal-lang
Jenz has joined #crystal-lang
* Jenz
o/
devil_tu1 has joined #crystal-lang
devil_tux has quit [Ping timeout: 248 seconds]
duane has joined #crystal-lang
<FromGitter>
<j8r> Crystal is unusable this days
<FromGitter>
<j8r> shards can't handle more than 8+ dependencies, aarch64 is broken
ht_ has joined #crystal-lang
<rkeene>
j8r, There's always Tcl ;-)
<FromGitter>
<j8r> lol
devil_tu1 has quit [Ping timeout: 248 seconds]
<rkeene>
Hmm ?
<FromGitter>
<kniknoo> Ok, I've read through the LLVM intro until I hit a wall in comprehension (Arduino is the closest I've come to C++). Then I read about Charley-Lang, so I read the source for it and it starts to get over my head too quick, and I read crystal/compiler macros, lexer, ast... maybe a few others... I can grok about 30% of it. I need to step it back to simple, yet using what crystal constructs there are. I am good
<FromGitter>
... with how a lexer needs to work, and that a parser needs to generate a series of AST nodes based on token patterns, and that an interpreter reads those nodes and responds with the related construct in the target output language. I'm so lost about the context of what all the built in AST nodes are and what all the macros are an ... [https://gitter.im/crystal-lang/crystal?at=5d5573604e17537f52381dc1]
<FromGitter>
<tenebrousedge> is there a specific problem you're trying to solve?
<FromGitter>
<tenebrousedge> would writing tests help?
<FromGitter>
<kniknoo> I'm trying to learn compiler/transpiler design at the most fundamental level via LLVM. Since crystal is an LLVM language, I presume that there are some helpers to simplify the process. Right now I understand it in theory and can generate a basic token. I'm trying to understand what it means in crystal to generate an Abstract Syntax Tree and then interpret that tree.
sagax has quit [Remote host closed the connection]
<FromGitter>
<tenebrousedge> you've been looking at the Crystal tests that generate the LLVM-IR ?
<FromGitter>
<kniknoo> Ah, good point. I'm still new to other people's code so I've yet to learn that tests are where the real docs reside, as you've suggested before. I'll jump in there. It's just constructed for such a high level language and I want to start with a language that can recognize "def" -> "end" as a "subroutine", recognize integer variables, and run math equations. I'd start by showing how to do that much in crystal
<FromGitter>
... and send it to LLVM.
<FromGitter>
<tenebrousedge> sounds LISPy
<FromGitter>
<kniknoo> Perhaps. Goal is to be able to generate a toy language piece by piece. I have steps to learn in mind more than an end goal purpose.
<FromGitter>
<tenebrousedge> you're aware of "NAND to Tetris", yeah?
<FromGitter>
<kniknoo> Yes. Just finished up to the Assembler a couple days ago. Now I must purchase the book to continue or try to dive head first into something related, the latter of which I've been trying.
<FromGitter>
<kniknoo> Concrete goal is a VM that emulates a TIS-100 node network. I have a virtual ALU and ASM parser spec in mind for it, but I need to learn how to build the VM, which will require some of this knowledge.
<FromGitter>
<tenebrousedge> well it sounds like you're on the right track
<FromGitter>
<kniknoo> Thanks! I can't wait to put some newfound understanding of how declarative HDL works toward designing some things on my FPGA. It was way over my head when someone gave it to me, I could get a basic hello world.
<FromGitter>
<kniknoo> Ok, I see now. I was being too literal about LLVM's terms on their tutorial. Codegen is what I'm missing looking at.
devil_tux has joined #crystal-lang
<FromGitter>
<kniknoo> ...or I hadn't read ahead.
<FromGitter>
<tenebrousedge> o.o
<FromGitter>
<kniknoo> I'm just so lost by what's going on in their parser example.
<FromGitter>
<kniknoo> It makes more sense by codegen, but I'm at a point where I basically understand an AST as a list of hashes.
devil_tux has quit [Ping timeout: 248 seconds]
<FromGitter>
<kniknoo> Oh FFS. I think it's being a burnout that's the problem. I just reviewed chap2 and somehow I got onto the full code listing page...
<FromGitter>
<asterite> @kniknoo you should probably read the kaleidoscope tutorial for llvm, it'll be much simpler
<FromGitter>
<asterite> also, cool that you are emulating TIS-100! (I just played a couple of levels but plan to continue playing if I have time)
<FromGitter>
<kniknoo> That's what I'm reading. But NOW, I realize that it's confusingly both in c++ and Ocaml. I don't know either, but the differences between them are helping me to figure out what's c++ boilerplate and what's necessary.
<FromGitter>
<kniknoo> I love Zachtronics! I want to do up this wild re-implementation of TIS, and I also have some ideas in mind for an exapunks inspired game that uses cards with assembly control flow and bitwise operations to create a dynamic gameboard for a version of their hacker battles.
<FromGitter>
<kniknoo> But I love the simplicity of the languages so much that I actually want to try writing some generic assemblers for them as a means of mapping an inline ASM spec for micro-operations.
<FromGitter>
<j8r> mps I run git bisect
<mps_>
j8r: did you found something which could be of the help
<FromGitter>
<asterite> Just pass SPEC_SPLIT=0%4 to run every spec modulo 4 == 0, and so on
<mps_>
aha, thanks
<FromGitter>
<j8r> good to know yes
<FromGitter>
<j8r> anyway I'm on 0.29, the only thing I can do is zwap
<mps_>
I've built 0.27 and 0.28 with 4GB RAM and zswap but suspect I could do that for 0.29 and 0.30
rohitpaulk has joined #crystal-lang
fyber has joined #crystal-lang
Jenz has quit [Ping timeout: 258 seconds]
lvmbdv has quit [Ping timeout: 248 seconds]
lvmbdv has joined #crystal-lang
devil_tux has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
lvmbdv has quit [Ping timeout: 248 seconds]
lvmbdv has joined #crystal-lang
devil_tux has quit [Ping timeout: 272 seconds]
alex`` has quit [Ping timeout: 244 seconds]
alex`` has joined #crystal-lang
MasterdonX has quit [Read error: Connection reset by peer]
<FromGitter>
<renich> @Blacksmoke16 thanks! I'll try it in a little while.
salival01 has left #crystal-lang [#crystal-lang]
<FromGitter>
<j8r> mps I was able to compile specs with LLVM5
<FromGitter>
<j8r> but I was using crystal 0.29 :/
<FromGitter>
<j8r> forget it, I try with 0.30
<mps_>
we have 0.29 on aarch64 in v3.10 alpine release, it is built llvm5
fyber has quit [Remote host closed the connection]
<FromGitter>
<j8r> The bisect will be long, because I will need to compile Crystal then all specs, on Qemu :/
ht_ has quit [Remote host closed the connection]
MasterdonX has joined #crystal-lang
sagax has quit [Remote host closed the connection]
duane has quit [Ping timeout: 245 seconds]
<FromGitter>
<asterite> 1) 30.0 can't work with LLVM >= 6 compiled with assertions (maybe it even fails without them). You have to use 0.30.1 (in case it helps)
<mps_>
just received PRIVMSG but looks like my trigger in irssi failed to reformat it correctly
<mps_>
anyone sent msg to me?
<rkeene>
Nobody loves you
<mps_>
hehe, and especially my script to make gitgutter gateway acceptable in irssi ;-)
<FromGitter>
<sam0x17> if I'm getting "cannot convert from `SomeType` to `SomeOtherType`" errors, is there some drop-in method I can create that will make crystal know how to convert from `SomeType` to `SomeOtherType`, or am I out of luck?
<FromGitter>
<watzon> @sam0x17 depends on the situation, but generally you're out of luck
<FromGitter>
<sam0x17> whats the situation where it depends? lol
<FromGitter>
<watzon> It depends on what types you're trying to convert. There are lots of situations where you'd think it should work, but it doesn't
<FromGitter>
<watzon> Apparently the compiler isn't smart enough for that yet
<FromGitter>
<sam0x17> Array(Int64) to and from Array(String)
<FromGitter>
<watzon> Yeah you can't do that, for whatever reason. The only way to do that would be to use `map`. So `arr.map!(&.to_s)` should work.
<FromGitter>
<sam0x17> some idiot at my work defined this db column as a postgres string array when its an array of ids, so this orm (correctly) doesnt let me trick it into letting me
<FromGitter>
<sam0x17> so I'll just have to keep using strings :/
<FromGitter>
<watzon> You can do the conversion using `map`. It shouldn't have much of a performance impact, if any ⏎ The only place where you'll run into trouble is if the value isn't a valid int
<FromGitter>
<sam0x17> yeah no thats what I was trying to do clear orm doesn't let me basically because it checks the types before it runs the conversion code
<FromGitter>
<Blacksmoke16> what orm @sam0x17 ?
<FromGitter>
<Blacksmoke16> can you not define a converter?
<FromGitter>
<sam0x17> for some reason the postgres array types are all janked with those
<FromGitter>
<sam0x17> like its trying to use `Array(PG::StringArray)`
<FromGitter>
<tenebrousedge> so you can't change `collaborator_ids: Array(Int32)` ?
<FromGitter>
<sam0x17> which I thought should just be `PG::StringArray` (which I also dont know how to instantiate)
<FromGitter>
<sam0x17> you get sql errors if you do that
<FromGitter>
<sam0x17> so I tried writing a converter for Array(Int64) <=> Array(String) but Array(String) is also a magically supported type that isn't in the valid types list
<FromGitter>
<tenebrousedge> can you change the schema?
<FromGitter>
<tenebrousedge> (sorry if I'm asking stupid questions)
<FromGitter>
<sam0x17> no thats the best solution obviously
<FromGitter>
<sam0x17> I really dont want to lets put it that way
<FromGitter>
<sam0x17> would be a massive migration
<FromGitter>
<sam0x17> this is a 5 year old table from a large rails app
<FromGitter>
<sam0x17> right now the easiest solution is to just use custom getters and setters that have a different name on the model
<FromGitter>
<Blacksmoke16> rip
<FromGitter>
<sam0x17> so yeah, you feel my pain lol
<FromGitter>
<sam0x17> would `PG::StringArray` in theory be coming from the `pg` shard?
<FromGitter>
<sam0x17> `Array(PG::StringArray)` seems to be how it represents postgres string arrays when talking to postgres, but its like its abusing the syntax for some reason because its really an array of arrays I think
<FromGitter>
<watzon> @sam0x17 you should try searching your lib directory for `StringArray` and see if you can find it
<FromGitter>
<j8r> @asterite Thanks. I use LLVM 5 to avoid this type of issues
<FromGitter>
<sam0x17> so what is it really then?
<FromGitter>
<Blacksmoke16> a union of String and Array(String)
<FromGitter>
<sam0x17> ah
<FromGitter>
<sam0x17> that I could probably disect
<FromGitter>
<sam0x17> so since its `Array(PG::StringArray)` its really a `Array(String | Array(String))`?
<FromGitter>
<tenebrousedge> seems so
<FromGitter>
<sam0x17> any ideas why its being nested in an outer array lol?
<FromGitter>
<sam0x17> my initial thought was that there is some syntactical abuse going on somewhere that makes that convenient
<FromGitter>
<tenebrousedge> could be that there are methods that only return one result?
<FromGitter>
<sam0x17> so I should just assume the outer array always has 0 or 1 elements I'm thinking
<FromGitter>
<tenebrousedge> why not just flatten it and then convert whatever you have?
<FromGitter>
<j8r> like a Tuple
<FromGitter>
<j8r> nvm, depends of what elements they are
<FromGitter>
<sam0x17> I have I think the first part of the converter working, however my assumption that `Array(PG::StringArray) == Array(String | Array(String))` seems not to be working: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d55ddc4a4efe3718d0cbce5]
<FromGitter>
<Blacksmoke16> or something like that
<FromGitter>
<sam0x17> aha ok
<FromGitter>
<sam0x17> `Error: can't cast Array(String) to PG::StringArray`
<FromGitter>
<Blacksmoke16> so try like
<FromGitter>
<sam0x17> now I now longer feel bad for giving up on this last night xD
<FromGitter>
<sam0x17> is there some introspection I can use to get crystal to tell me what PG::StringArray is in great detail, because I'm starting to think its not what we think it is