<FromGitter>
<HertzDevil> if you can't do `@data : Tensor` without the type vars (you can't with `Array`) i don't think the hash is gonna work that way
<jhass>
f1refly: #compact :)
<jhass>
your code would work if you'd return a new array (reject instead of reject!), compact is a shortcut to this
<f1refly>
Yeah, makes sense. I'll do that
<f1refly>
Looks very neat, too :)
<FromGitter>
<j8r> How can I can TypeNode to NamedTupleLiteral, I tried `if Options < NamedTuple`
<FromGitter>
<Blacksmoke16> hm?
<jhass>
I think you accidentally a word
<FromGitter>
<j8r> *cast
<FromGitter>
<j8r> can => cast 😅
<FromGitter>
<Blacksmoke16> got some example code/
<FromGitter>
<Blacksmoke16> can you make a playground link?
<raz>
being as specific/explicit with types as possible is something i had to learn coming with ruby. it felt cumbersome at first in some places (and in some it legit *is* cumbersome). but the end-result is usually very much worth it - stuff clicks into place instead of dangling around
<raz>
coming from*
<raz>
it takes some unlearning to kick that ol' "just throw it in a hash" habit from ruby tho
<FromGitter>
<Dan-Do> > can you make a playground link? ⏎ ⏎ nope, it's really big. I want to render a web page with data
<FromGitter>
<Blacksmoke16> and you're using a hash of params?
<FromGitter>
<Dan-Do> The thing is data comes from anywhere: db, user input, function...
<raz>
can you normalize it somewhere on the way? (e.g. wrap it in a class)
<FromGitter>
<Blacksmoke16> arent there shards to help with this kinda stuff?
<FromGitter>
<Blacksmoke16> but the problem you're running into i think is `Proc`s are not as liberal with how they handle types
<FromGitter>
<Blacksmoke16> i.e. they have to be exact iirc
<FromGitter>
<Blacksmoke16> like you could have the proc type be like `Proc(String, SomeWrapperType, Nil)`
<FromGitter>
<Blacksmoke16> where that wrapper type is something like raz suggested, that can contain arbitrary data
<FromGitter>
<Dan-Do> The Proc is used to "transform" data from Hash(String, *) -> Hash(String, String)
<FromGitter>
<Blacksmoke16> does it have to be a proc? isnt that just like `hash.transform_values &.to_s`?
<FromGitter>
<Blacksmoke16> plus crystal handles doing that when interloping strings and stuff so might not even need to worry about it in the first place
<FromGitter>
<Blacksmoke16> im sure theres an alternate/better approach here. However without knowing the context/end goals cant help *that* much
<raz>
i think i would rather discuss the reasoning behind that requirement (and have it dropped) than spend ~50% of my development resources on trying to make everything work without js
<FromGitter>
<Dan-Do> I used browser without js 80% and I can stand with it.
<FromGitter>
<Dan-Do> No advertisement :)
<raz>
hm ok, everyone chooses their own battles :D
<FromGitter>
<Blacksmoke16> just install and adblock and call it a day
<FromGitter>
<Dan-Do> :D
<raz>
the 0.2% can't install adblock because that's js, too :p
teardown has quit [Quit: leaving]
<FromGitter>
<naqvis> naah, ddd project is targeting users like ddd , so even if js disabled, server will continue render the advertisement :P
<raz>
and i'd bet a large portion of those 0.2% was just measured wrong because some advanced adblocker stripped the test-js :P
<jhass>
I never tried but I bet libreJS is the best adblocker out there actually
<raz>
i'm happy with ublock. don't remember when i last saw an ad
<FromGitter>
<Blacksmoke16> circling back, i still dont see why its an issue that your front end framework doesnt use jinja?
<FromGitter>
<Blacksmoke16> you're rendering HTML on the server, it shouldnt matter what the front end is at that point as you're getting back the full HTML page no?
<FromGitter>
<Dan-Do> If js is enable, SPA framework works as normal :)
<FromGitter>
<Blacksmoke16> so?
<FromGitter>
<Dan-Do> jinja is not SPA framework :(
<FromGitter>
<Blacksmoke16> right?
<FromGitter>
<Blacksmoke16> i dont see the problem here
<FromGitter>
<Blacksmoke16> or are you like using the same html for both spa and non spa context?
<FromGitter>
<Dan-Do> yeap, that's what I want
<FromGitter>
<Blacksmoke16> so you have an SPA being powered via server rendered HTML?
<FromGitter>
<Dan-Do> correct
<raz>
perhaps something like unpoly (which is awesome btw)
<FromGitter>
<Blacksmoke16> how does that work?
<raz>
unpoly.com
<FromGitter>
<Blacksmoke16> like normally the SPA handles rendering its own templates
<FromGitter>
<Blacksmoke16> and if you have to do a request to the server to get them doesnt that defeat the purpose/intent of the SPA in the first place?
<raz>
it only has to do the req the first time, then it's cached
<FromGitter>
<Dan-Do> true :)
<FromGitter>
<Blacksmoke16> sure, but then how does the SPA do anything after that? i.e what if you click a button to add another todo
<FromGitter>
<Blacksmoke16> would have to do another request, or does the initial server rendered html include the markup for the spa?
<FromGitter>
<Dan-Do> on my design, the server will detect then just return json if the request comes from spa
<raz>
did you build the client-side framework, too, or using something existing?
<FromGitter>
<Blacksmoke16> i guess im still just missing the piece of why you cant use like crinja to handle the rendering of the html in the non spa context
<FromGitter>
<Dan-Do> I am trying mikado and sinuous :)
<FromGitter>
<Dan-Do> lol
<FromGitter>
<Dan-Do> > or are you like using the same html for both spa and non spa context? ⏎ ⏎ > i guess im still just missing the piece of why you cant use like crinja to handle the rendering of the html in the non spa context ⏎ ⏎ because of this [https://gitter.im/crystal-lang/crystal?at=5f98514b955f6d78a956de81]
<FromGitter>
<Blacksmoke16> i.e. your custom renderer is made to support both
<FromGitter>
<Dan-Do> yes
<FromGitter>
<Blacksmoke16> 👍
<raz>
but then don't you have to build all templates twice? (once in js, once on server)
<FromGitter>
<Blacksmoke16> i think hes saying he made a custom renderer that uses the same syntax as the front end one
<raz>
ohhh
<FromGitter>
<Dan-Do> No, just one. the client framework has higer priority, so the server side must adapt to
<FromGitter>
<Blacksmoke16> so they can both use the same tempalte
<raz>
sounds like he's inventing a full blown meteor/hyperstack there
<raz>
in fact, the hyperstack guys have voiced interest in porting it to crystal
<FromGitter>
<Dan-Do> > i think hes saying he made a custom renderer that uses the same syntax as the front end one ⏎ > so they can both use the same tempalte ⏎ yes, that's the point
<raz>
would love to see that. but it's a ginormous undertaking...
<raz>
well, same template is half of the story. but what about variable references, etc
* raz
scratches head
<FromGitter>
<Blacksmoke16> regardless in that case i think you're going need to use a slightly diff approach for your proc
<FromGitter>
<Blacksmoke16> or does it need to be a proc?
<FromGitter>
<Blacksmoke16> that kinda stuff
<FromGitter>
<Dan-Do> The renderer engine must adapt to the template, user can change/modify template, so I used proc to let dev write the "transform" part themselve
<FromGitter>
<Blacksmoke16> got an example of what that looks like?
<FromGitter>
<Blacksmoke16> like i could also see that just being a class with some method on it versus an actual proc
<FromGitter>
<Blacksmoke16> or something along those lines
<FromGitter>
<RespiteSage> Are you trying to call the method `Helpers#name` when you pass in `{name: "foo"}`?
teardown has quit [Quit: leaving]
<FromGitter>
<lebogan> I'm trying to use the key as the method name.
<FromGitter>
<lebogan> I want to process the NamedTuple info one key/value at a time. If I call .name on process_helpers(info[:name]) it works, but it seems clumbsy if I have a larger amount of items.
<FromGitter>
<j8r> @lebogan you can use macros, `{{ @type.instance_vars }}` to generate a case/when
<FromGitter>
<j8r> where comes the `info` namedtuple?
<FromGitter>
<j8r> is it really wanted to create a new helper on each iteration?
gangstacat has quit [Ping timeout: 272 seconds]
<FromGitter>
<lebogan> My use case is a snmp-get operation where I process a unique oid at a time. I'm really attempting to build a parser, I think. I admit my macro knowledge is lacking.
Andriamanitra has quit [*.net *.split]
<FromGitter>
<Blacksmoke16> you'd have to do something like what @j8r said
<FromGitter>
<Blacksmoke16> like an `.invoke(name : String)` that case a case on the `name` based on ivar names and returns/calls the related method
<FromGitter>
<Blacksmoke16> but id sit back and think if theres not a better way
<FromGitter>
<Blacksmoke16> like more specialized types
<FromGitter>
<RespiteSage> A note: the case in my example accepts either a string or a symbol, and it took me a long time to realize it wasn't working with just string because the named tuple key is a symbol.
<FromGitter>
<RespiteSage> I agree. This works, but it's probably not an ideal long-term solution.
teardown has joined #crystal-lang
<FromGitter>
<lebogan> @RespiteSage , I tried your example but no output. I need to work on this some more. Thanks also @Blacksmoke16
<FromGitter>
<Blacksmoke16> i mean theres deff output, i see it on the side
<FromGitter>
<lebogan> My copy/paste noob mistake :(
teardown_ has joined #crystal-lang
teardown_ has quit [Client Quit]
teardown has quit [Quit: leaving]
teardown has joined #crystal-lang
teardown has quit [Client Quit]
teardown has joined #crystal-lang
teardown has quit [Client Quit]
teardown has joined #crystal-lang
teardown has quit [Quit: leaving]
teardown has joined #crystal-lang
teardown has quit [Client Quit]
teardown has joined #crystal-lang
gangstacat has joined #crystal-lang
teardown has quit [Ping timeout: 240 seconds]
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
yukai has joined #crystal-lang
<oprypin>
is there any way to explicitly instantiate a type `Generic(*T)` with an empty tuple of types? `Generic().new` is a syntax error
<FromGitter>
<Blacksmoke16> type of tuple.new
<oprypin>
u mean `Generic(*typeof(Tuple.new)).new` ? that does work, thanks
<oprypin>
hm anything less jarring? i'm intending this for the end user, who can make use of such an instantiation, among others
<FromGitter>
<Blacksmoke16> Generic.empty
<FromGitter>
<Blacksmoke16> Abstract it behind that class method