<FromGitter>
<Blacksmoke16> would have to use shards override i think, or just use whichever you already have a dep on
<FromGitter>
<moe:busyloop.net> hmm i can rename one with shards override?
<FromGitter>
<moe:busyloop.net> was gonna fork
<FromGitter>
<moe:busyloop.net> the j8r one is in my shard.yml, the other one is a dep of some shard i use (don't even know which)
<FromGitter>
<Blacksmoke16> i never remember if override can fix this or not
<FromGitter>
<Blacksmoke16> but its unfortunate because they share the same namespace too, so id just use the one thats a dep
<FromGitter>
<moe:busyloop.net> meh yea, the classes clash
<FromGitter>
<moe:busyloop.net> gonna fork j8r
<FromGitter>
<Blacksmoke16> hows that going to help?
<FromGitter>
<moe:busyloop.net> then i can rename it to BetterPool
<FromGitter>
<Blacksmoke16> hehe fair enough :P
<FromGitter>
<jrei:matrix.org> That's a pros and cons of Crystal: no "import x as Y"
* FromGitter
* Blacksmoke16 still would love ES6 import system instead of global requires
<FromGitter>
<moe:busyloop.net> j8r (https://matrix.to/#/@jrei:matrix.org): i don't think you'll call it a pro anymore after you've renamed your shard :P
* FromGitter
* moe:busyloop.net was just about to write a github isue
<FromGitter>
<jrei:matrix.org> The advantage is simplicity, for little apps at least
<FromGitter>
<moe:busyloop.net> yea it's probably not a big deal in general. but means generic names really need to be avoided for competing impls. at least one popular shard (redis) depends on the other pool. that makes yours a tough choice under the current name.
<FromGitter>
<jrei:matrix.org> I don't think so
<FromGitter>
<jrei:matrix.org> If one forks a library, and a dep use the older version, a clash will happen too
<FromGitter>
<jrei:matrix.org> For me, ideally we should name however we think fits best
<FromGitter>
<jrei:matrix.org> IMO a library should be one namespace (i.e. class/module), which can then be eventually changed somehow through the language (import as) or even in shard.yml
<FromGitter>
<Blacksmoke16> also could help to group shards by author
<FromGitter>
<Blacksmoke16> `j8r/pool` and `ysbaddaden/pool` instead of just `pool/`
<FromGitter>
<moe:busyloop.net> yup. atm the `pool:` name in the yml doesn't seem to have any effect. if i change it i just get: `Error shard name (pool) doesn't match dependency name (j8r_pool)`
<FromGitter>
<Blacksmoke16> that has to match the `name` property within `shard.yml`
<FromGitter>
<moe:busyloop.net> if that name could be used to convince shards to store it in a different folder. and then crystal would let me import like above. and also magically wrap the class as `J8r::Pool`...
<FromGitter>
<jrei:matrix.org> Another option is to use git submodules or subtree, and then modify the name
<FromGitter>
<jrei:matrix.org> Even J8r::Pool one could have the same name in gitlab and have a pool library (or a fork of mine) 😁
<FromGitter>
<jrei:matrix.org> It should be user-modifiable
<FromGitter>
<jrei:matrix.org> Or my name could be Array or Hash - then it may not compile or mess with the API docs
<FromGitter>
<jrei:matrix.org> Sounds more and more like Java's
<FromGitter>
<moe:busyloop.net> well, your shard will sound like java anyway, as you have to rename to JPool until this is fixed :p
<FromGitter>
<moe:busyloop.net> i'll just fork for now, but i'm probably not the last to bump into this :/
<FromGitter>
<jrei:matrix.org> If I where you I'd use git subtree
<FromGitter>
<Blacksmoke16> still not going to solve it, as part of the problem is the class name itself conflicts
<FromGitter>
<jrei:matrix.org> And commit to change the name
<FromGitter>
<jrei:matrix.org> Maybe another option is to have a post install that sed the name, lol?
<FromGitter>
<moe:busyloop.net> yea... why not replace a small pain with an ongoing agony
<FromGitter>
<moe:busyloop.net> i've just decided i won't even fork but just copy paste into my src/ ;)
<FromGitter>
<jrei:matrix.org> That's good too
<FromGitter>
<jrei:matrix.org> In fact this lib is so small, it can be vendored
<FromGitter>
<jrei:matrix.org> Unlikely to change also
<FromGitter>
<moe:busyloop.net> yeh but it's still sad nobody can easily use it. it's better then the other impl.
<FromGitter>
<Blacksmoke16> to be clear, its only an issue because another shard you have is using the same name
<FromGitter>
<jrei:matrix.org> Then maybe make the dependency you use use my Pool haha
<FromGitter>
<Blacksmoke16> if you install only his pool shard, it would be fine
<FromGitter>
<Blacksmoke16> or figure out what dep uses the other and make a PR to switch out the implementation
<FromGitter>
<moe:busyloop.net> right, but i wouldn't be surprised if many people who'd be interested in his shard will be in the same boat with me of having conflicting shards in their deps
<FromGitter>
<moe:busyloop.net> i already figured it out, it's `redis` shard
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<moe:busyloop.net> but i'm not looking to start a shards-war, i think one of them should just rename until the problem can be addressed in shards itself ;)
ur5us has joined #crystal-lang
notzmv has joined #crystal-lang
miketheman has joined #crystal-lang
<miketheman>
👋
<miketheman>
Been thinking about JSON::Any recently, and was trying to find some modern examples of how to implement a deconstruction of a JSON input (file, string, etc) to explicit types, when the structure is unpredictable/unknown (otherwise Serializable might work, I think) - all in the name of building up an AST for a parser/lexer to handle.
<miketheman>
It's probably some combination of a JSON::PullParser, but I can't seem to find any good examples.
<miketheman>
If anyone has some pointers for me to read, would much appreciate it!
<FromGitter>
<Blacksmoke16> if the structure is unknown then you kinda have to use `JSON::Any`
<FromGitter>
<Blacksmoke16> even if you use a pull parser to know that the current value is a integer, you dont really have a good way to store all the parsed data in, which is where `JSON::Any` comes into play
<miketheman>
Thanks - that's helpful! Don't know why I didn't find this thread earlier.
<miketheman>
I guess even having a parser that can take a `JSON::Any` and do something `if unknown_input.as_a do visit(unknown_input.as_a) end` (pseudo code), then I could test the input for each type I'm looking to support, and write a bunch of `visit(some_input : <type>)` overloads - would that work? I haven't seen anything like that yet.
ur5us has quit [Ping timeout: 256 seconds]
ur5us has joined #crystal-lang
<FromGitter>
<Blacksmoke16> Hmm
<FromGitter>
<Blacksmoke16> Might be able to just do like data.raw
<FromGitter>
<Blacksmoke16> Which returns the raw value, which I'm pretty sure your overloads could take it from there