« Back to channel list

#elixir-lang - 03 May 2019

« Back 1 day Forward 1 day »
[00:03:58] orbyt_: has joined #elixir-lang
[00:04:46] Sgeo_: has joined #elixir-lang
[00:07:39] gvaughn_: has joined #elixir-lang
[00:14:30] thomasross: has joined #elixir-lang
[00:16:50] thomasross: has joined #elixir-lang
[00:22:48] NightMonkey: has joined #elixir-lang
[00:30:28] gvaughn: has joined #elixir-lang
[00:31:13] also_uplime: has joined #elixir-lang
[00:32:46] hypercore: how should i update state in a form using live view? e.g. if i mount a map %{key1: ..., key2: ..., etc}, how do i update a particular key if the key isn't a schema field? (e.g. an intermediary value)
[00:33:08] jeffro_: has joined #elixir-lang
[00:34:40] sparogy: has joined #elixir-lang
[00:37:29] Havvy: has joined #elixir-lang
[00:45:43] greengriminal: has joined #elixir-lang
[01:03:22] mdbm_: has joined #elixir-lang
[01:06:28] carldd: has joined #elixir-lang
[01:29:22] pera: has joined #elixir-lang
[01:36:17] thomasross: has joined #elixir-lang
[01:52:36] orbyt_: has joined #elixir-lang
[01:59:45] tomterl: has joined #elixir-lang
[01:59:59] acscherp: has joined #elixir-lang
[02:21:47] mdbm__: has joined #elixir-lang
[02:25:18] ariedler: has joined #elixir-lang
[02:36:14] mdbm__: has joined #elixir-lang
[02:37:17] infowolfe: has joined #elixir-lang
[03:04:20] sparogy: has joined #elixir-lang
[03:11:12] mdbm_: has joined #elixir-lang
[03:11:56] iamvery: has joined #elixir-lang
[03:14:31] Saukk: has joined #elixir-lang
[03:19:06] ur5us_: has joined #elixir-lang
[03:19:31] robramsaynz: has joined #elixir-lang
[03:19:50] ur5us: has joined #elixir-lang
[03:20:52] carldd: has joined #elixir-lang
[03:30:27] alex88: has joined #elixir-lang
[03:30:45] __charly__: has joined #elixir-lang
[03:41:46] alex88: has joined #elixir-lang
[03:42:25] pera: has joined #elixir-lang
[03:50:45] notzmv: has joined #elixir-lang
[04:10:50] lauromoura_: has joined #elixir-lang
[04:18:07] orbyt_: has joined #elixir-lang
[04:26:40] ariedler: has joined #elixir-lang
[04:55:17] lauromoura__: has joined #elixir-lang
[05:02:01] orbyt_: has joined #elixir-lang
[05:07:56] serafeim: has joined #elixir-lang
[05:09:38] serafeim: good morning
[05:18:56] iamvery: has joined #elixir-lang
[05:19:43] qqwy: has joined #elixir-lang
[05:25:13] voltone: has joined #elixir-lang
[05:32:02] ur5us_: has joined #elixir-lang
[05:32:50] ur5us_: has joined #elixir-lang
[05:34:30] sparogy: has joined #elixir-lang
[05:35:53] gvaughn: has joined #elixir-lang
[05:40:09] serafeim: I've implemented a simple module for checking greek tax numbers. I'd be grateful if a person more experienced in Elixir than me could take a look at it and tell me if it is idiomatic enough or I should change some things: https://github.com/spapas/validate_greek_tax_number/blob/master/lib/validate_gr_tax_num.ex
[05:40:15] serafeim: PRs of course are welcome !
[05:48:36] Liru: Serafeim: The try/rescue in there seems rather unidiomatic
[05:48:44] Liru: Hold on, working on something
[05:49:51] __charly__: has joined #elixir-lang
[05:49:53] serafeim: liru I wanted to convert the digits to integers but if there are non-digits there (letters etc) to return the empty list so as to fail the check
[05:55:11] Liru: Yeah, I understand the intent, but it's done in an ugly way. Another thing you could've done is split it and filter for non-numbers
[05:55:23] Liru: I'm working on a third way, which I think is neater, though
[05:56:27] serafeim: all right i'd like to see it :)
[05:56:28] qqwy: has joined #elixir-lang
[05:56:46] wsieroci: has joined #elixir-lang
[06:00:07] voltone: has joined #elixir-lang
[06:03:59] Liru: Aw, the checksum kind of ruined the elegance of it
[06:04:02] Liru: But it's still good
[06:04:06] Liru: ACTION continues
[06:07:12] Sgeo_: has joined #elixir-lang
[06:07:22] jnoon2: has joined #elixir-lang
[06:07:33] craigp: has joined #elixir-lang
[06:08:16] BitBot: has joined #elixir-lang
[06:15:23] voltone: has joined #elixir-lang
[06:27:34] ariedler: has joined #elixir-lang
[06:31:40] gde33: has joined #elixir-lang
[06:35:31] harfangk: has joined #elixir-lang
[06:40:26] gvaughn: has joined #elixir-lang
[06:50:34] serafeim: would you recommend Rummage or Scrivener for phoenix ecto pagnation for a traditional (HTML only) web app ?
[06:50:52] serafeim: does anybody have experience with these projects ? they don't seem that much popular :/
[07:00:01] PragTob: has joined #elixir-lang
[07:03:40] squall: has joined #elixir-lang
[07:07:31] Liru: Serafeim: https://gist.github.com/Liru/c06b44a9d30fa378fec9a6427d9bbfa2
[07:08:26] Liru: A lot messier than I intended, but it's 3am
[07:08:33] Liru: that's my excuse and I'm sticking to it
[07:10:19] Liru: also, scrivener is probably the more well known option
[07:11:07] serafeim: liru thanks! I'll take a look at it right now
[07:14:34] Liru: you'll need to add a {:nimble_parsec, "~> 0.5"}
[07:14:43] Liru: to your mix.exs dependencies
[07:15:28] jmiven: has joined #elixir-lang
[07:15:45] Liru: for a simple example, it's way overkill, but you have more proper parsing
[07:16:09] Liru: instead of removing any spaces and dashes and erroring out if there's an integer, you guarantee that the tax number is in a certain form
[07:16:17] Liru: er, if there isn't an integer
[07:16:47] Liru: as well as a bunch of other benefits
[07:18:46] Liru: even this can be improved
[07:18:55] Liru: may do so if I feel like it when I wake up
[07:22:09] proteusguy: has joined #elixir-lang
[07:47:00] proteusguy: has joined #elixir-lang
[07:51:00] proteusguy: has joined #elixir-lang
[07:52:58] gvaughn: has joined #elixir-lang
[07:56:44] Sgeo_: has joined #elixir-lang
[07:58:15] lexmag: has joined #elixir-lang
[08:02:35] asabil: has joined #elixir-lang
[08:04:40] sparogy: has joined #elixir-lang
[08:16:32] mdbm: has joined #elixir-lang
[08:17:18] qqwy: has joined #elixir-lang
[08:18:44] Guest42: has joined #elixir-lang
[08:21:11] optikfluffel: has joined #elixir-lang
[08:27:38] gvaughn: has joined #elixir-lang
[08:28:10] ariedler: has joined #elixir-lang
[08:45:12] iamvery: has joined #elixir-lang
[08:48:54] Havvy: has joined #elixir-lang
[09:01:51] lexmag: has joined #elixir-lang
[09:08:06] kyrylo: has joined #elixir-lang
[09:23:48] mdbm: anyone has read the Programming Elixir book?
[09:24:01] mdbm: I don't understand some code
[09:31:49] dysfun: mdbm: which code?
[09:32:04] dysfun: (no, i don't have a copy of the book handy)
[09:35:15] mdbm: at one point, he creates a "Ticker" module, which emit "ticks" to clients (just send :tick atom).The clients can register to the Ticker server and listens to the :tick messages. I don't understand why he creates processes for the Ticker server and the Client. Why not use "the current" process?
[09:35:17] mdbm: https://pastebin.com/YL6bKySz
[09:35:20] mdbm: dysfun, ^
[09:36:07] mdbm: so my question is, why do we need processes here? lol
[09:36:23] dysfun: well it looks like the reason that's been done is so there's a global name for it
[09:36:46] dysfun: in general, it is managing data you might want to be accessible globally
[09:36:47] mdbm: dysfun, if we don't crreate a process, we don't even need that global name
[09:37:07] dysfun: but we do, because you might want to use it from more than one place
[09:37:30] mdbm: dysfun, and there's no other way than processes?
[09:37:45] dysfun: there are other ways, but this is the one you're learning
[09:38:03] dysfun: and the most generally useful one
[09:38:31] dysfun: in general, i don't do a lot of thinking about "the current" process outside of a genserver etc.
[09:38:33] gvaughn: has joined #elixir-lang
[09:38:46] mdbm: dysfun, but why not: :global.register_name(@name, self()) <= attach a name to the current process. Why create a new one?
[09:39:05] mdbm: (why create a new one with spawn*)
[09:39:28] dysfun: presumably when you get further in the book and it introduces supervision trees and such, it will become clear
[09:39:38] alexandre: has joined #elixir-lang
[09:40:03] dysfun: services like this would typically be started by a supervisor
[09:40:10] mdbm: dysfun, you are right, maybe I ask myself too many questions for now
[09:40:36] mdbm: dysfun, but can you tell me what happens to the process that actually spawns the new process? it dies?
[09:40:37] dysfun: but for now they are introducing the mechanisms one by one so you're not completely confused
[09:40:56] dysfun: no, it keeps on going
[09:41:27] dysfun: presumably you'll do other things after starting the service
[09:41:53] mdbm: dysfun, well once it has run the program, it keeps doing what? i.e. after it has reached the "end" of the start function
[09:42:14] dysfun: it will return the result of calling it to you
[09:42:30] dysfun: and the new thread will be live doing its thing
[09:42:49] zakora: has joined #elixir-lang
[09:43:14] dysfun: calling spawn does not suspend the current thread
[09:43:19] mdbm: yeah the new process will wait (receive do...) for messages. But I think the first one that created that thread will die in this sample code, because it has nothing more to do
[09:43:20] dysfun: it just returns a value
[09:43:33] mdbm: dysfun, and what is its state after returning the value?
[09:43:43] dysfun: well i assume the code you are not showing does Client.start()
[09:43:58] dysfun: which will return the value of calling Ticker.register
[09:44:02] mdbm: dysfun, in this example that is done in another iex session I believe
[09:44:15] dysfun: right, well you'll notice you can still type in iex after doing it
[09:44:23] dysfun: i.e. the process continues
[09:44:23] thomasross: has joined #elixir-lang
[09:44:25] mdbm: ah right
[09:44:37] dysfun: you just called a function that happened to spawn a new process
[09:44:51] dysfun: there is no change of state of the process as such
[09:44:56] dysfun: it's just you created a new process
[09:44:59] dysfun: the return of which was a pid
[09:45:39] thomasross: has joined #elixir-lang
[09:45:48] mdbm: dysfun, if we run a java program, it will execute the main method and then exit, right? process exists (I'm not a java programmer but it's just an example)
[09:46:13] mdbm: bu in Elixir, I understand as you said the process still live, but I don't understand why, and what it can still do except responding to iex commands
[09:46:26] dysfun: stop thinking like java threads
[09:46:38] dimitarvp: has joined #elixir-lang
[09:46:38] dysfun: you can just spawn new threads in erlang almost without thinking about it
[09:47:06] dysfun: if you get to the end of a function in a spawned thread, the thread dies of natural causes
[09:47:39] dysfun: but spawning a thread isn't a special thing as such, there is nothing special about a thread that spawns a thread
[09:47:39] mdbm: ah, so there is a difference between a spawned thread and the main thread from which the program starts?
[09:47:51] dysfun: no, there isn't
[09:48:21] dysfun: i keep saying thread when i mean to say process, which probably isn't helping
[09:48:37] dysfun: you have no guarantees about which OS thread your process will run on
[09:48:44] mdbm: you said the spawned thread dies of natural causes, but my "main" thread, still lives and can still respond to iex commands once it gets to the end of the function
[09:48:53] dysfun: yes, indeed
[09:49:02] Nicd-: yeah it goes OS process -> OS thread -> BEAM process
[09:49:02] dysfun: if you want it to die when something else dies, you have to link it
[09:49:16] dysfun: i presume they'll cover that shortly
[09:49:33] dysfun: but the default mode doesn't have them connected
[09:49:52] dysfun: if you'd use spawn_link instead of spawn, however...
[09:50:04] mdbm: yeah I've read that already
[09:50:16] dysfun: i think you might be just jumping a bit too far ahead
[09:51:07] mdbm: yeah I guess some points will auto-clarify as I progress in the book
[09:52:08] dysfun: if they don't, perhaps you'll have a slightly better footing to help understand our explanations :)
[09:52:15] gonz_: In my experience nothing will crystallize like doing.
[09:52:59] dysfun: i think it's only once you start doing supervision trees the reason for not just abusing the process you happen to be on will become clear
[09:57:29] thomasross_: has joined #elixir-lang
[09:59:12] mdbm: I finished the "Processes" and "Nodes" chapter. Upcoming: "OTP: servers", "OTP: supervisors" and "OTP: applications"
[09:59:37] mdbm: are all of these concepts heavily used in an Elixir app?
[09:59:53] dysfun: they are in most production elixir apps
[09:59:59] dysfun: they're what give us that fault tolerance
[10:00:00] serafeim: not in phoenix apps though
[10:00:08] dysfun: yes, they are used in phoenix apps
[10:00:17] josevalim: there are in Phoenix apps too, but someone else set it up for you, so you don't have to worry about it
[10:00:18] serafeim: at least not in a good old traditional crud app
[10:00:29] serafeim: josevalim probably that's the case
[10:00:36] josevalim: not probably, certainly :)
[10:00:39] dysfun: just because you don't see much of it doesn't mean it's still there
[10:00:50] dysfun: crack open application.ex
[10:01:06] dysfun: s/it's/it's not/
[10:01:07] josevalim: it is completely fine to write a Phoenix app and not care about any of this, but it is still all there as someone else did the "dirty" work :)
[10:01:27] serafeim: i know I have to put some some things in my application (like :exldap) to be started; but i'm not very familiar with this
[10:01:39] serafeim: it "just works" so i''m ok with that for now
[10:02:23] serafeim: i also know that things that are *started* are processes and are used to save state; that's it
[10:02:44] dysfun: then there's much to learn
[10:03:11] gonz_: It's fantastic that it's possible to create tools that allow people to not care about these things, but OTP is part of the secret sauce that is the BEAM and putting off learning it isn't useful.
[10:03:42] gonz_: Learning how to use and actually take advantage of OTP can only be done with practice.
[10:03:54] dysfun: i'd also argue it denies you a valuable tool for reasoning about your codebase
[10:04:24] dysfun: the way we do things are tools for thought as well as resilience
[10:05:21] dysfun: and it's actually not all that hard, it's just unfamiliar
[10:05:46] serafeim: i think that the best way to learn is by doing
[10:05:53] gonz_: If I were to look at someone's GitHub while gauging them for hiring or something like that it's on the whole a positive to see a bunch of useless (to everyone else in the world) apps that explore what OTP is, using different models for starting and managing processes, etc.
[10:06:02] dysfun: it is. but you have to do things that stretch your knowledge if you're going to learn
[10:06:33] serafeim: so i'll start with my simple CRUD app for now... if I need to add some extra thigns (thatt will be needed probably) like async tasks or scheduled tasks etc I'll guess that I'll learn more advanced otp stuff
[10:07:22] gonz_: My point is that made up use cases that aren't practically useful will allow you to explore these things before you need them.
[10:07:58] serafeim: gonz_ this doesn't work very well for me :| it may work for other people though
[10:08:28] dysfun: doesn't work for me either tbh
[10:08:39] dysfun: just find something that needs knowledge you don't have
[10:08:58] dysfun: might not feel very easy going for a while, but boy you'll learn :)
[10:09:48] gonz_: I suppose this is largely a matter of inspiration and imagination
[10:10:01] gonz_: but there's a multitude of ways to make a chat service in Elixir and each will teach you something
[10:10:03] dysfun: different people learn in different ways
[10:10:05] gonz_: as an example
[10:10:24] dysfun: it's one of the perennial arguments i have with haskell people
[10:10:40] gonz_: Thinking "Oh, I'd just use phoenix channels anyway so why should I bother?" (this is common) is a surefire way to stay one-dimensional
[10:11:00] gonz_: "haskell people" ^^
[10:11:17] mdbm: dysfun, in the sample code I gave you, the "main" function of the Ticker server is called "start", but very often I see a function called "run", when does a function name need to be called "run"? https://pastebin.com/YL6bKySz
[10:12:36] dysfun: mdbm: i think for now you shouldn't attach too much significance to names. when you build a genserver, you will need to make functions with specific names so you can be called back, but otherwise, it's just freeform - i don't know off the top of my head anything that makes you call something 'run' in elixir
[10:13:46] gonz_: dysfun: If the torrent of monad tutorials trying to express it in different ways have showed me anything it's that "haskell people" have tried pretty much every way at this point
[10:14:21] gonz_: I also don't think this categorization of people is very useful in the long run.
[10:14:58] gonz_: "Elixir people" isn't a useful categorization in my book, for example, because I've seen people who are vastly different even on a limited place like ElixirForum, for example.
[10:15:24] gonz_: You might want to consider if this might also apply to other communities
[10:15:24] dysfun: yes, well perhaps the haskell community have been awful to yet another one of my friends who's decided to leave the community again and i'm not much interested in hearing a defence of them
[10:16:10] gonz_: With all due respect I don't think your friend being treated badly by some people in the community is a useful data point
[10:16:44] gonz_: I'm sure they're nice and whatever happened they didn't deserve it, but it's useless to paint an entire community with this broad a brush
[10:16:57] dysfun: well frankly, i wasn't intending to talk about haskell at all, it was an off the cuff remark to say "but this has come up before in other communities"
[10:17:21] gonz_: Right. But it's a demonstrably false assertion as well.
[10:17:41] dysfun: well no. but i suggest we stop here because i could get rude otherwise
[10:17:42] serafeim: well i haven't actually tried to ever learn haskell but the language and community have an elitistic and academic feeling to me
[10:17:51] serafeim: from discussions and comments in HN mainly
[10:18:16] serafeim: i have the feeling that haskell is only good if you are a post-grad student in programming language theory
[10:18:19] dysfun: ACTION is still a part of the haskell community incidentally
[10:18:27] gonz_: dysfun: Maybe you should think about what that says about you.
[10:18:29] serafeim: and you can't use it for anything prod like
[10:18:40] Nicd-: I don't know anyone from the Haskell community, I just find Haskell is way over my head
[10:18:53] serafeim: as i said i don't know anything about haskell unless these feelings i just mentioned :)
[10:18:58] dysfun: oh spare me, haskell is not dealing with its toxic comunity members
[10:19:05] dysfun: never has either
[10:19:16] serafeim: oh and that it was tought in the 9nth semester in my university in an optional course
[10:19:20] Nicd-: could you continue in PM?
[10:19:25] Nicd-: if you are going to fight over it
[10:20:27] gonz_: I agree it doesn't have a place in this channel.
[10:28:50] mdbm: I log some stuff using IO.puts, and I want to include the process ID but it doesn't work: IO.puts "Some log #{self()}"
[10:28:52] mdbm: I get the error:
[10:28:54] mdbm: ** (Protocol.UndefinedError) protocol String.Chars not implemented for #PID<0.104.0>
[10:29:04] mdbm: how can I include that PID?
[10:29:12] ariedler: has joined #elixir-lang
[10:31:57] Nicd-: use `"Some log #{inspect(self())}"`
[10:32:01] josevalim: > Thinking "Oh, I'd just use phoenix channels anyway so why should I bother?" (this is common) is a surefire way to stay one-dimensional
[10:32:16] josevalim: there is nothing one-dimensional about the web
[10:32:53] josevalim: you have to learn http, websockets, html, css, js, sql and now elixir+phoenix and not learning otp is what makes you one-dimensional?
[10:33:08] josevalim: there are plenty of reasons to use Phoenix above other tools without including OTP
[10:33:24] thomasross: has joined #elixir-lang
[10:33:40] josevalim: people shouldn't feel bad or one dimensional because they would rather focus on other stuff
[10:34:19] hypercore: has joined #elixir-lang
[10:34:29] sparogy: has joined #elixir-lang
[10:34:47] DarkSeid: has joined #elixir-lang
[10:34:48] josevalim: and that's not including the domain or business challenges they may also be working on
[10:35:38] hypercore: how can i embed a field inside a custom select field?
[10:36:09] mdbm: Nicd-, thanks:)
[10:37:46] hypercore: also related to my question about saving state that isn't tied to a changeset, e.g. for an intermediary value (used to calculate the value of a changeset field)
[10:38:26] mdbm: I see the book uses Erlang: ":global.register_name(@name, pid)" but I can see an Elixir function if I'm not wrong for it in the Process module: Process.register(pid_or_port, name)
[10:39:11] mdbm: actually I'm surprised, I thought the philosphy was to not rewrite Erlang functions if there's no reason, is there any added value to use Process.register/2 ?
[10:39:45] mdbm: I wonder why the author didn't use the Elixir function
[10:40:12] mdbm: (the book is Programming Elixir 1.6)
[10:40:28] dysfun: elixir has reorganised the stdlib a bit because the erlang one is a bit of a mess
[10:40:34] dysfun: Process is one of the modules that this was done for
[10:40:47] dysfun: i guess what we really mean is "don't needlessly wrap erlang libraries"
[10:40:56] dysfun: most libraries are self contained enough and don't need wrapping
[10:41:06] hypercore: it still suprises me how complex implementing a simple form can be
[10:41:15] dysfun: the elixir stdlib will also quietly rewrite some of these calls to the erlang ones rather than functions that call the erlang ones
[10:44:12] hypercore: i think this field is showing when i submit the form the traditional way, but i can't figure out how to make it work using live view (because the field isn't part of the changeset)
[10:46:29] mdbm: dysfun, thank you. I've always wondered why they don't just fix the mess in a major release. It's like php and its horrible stdlib, why can't we just refactor the mess
[10:47:31] dysfun: backwards compatibility
[10:47:45] dysfun: i mean, we do break things in erlang sometimes, but there's a limit
[10:47:49] mdbm: dysfun, that's why I specified major release
[10:48:47] mdbm: but I understand for some people it will be too hard to update because of BC
[10:48:59] mdbm: but then we have to stick to some mess for decades
[10:49:01] dysfun: erlang takes BC quite seriously
[10:49:06] dysfun: more seriously than i'd like it to, perhaps
[10:49:51] josevalim: mdbm: Process.register is per node, :global is global across the cluster
[10:51:20] mdbm: so I need to use :global.register_name only if I want my processes to interact from different machines?
[10:51:46] wsieroci: has joined #elixir-lang
[10:55:08] ariedler: has joined #elixir-lang
[10:55:28] gvaughn: has joined #elixir-lang
[10:55:41] dysfun: global is for the cluster, local is for the node
[10:56:10] dysfun: in a 5-node cluster, only 1 node will run the global process
[10:56:19] dysfun: (vs 5 for local)
[11:00:40] iamvery: has joined #elixir-lang
[11:01:05] hypercore: is it ok to change files in deps?
[11:01:33] dysfun: if you don't mind it breaking when you next do a clean or try to build it on a fresh machine
[11:01:55] hypercore: dysfun: yeah it's not ideal, but it's the only solution to my problem i think
[11:02:11] dysfun: how about path: ?
[11:02:26] dysfun: {:foo, path: "../../blah"}
[11:02:54] hypercore: the url path?
[11:03:00] dysfun: no, a file path
[11:03:09] dysfun: to your local git clone
[11:03:16] mdbm: hypercore, for me it's never ok to change files in your dependencies
[11:03:25] dysfun: i assume you're debugging something
[11:03:37] mdbm: at least fork then
[11:03:38] dysfun: if you need to use a fork, you can pass git: as well
[11:03:45] hypercore: dysfun: i'm trying to add a custom field to a datetime form builder
[11:03:56] hypercore: mdbm: yeah this is generally my view too, like to avoid as much as possible
[11:04:13] mdbm: hypercore, not as much as possib,e always avoid :D
[11:04:16] dysfun: yeah i'd probably vendor the lib for now, maybe make it its own git repo later
[11:04:40] dysfun: but for that, you wouldn't modify the one in deps, as such
[11:04:42] dysfun: you'd use path:
[11:04:55] dysfun: and it'd just be a path within your project to the vendored copy
[11:05:06] hypercore: dysfun: oh i see what you're saying
[11:05:34] hypercore: yeah this could work
[11:05:52] hypercore: or should i just build a completely custom form?
[11:06:03] hypercore: i.e. with html for each select element
[11:06:22] dysfun: ACTION consults his crystal ball
[11:07:17] hypercore: dysfun: but it won't with live view if i do that right?
[11:07:48] dysfun: i've never used liveview
[11:08:48] mdbm: dysfun, a "receive do" by default has no timeout right?
[11:08:56] hypercore: i just started using it a day or so ago, pretty cool
[11:09:04] dysfun: mdbm: correct, you need to ask for one if you want one
[11:09:10] mdbm: thank you
[11:09:18] hypercore: but i don't have a good enough understanding of the internals to make a judgement call on this
[11:09:28] dysfun: try it then
[11:09:46] hypercore: dysfun: try the html?
[11:10:11] dysfun: it's not going to take long to try
[11:10:45] dysfun: but if you're starting to diverge from a library, i'd seriously consider whether just doing it yourself would be easier
[11:12:44] hypercore: oh i've tried (the inserting the html in the form builder, that is), but when the changeset is sent to the server, it gives the form %{"select_builder" => %{"a" => 1, "b" => 2}, "c" => "3"} (where c is the inserted field)
[11:13:16] hypercore: instead of %{"select_builder" => %{"a" => "1", "b" => "2", "c" => "3"}}
[11:13:29] dysfun: sorry, sounds like i'd need to know liveview to answer that
[11:15:26] hypercore: dysfun: sorry, the field doesn't even show up on phx-change
[11:15:41] thomasross_: has joined #elixir-lang
[11:15:56] hypercore: yeah i think so
[11:15:58] dysfun: ACTION shrugs
[11:16:08] dysfun: i may not have mentioned, but all my phoenix work is with a rest api
[11:17:23] hypercore: react probably
[11:17:32] dysfun: not me doing it though
[11:17:51] hypercore: that makes it a lot more palatable
[11:17:59] dysfun: in my other job i work on an spa, but that's written in purescript
[11:18:08] dysfun: (with react, but i wrote a really nice react binding)
[11:18:46] hypercore: personally i think SPA adds way too much (for most cases) unnecessary complexity
[11:19:02] thomasross: has joined #elixir-lang
[11:19:12] hypercore: so much easier just using forms, and live view bridges the dynamic UX gap
[11:19:21] dysfun: i have mixed feelings about them. the one i work on would probably not be better if it weren't an spa
[11:20:17] hypercore: maybe SPA is better option for a team of developers, but for a solo dev i don't think the benefits outweight the costs
[11:20:37] dysfun: well, the api i work on, almost all of the spa is done by one person right now
[11:20:46] mdbm_: has joined #elixir-lang
[11:21:11] dysfun: we have joked about replacing him with liveview
[11:23:32] serafeim: I've thought a lot about the SPA vs traditional web app
[11:24:10] serafeim: I strongly believe that SPA are useful for only a very small number of applications (less than 1% of all apps developed) like gmail, chat-like apps and so on
[11:24:44] dysfun: there's nothing wrong with being wrong
[11:25:00] serafeim: all other apps that are using SPA is mainly because developers like shiny things and managers of developers can't understand things and believe what their developers (and hype) says to them
[11:25:40] hypercore: that was my conclusion. maybe before live view there was a better argument for them, but now the complexity just isn't worth it
[11:25:40] dysfun: we definitely didn't end up with an spa because of overmanagement, in our less than 10 people company
[11:26:27] dysfun: that's inadvertently hilarious, but explaining why might be difficult
[11:26:45] mdbm_: what is live view? :/
[11:26:49] gonz_: hypercore: Drab existed before and was a valid alternative for many use cases
[11:27:56] dysfun: mdbm_: live view is a little bit of js wrapping phpenix channels that makes your webserver draw updated html instead of doing it in javascript
[11:27:58] hypercore: gonz_: sure, drab, texas, etc. I just said live view because that's the first library i heard about that could do this stuff
[11:28:22] serafeim: i am working professionaly for like 15 years, i haven't yet found an app that can't be implemented with a little jquery and would really benefit from an SPA
[11:28:23] gonz_: I think that's how they prefer it
[11:28:27] mdbm_: dysfun, uhm, sounds horrible?
[11:28:41] dysfun: mdbm_: depends on your usecase, as ever
[11:29:06] gonz_: mdbm_: For low-latency, low user count setups (this is variable, of course) it's pretty excellent.
[11:29:18] dysfun: Serafeim: i've also been working professionally for ~15 years and i've seen loads
[11:29:25] gonz_: Any internal system is probably most easily done with a system like this
[11:29:42] hypercore: idealistically SPA's are probably superior to web apps, but practically most of the time their unnecessary
[11:30:01] serafeim: dysfun hmm we work in different environments i guerss :)
[11:30:25] serafeim: i work in a public sector organization implementing various internal apps for its users
[11:30:35] dysfun: that's the sort of thing liveview is probably very good for
[11:30:55] gonz_: Serafeim: The problem is that "can" is a matter of debate. Could you make whatever with JQuery? Yeah, technically speaking. The problem isn't the ability to do something, but rather whether or not it's a good idea in the long run.
[11:30:57] dysfun: my experience has been, well let's say 'diverse'.
[11:31:40] serafeim: gonz_ I agree. however for most of the use cases i have in my mind using jquery seems like a good idea
[11:31:40] gonz_: You can do whatever in whatever, really. The issue is only "Does it make sense to?".
[11:32:05] dysfun: the problem space for webapps is very wide. no approach is always correct
[11:32:41] serafeim: for example: stackoverflow: can it be implemented with jquery? yes. would it be a good idea? yes. the same for gitub, hn, mandrill, sendgrid, every cms in the worl... there are very few exceptions
[11:33:58] dysfun: as we already discussed, your experience is not the only one
[11:35:27] gonz_: This is a scale, though. A structure that people subscribe to is more likely to lead to less bugs overall.
[11:35:42] mdbm_: Serafeim, but when doing traditional server side rendering and using just jquery, a lot of state ends up in the server and I often have seen a lot of ugly messy code (big fat controllers with too much responsibilities). UI state belongs to the client and frontend libs like React allow you to manage all your UI state client-side, in the browser.
[11:35:47] gonz_: If people are either afraid to put in features because they perceive adding features as a source of bugs I don't want them to use JQuery.
[11:36:04] gonz_: If people are adding features and creating bugs as a result of using JQuery I again don't want them to use JQuery.
[11:36:14] netrino: has joined #elixir-lang
[11:37:01] serafeim: mdbm_ that's what I'm saying. most of the time you don't have that much state. you just have a crud app for inserting things in a database
[11:37:41] serafeim: and maybe in some complex cases a workflow for what can be done by each actor
[11:37:49] mdbm_: Serafeim, most of the time you *think* you don't have much state, and you oftenly end up with a lot of state. except products for academic purposes, then I agree, but I don't care about these
[11:37:50] serafeim: but most business apps in the world are like this
[11:39:46] shmink: has joined #elixir-lang
[11:40:25] wonko77: has joined #elixir-lang
[11:41:59] lexmag_: has joined #elixir-lang
[11:42:53] shmink: has joined #elixir-lang
[11:43:59] kyrylo: has joined #elixir-lang
[11:44:27] shmink: has joined #elixir-lang
[11:44:28] serafeim: i recommending reading some basecam/DHH articles for more
[11:44:45] hypercore: are there any live view expers here?
[11:45:25] serafeim: concerning live view; is there a demo site where I can play with liveview a little ?
[11:45:45] wsieroci: has joined #elixir-lang
[11:45:49] serafeim: i've seen implementations in GH but i'd like to see a working exampleto play with it i.e hosted on heroku or something
[11:46:11] gonz_: https://tg.pl/drab
[11:47:20] shmink: I'm trying to make a reverse polish notation spreadsheet processor. That I'm having real trouble with frankly. I have the following input "1,2,=A1 B1 +\n2,2,=C1 A2 B2 + +\n" and the expected output should be "1,2,3\n2,2,7". Any pointers would help a lot.
[11:47:37] serafeim: thanks gonz_
[11:48:50] gonz_: To be clear, it was kind of a joke and that page is about Drab, not LiveView
[11:48:50] shmink: all I've managed to do so far is a rudimentary reverse polish notation calculator that works as "2,2,+" will output "4". But the way these expressions are in the above input I don't really know how best to even parse them up.
[11:49:09] serafeim: gonz_ it uses live view internall doesn't it ?
[11:49:30] gonz_: Not unless it was rewritten recently
[11:49:37] gonz_: Drab predates LiveView
[11:50:46] serafeim: so liveview is somethign similar to drab ? control front end from the backend ?
[11:51:04] serafeim: excellent thanks
[11:52:00] gonz_: Without being too toxic about it my opinion has been from the announcement of LiveView that it should've been done as work with Drab
[11:53:18] gonz_: There's approximately 3 years of work in Drab
[11:53:43] gonz_: But yeah, I don't care enough for this community to have that debate again
[11:53:49] serafeim: and it's rather popular and nice maintened for elixir standards
[12:00:49] nickjj: was pg_dump a new dependency as of phoenix 1.4 / ecto 4? since upgrading i noticed i can no longer run a mix ecto.setup due to it saying pg_dump isn't on the path (using the same debian based docker image i used previously which just had elixir and libpq-dev as deps
[12:04:32] gvaughn: has joined #elixir-lang
[12:06:50] shmink: Is there a way to increment chars in elixir like in the following question?
[12:07:15] micmus: nickjj: there's no ecto 4 :P you probably mean 3. AFAIK The ecto.dump and ecto.load tasks always required pg_dump and psql respectively. Also ecto.setup is not a standard task and probably something defined in your project. Last - you don't need libpq, at least not for ecto/postgrex, it implements the tcp protocol from scratch and does not use C bindings
[12:07:23] shmink: https://stackoverflow.com/questions/12504042/what-is-a-method-that-can-be-used-to-increment-letters
[12:08:11] nickjj: micmus, sorry i meant phoenix_ecto 4.0.0 (i upgraded from phoenix 1.3 to 1.4 recently)
[12:08:48] nickjj: ecto.setup was an alias that did a create, migrate and seed in 1 shot -- but prior to this i didn't have pg_dump installed in the same container as ecto and it worked
[12:10:26] mdbm_: trying to grasp OTP. Is OTP actually just a library written in Erlang?
[12:10:59] shmink: \join #programming
[12:11:12] nickjj: it's now become problematic, it's not as simple as just installing postgresql-client-9.6 (available in debian stretch) because i'm running pg 11.x and then it gets a pg_dump server / client mismatch
[12:12:16] micmus: nickjj: I don't think anything in there should require pg_dump. pg_dump is only used by the ecto.dump task
[12:14:02] nickjj: micmus, the migrate alias i'm running does a dump because i wanted to have my entire schema written to a file on the side
[12:15:22] wsieroci: has joined #elixir-lang
[12:15:51] nickjj: if i remove the ecto.dump then i'm able to run the task, but now i'm really curious how this worked in the past with the same server environment but an older version of ecto
[12:18:40] shmink: how do you get the value of a char and visa versa? I know the << >> have something to do with it.
[12:21:52] gonz_: mdbm_: Yes, it's just a library for dealing with processes.
[12:22:16] tnez: has joined #elixir-lang
[12:22:54] mdbm_: gonz_, why is it considered tedious to learn?
[12:22:56] gonz_: Though the obvious disclaimer as I see it is that you shouldn't run away and implement it on some other platform. People have tried and regardless of what they think they've not really succeeded.
[12:23:03] gonz_: mdbm_: Is it?
[12:23:56] mdbm_: gonz_, implement it on some other platform? not sure what you mean or what you're talking about
[12:24:06] gonz_: OTP is a crystallization of what it means to think in Erlang, as far as I see it. Learning it and how to use it means you've likely internalized what it means to make a living Erlang system.
[12:24:50] lexmag: has joined #elixir-lang
[12:24:54] gonz_: As for this being tedious, I suppose unlearning fear of concurrency can be scary in itself, but I'm not sure people are lining up to rant about how OTP is hard or tedious to learn.
[12:25:41] gonz_: Then again, I haven't read the forums or peoples' blog posts for a while either.
[12:27:01] mdbm_: gonz_, I might heave read wrong too, it was just my impression. Maybe because it is a big library, I don't know... the book I'm currently reading (Programming Elixir 1.6) says it will just talk about some parts of OTP, not all, that sets the tone
[12:27:17] gonz_: If you compare OTP to other platforms' solutions it's conceptually much easier, but possibly a bit too different for people who've invested in other modes of thinking.
[12:30:00] lexmag: has joined #elixir-lang
[12:32:02] gonz_: All in all I think a lack of familiarity is the biggest blocker to a lot of things people say is hard, or rather a familiarity with something that is sufficiently different to disrupt learning of a different concept.
[12:33:25] gonz_: If all you've ever done is manage threads manually, dealing with thread pools and whatnot, OTP is going to seem odd to you.
[12:34:48] inoas: has joined #elixir-lang
[12:35:04] gonz_: Perhaps it's even going to seem like giving up a lot of control. I'd wager a guess that in most of these cases people weren't actually controlling the same amount of things that OTP allow you to control, however.
[12:46:19] nickjj_: has joined #elixir-lang
[12:59:49] nox: I am pretty sure most people who get confused with OTP get confused with thread pools too.
[13:00:31] sparogy: has joined #elixir-lang
[13:03:53] mdbm_: has joined #elixir-lang
[13:04:48] blahdodo: has joined #elixir-lang
[13:06:41] dysfun: i don't get confused with OTP too easily, but thread pools confuse the heck out of me
[13:14:50] either|or: has joined #elixir-lang
[13:15:32] proteusguy: has joined #elixir-lang
[13:16:19] medzin: has joined #elixir-lang
[13:22:03] gvaughn: has joined #elixir-lang
[13:27:32] inoas: has joined #elixir-lang
[13:35:28] __charly__: has joined #elixir-lang
[13:38:05] drincruz: has joined #elixir-lang
[13:41:11] duaneb: has joined #elixir-lang
[13:41:24] pera: has joined #elixir-lang
[13:43:05] weird_error: has joined #elixir-lang
[13:44:25] greengriminal: has joined #elixir-lang
[13:49:49] shmink: how do you get the value of a char and visa versa? I know the << >> have something to do with it.
[13:50:14] josevalim: Use a question mark before the char
[13:50:52] josevalim: nickjj_: why is the setup task
[13:51:09] shmink: josevalim: nice, thanks :)
[13:51:25] josevalim: nickjj_: why is the setup task dumping after migrating? In any case, you can just change the alias
[13:51:37] nickjj_: josevalim, it was doing "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"]
[13:51:56] josevalim: That should not dump it
[13:52:04] nickjj_: and migrate was adjusted to be: "ecto.migrate": ["ecto.migrate", "ecto.dump"]
[13:52:12] josevalim: Oh, that’s why
[13:52:46] nickjj: mainly because i wanted to get a sql file dumped out in priv/repo/structure.sql
[13:53:06] gvaughn: has joined #elixir-lang
[13:53:06] josevalim: Right, that’s why you need pg_dump then :)
[13:53:30] josevalim: You can not define said alias in production
[13:53:36] nickjj: but, it's very interesting because 6+ months ago when i was working on this project, somehow that all worked without pg_dump being available in the container that has elixir
[13:53:58] josevalim: IIRC We always used pg_dump
[13:54:17] nickjj: and between then and now i've updated phoenix from 1.3 to 1.4 (and the associated ecto libs) and also updated pg from 10.x to 11.x
[13:54:33] josevalim: Serafeim: LiveView is not really about controlling the client from the server
[13:54:55] josevalim: As it doesn’t expose semantics like that (which Drab does)
[13:55:16] nickjj: yeah truthfully i may ditch the alias in the end, having the sql file at this point isn't necessary -- i just wanted it early on to better see the raw sql vs ecto migrations
[13:55:57] josevalim: LiveView is more high level, it can be summarized as “react running on the server”
[13:56:24] netrino: has joined #elixir-lang
[13:56:32] OliverMT: so when are we getting hooks josevalim ?
[13:56:38] josevalim: I guess drab is more like “jquery on the server”?
[13:57:32] nickjj: you guys did a really great job with the upgrade process too btw, i jumped both elixir and phoenix/ecto versions and other than some phoenix related boilerplate associated changes, i only had to change about 5 lines of application code
[13:57:47] josevalim: OliverMT: hooks for?
[13:58:04] hypercore: hoping you might have some insight into live view jose, do you know if it's possible to submit a custom field on validation?
[13:58:46] hypercore: tried inserting the custom field in html, adding the name like i would with a non-liveview form, but it isn't shown in the validation changeset
[13:59:44] jeffro: has joined #elixir-lang
[13:59:59] __charly__: has joined #elixir-lang
[14:00:27] josevalim: hypercore: do you receive the field as a parameter?
[14:01:49] hypercore: josevalim: nope, doesn't shown up at all. To be clear, i'm using the date form builder to add in a "week" field (which is just an html select element with name=date[week])
[14:02:32] OliverMT: josevalim: I was making a react joke :(
[14:07:35] hypercore: paste -> https://pastecode.xyz/view/51f915f5
[14:09:48] hypercore: i'm guessing live view needs the param to be a field in the changeset, otherwise it won't track it
[14:10:15] hypercore: %s/field in the changeset/field in the schema
[14:11:04] josevalim: hypercore: it should show up in the params as any other field. Unless we have a bugs with select?
[14:11:11] josevalim: Try something else just in case
[14:12:11] hypercore: josevalim: should it should show up in in live view validation event params?
[14:12:33] hypercore: ok i'll try it with another form, maybe i'm missing something
[14:16:56] josevalim: Yeah, everything inside the form should be validated or show up in submit
[14:17:27] hypercore: josevalim: i'm probably doing something stupid then, thanks for clarifying that
[14:20:46] mdbm: has joined #elixir-lang
[14:21:23] shmink: could someone explain or show why my `col_num` and `row_num` are being "unused"? https://dpaste.de/0SqY
[14:23:15] shmink: The function in the above paste is giving me `[[A1: 1, A1: 2, A1: "=A1 B1 +"], [A1: 2, A1: 2, A1: "=C1 A2 B2 + +"]]` when I would actually like `[[A1: 1, B1: 2, C1: "=A1 B1 +"], [A2: 2, B2: 2, C2: "=C1 A2 B2 + +"]]`
[14:26:17] shmink: It doesn't really make any sense to me, if one is enumerating, during that phase you can modify variables outside of the scope of the enumaration right?
[14:28:22] asabil: has joined #elixir-lang
[14:34:16] josevalim: shmink: no, you cannot
[14:34:36] josevalim: shmink: you have to convert that into a map_reduce
[14:35:00] shmink: I still can't wrap my head around map_reduce
[14:35:23] medzin: has joined #elixir-lang
[14:36:32] ariedler: shmink: do you understand both map and reduce seperatly ?
[14:36:50] shmink: not reduce I suppose.
[14:37:12] shmink: Reading up on it now. Enum.reduce/3 right?
[14:38:14] ariedler: map_reduce can be thought as just a map operation, followed by a reduce operation
[14:38:25] ariedler: just more efficient to do in one step
[14:39:43] shmink: Here `iex> Enum.map_reduce([1, 2, 3], 0, fn x, acc -> {x * 2, x + acc} end)` 0 is the initial `acc` value?
[14:39:49] user4: has joined #elixir-lang
[14:40:52] qqwy: has joined #elixir-lang
[14:41:49] fastfresh: has joined #elixir-lang
[14:43:49] drincruz_: has joined #elixir-lang
[14:44:20] shmink: An issue is that I have a value that I want to increment every "loop" of map. It starts at 65.
[14:46:29] drewolson: shmink: can you explain the problem you're trying to solve in english?
[14:47:43] shmink: drewolson: its in the messages above jose's
[14:48:02] shmink: if you just joined I can re-paste them.
[14:49:45] drewolson: i see the paste but can't quite understand what you're actually attempting from reading it
[14:50:53] greengriminal: has joined #elixir-lang
[14:51:06] shmink: Using the pasted function the output is: `[[A1: 1, A1: 2, A1: "=A1 B1 +"], [A1: 2, A1: 2, A1: "=C1 A2 B2 + +"]]`. But my desired output is: `[[A1: 1, B1: 2, C1: "=A1 B1 +"], [A2: 2, B2: 2, C2: "=C1 A2 B2 + +"]]`
[14:52:51] netrino_: has joined #elixir-lang
[14:53:08] shmink: The values are essentially arbritary for now. The keys however I want to enumerate at different points. Using `cell_num = Enum.into([<<col_num>>, "#{row_num}"], "") I can create the key but the values aren't incrementing.`
[14:54:17] drewolson: so you basically want to iterate over cells and put the values of each x y coord into the cell?
[14:55:41] shmink: no, I just want to iterate a number within a map, apparently I can't do that and so jose suggested using map_reduce instead and I'm trying to learn how to use it.
[14:56:40] drewolson: i still don't quite get it. why is a1 1 and b1 2? but both a2 and b2 are 2?
[14:57:19] shmink: They just are. Like I said, the values don't matter, just the keys.
[14:57:52] drewolson: ok, let see what we can do
[14:58:07] Phylock: has joined #elixir-lang
[15:00:39] fastfresh: how do I properly setup ElixirLS for VS Code? I'm getting strange file errors, though everything seems to work. Output: https://hastebin.com/sizeqamida
[15:04:04] drewolson: shmink: this uses nimble_csv https://gist.github.com/drewolson/922d677ec1466b5785a3fcda6139ba73
[15:04:15] drewolson: whoever wrote that library is pretty smart
[15:10:10] shmink: drewolson: don't think I'm allowed to use libraries :(
[15:10:26] shmink: I'll double check though
[15:21:11] nineczar: has joined #elixir-lang
[15:25:06] isHavvy: has joined #elixir-lang
[15:26:39] Poeticode: so I'm trying to associate an array of songs to a playlist. I found that when I upload more than 10 songs, suddenly the array order is 0, 1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9. Instead of the obvious ordering.
[15:26:54] shmink: thanks drewolson
[15:27:00] Poeticode: is there something I can do to force it to be ordered numerically instead of by string?
[15:27:23] ariedler: has joined #elixir-lang
[15:27:31] Poeticode: (im assuming that's what's happening under the hood. "10" is less than "2" if they're strings)
[15:38:22] user2: has joined #elixir-lang
[15:40:11] netrino: has joined #elixir-lang
[15:56:05] drewolson: Poeticode: you could use sort_by and parse the strings as integers
[15:57:36] drewolson: Poeticode: https://hexdocs.pm/elixir/Enum.html#sort_by/3
[15:59:47] Poeticode: d'oh, not sure why I didn't think of that D:
[16:00:11] Poeticode: got it working with `Enum.sort_by(songs, fn s -> Integer.parse( elem(s, 0) ) end)`
[16:12:05] traxo: has joined #elixir-lang
[16:15:28] jeffweiss: has joined #elixir-lang
[16:16:11] gvaughn: has joined #elixir-lang
[16:16:18] shmink: if you spawn a new process, how do you close it?
[16:16:56] shmink: with the pid I assume but I guess the question is simpler and what's the name of the function :)
[16:17:16] Nicd-: `Process.exit/2`
[16:23:25] orbyt_: has joined #elixir-lang
[16:30:19] Munto: has joined #elixir-lang
[16:55:19] medzin: has joined #elixir-lang
[16:57:26] jnoon2: has joined #elixir-lang
[16:57:44] medzin: has joined #elixir-lang
[17:11:36] benwilson512: shmink: from inside the process or outside?
[17:18:14] Saukk: has joined #elixir-lang
[17:18:53] griffinbyatt: has joined #elixir-lang
[17:25:32] drincruz: has joined #elixir-lang
[17:26:16] jnoon21: has joined #elixir-lang
[17:37:02] shmink: So I have this map: `%{A1: 1, A2: 2, B1: 2, B2: 2, C1: 3, C2: 7}` I would like to output it to CSV file. What would people advice?
[17:37:18] jnoon21: i cant seem to win with this vscode ElixirLS Dialyzer "Function … has no local return". i guess i dont really understand since the last statement is always returned?
[17:38:16] shmink: My thought so far is to somehow loop by the row number, as in A1, B1, C1, then add '\n' and repeat till empty?
[17:38:44] shmink: That in itself has problems though I guess. I would need to parse the key value down.
[17:39:05] kyrylo: has joined #elixir-lang
[17:40:25] jnoon21: shmink: something like first pass to turn it into a list of lists, second pass to write it out?
[17:44:18] benwilson512: shmink: do you have a list of those maps or just 1 of them?
[17:50:06] shmink: benwilson512: just that one I passed.
[17:50:08] lexmag: has joined #elixir-lang
[17:50:17] benwilson512: shmink: so it'll be a 2 line csv?
[17:50:32] gvaughn_: has joined #elixir-lang
[17:51:22] shmink: benwilson512: yes. So I think it should end up as "1,2,3\n2,2,7"
[17:51:34] benwilson512: keys = Map.keys(map); [keys, keys |> Enum.map(&Map.get(map, &1))] |> NimbleCSV.RFC4180.dump_to_iodata
[17:51:47] benwilson512: your keys embed the row number?
[17:51:51] benwilson512: are they atoms like that?
[17:52:04] shmink: benwilson512: yeeeeeeeah, don't ask hahah
[17:52:20] benwilson512: do you create that map or do you get it from somewhere else?
[17:53:05] shmink: I create it but at the time I couldn't see a better way to do it for some other processing that happens. Anyway here I am now.
[17:53:59] shmink: I've converted that original map into the following list and thinking I can just sort perhaps? `[["A1", "1"], ["A2", "2"], ["B1", "2"], ["B2", "2"], ["C1", "3"], ["C2", "7"]]` not quite sure how to do that sort yet :)
[17:54:26] benwilson512: well, you'll need to generate indices
[17:54:35] benwilson512: are those _exhaustively_ the keys?
[17:54:44] benwilson512: cause tbh you could just hard code fetching 6 values
[17:54:46] benwilson512: given how nuts they are
[17:54:54] benwilson512: if you need to generalize though you'll want to build an infinite stream of indices
[17:55:01] benwilson512: and then take while you can find keys w/ those
[17:55:28] shmink: benwilson512: I could hardcode them I guess as this is only a prototype project but I'd rather not for now whilst I still have time to attempt it.
[17:55:54] jeffro: has joined #elixir-lang
[17:55:56] benwilson512: so 1) build a map like you had before but use string keys not atom
[17:56:34] benwilson512: ah man it's actually hard to figure out what the columns even are
[17:56:37] shmink: benwilson512: like %{"A1" => 1} instead of %{A1: 1}?
[17:56:47] benwilson512: how are you supposed to figure out the column names?
[17:57:17] shmink: benwilson512: maybe I'm not following you but the column names are A, B and C in this example.
[17:57:40] benwilson512: your map doesn't have A B C
[17:57:42] shmink: ah right, just thought I'd check.
[17:57:51] benwilson512: it has those suffixed by the row number
[17:58:18] benwilson512: are you given a separate list of columns? or do you have to like iterate all keys and regex out the text?
[17:58:43] shmink: maybe grapheme and group_by or something weird?
[17:59:01] benwilson512: what if the column names have numbers in them?
[17:59:06] benwilson512: or are they literally only 1 character widde
[17:59:06] lexmag: has joined #elixir-lang
[17:59:44] shmink: benwilson512: yeah I would argue that for the sakes of this project the columns will only ever be A..Z
[18:00:24] benwilson512: are you able to show what your actual input looks like?
[18:02:46] benwilson512: embedding column AND row in a string is just such a big pain, I'm wondering if there's a more fundamental format we can work with
[18:05:08] shmink: To be clear, the data is from a csv then it gets parsed into the mentioned map, then some expressions that were in the spreadsheet are evaluated, we end up with the final values and now I need to output all that data back to a spreadsheet. That's the big picture, I explain it just so I know what bit of input you mean.
[18:05:35] shmink: Just because assuming you mean an input other than the one I already posted here.
[18:06:01] benwilson512: do you parse it from the CSV?
[18:06:46] benwilson512: what you should do is track the keys / values as %{ {column, row} => value}
[18:06:50] benwilson512: use a tuple as the key
[18:06:59] benwilson512: not a string, then you can easily extract column and row information later
[18:07:08] shmink: I do. So my VERY ORIGINAL input is "1,2,=A1 B1 +\n2,2,=C1 A2 B2 + +"
[18:07:37] shmink: the odd looking expressions is reverse polish notation :|
[18:07:41] benwilson512: yeah no worries
[18:07:55] benwilson512: ok, so I can assume then that it's `%{ {column, row} => value}` form not `%{ "#{column}#{row}" => value}` ?
[18:11:44] shmink: benwilson512: I took some time to paste the whole module and omit the "sensitive" parts to help.
[18:11:58] shmink: I'm working on the function called `unparse` :)
[18:12:46] shmink: It's _functional_ code but not good code.:)
[18:13:22] benwilson512: shmink: no worries, just put it in a gist or something
[18:14:32] lexmag: has joined #elixir-lang
[18:15:00] shmink: so unparse would take the `%{A1: 1, A2: 2, B1: 2, B2: 2, C1: 3, C2: 7}` map and turn it into `1,2,3\n2,2,7`
[18:15:40] shmink: my bad, thought I pasted the link https://dpaste.de/6Vtb
[18:15:45] benwilson512: I get that problem statement but
[18:15:56] benwilson512: what I am _really_ trying to avoid is that key structture
[18:16:28] shmink: yeah the reason I just did that key structure is to easily execute the expressions you see.
[18:16:29] benwilson512: shmink: yeah right here https://dpaste.de/6Vtb#L117
[18:16:35] benwilson512: instead of that do
[18:17:03] benwilson512: {<<65 + col_num>>, row_num + 1}
[18:17:11] benwilson512: and then don't call String.to_atom
[18:17:54] benwilson512: then when a formula refers to a cell
[18:18:14] benwilson512: parse the reference into a column and row
[18:18:17] shmink: oooh then combine it on that one case rather than an over all rule.
[18:18:18] benwilson512: and then lookup the tuple in the map
[18:18:36] benwilson512: BUT if you don't want to refactor, here's a solution, one sec
[18:19:00] shmink: thanks ben for the help
[18:20:28] shmink: and ongoing help :)
[18:21:33] shmink: frankly though the elixir community is the nicest I've ever come across.
[18:22:26] benwilson512: https://www.irccloud.com/pastebin/lMRAgq2o/
[18:22:32] benwilson512: shmink: something like that ^
[18:22:43] benwilson512: basically, figure out all your columns, figure out all your rows
[18:22:50] benwilson512: then for each row, grab the values for each column
[18:22:56] benwilson512: then pass that to NimbleCSV or w/e
[18:25:56] notzmv: has joined #elixir-lang
[18:26:47] shmink: I mean that is some voodoo stuff right there ben.
[18:27:00] squall: has joined #elixir-lang
[18:28:08] akraut: has joined #elixir-lang
[18:28:37] shmink: is there a reason why are naming the column names with `k` on line 4? Or just arbituary.
[18:32:42] lexmag: has joined #elixir-lang
[18:32:50] benwilson512: shmink: in my head I was thinking `key` but `c` for `column` would be better
[18:33:26] shmink: ah right, there was like 1% of me thinking that it's some syntactic sugar for some reason.
[18:37:40] lexmag: has joined #elixir-lang
[18:53:00] ariedler_: has joined #elixir-lang
[19:06:27] orbyt_: has joined #elixir-lang
[19:10:44] asabil: has joined #elixir-lang
[19:18:31] kiltzman: has joined #elixir-lang
[19:34:54] pera: has joined #elixir-lang
[19:48:34] orbyt_: has joined #elixir-lang
[20:00:11] asabil: has joined #elixir-lang
[20:01:07] jeffro: has joined #elixir-lang
[20:04:11] bars0: has joined #elixir-lang
[20:06:05] inhortte1: has joined #elixir-lang
[20:07:41] hypercore: is it possible to give a form element a nested name?
[20:08:06] mahmudov: has joined #elixir-lang
[20:08:42] hypercore: so that <%= text_input f, "product[name]", ... %> returns %{"product" => %{"name" => "myname"}}
[20:17:24] asabil: has joined #elixir-lang
[20:31:26] orbyt_: has joined #elixir-lang
[20:33:12] greengriminal: has joined #elixir-lang
[20:38:51] markmm: has joined #elixir-lang
[20:41:59] kyrylo: has joined #elixir-lang
[20:54:44] greengriminal: has joined #elixir-lang
[20:57:00] asabil: has joined #elixir-lang
[20:59:34] greengriminal: has joined #elixir-lang
[21:03:11] laut: has joined #elixir-lang
[21:30:53] asabil: has joined #elixir-lang
[21:37:05] za1b1tsu: has joined #elixir-lang
[21:37:32] ur5us: has joined #elixir-lang
[21:42:17] asabil: has joined #elixir-lang
[21:52:30] Speed: has joined #elixir-lang
[22:00:02] __charly__: has joined #elixir-lang
[22:07:21] kawen: has joined #elixir-lang
[22:07:26] MononcQc: has joined #elixir-lang
[22:07:27] eproxus: has joined #elixir-lang
[22:07:28] ctp: has joined #elixir-lang
[22:07:38] uhoreg: has joined #elixir-lang
[22:07:40] scrogson: has joined #elixir-lang
[22:07:40] DavidAntaramian: has joined #elixir-lang
[22:07:41] Scorchin: has joined #elixir-lang
[22:07:42] null__: has joined #elixir-lang
[22:07:43] jaydoane: has joined #elixir-lang
[22:07:44] worstadmin: has joined #elixir-lang
[22:07:50] jevy: has joined #elixir-lang
[22:07:53] Zarathu: has joined #elixir-lang
[22:07:56] Jikan: has joined #elixir-lang
[22:07:59] micmus: has joined #elixir-lang
[22:08:02] obfusk: has joined #elixir-lang
[22:08:04] balo: has joined #elixir-lang
[22:08:08] fowlduck: has joined #elixir-lang
[22:08:12] antranigv: has joined #elixir-lang
[22:08:14] nbg: has joined #elixir-lang
[22:08:14] peel: has joined #elixir-lang
[22:08:17] hansihe_: has joined #elixir-lang
[22:08:18] keden: has joined #elixir-lang
[22:08:23] uranoss: has joined #elixir-lang
[22:08:23] Fire-Dragon-DoL: has joined #elixir-lang
[22:08:24] christhekeele: has joined #elixir-lang
[22:08:25] Soni: has joined #elixir-lang
[22:08:27] Linuus: has joined #elixir-lang
[22:08:38] adamkittelson__: has joined #elixir-lang
[22:08:39] gausby_: has joined #elixir-lang
[22:08:55] argoneus: has joined #elixir-lang
[22:09:00] timwis: has joined #elixir-lang
[22:10:49] siruf: has joined #elixir-lang
[22:11:24] Shados: has joined #elixir-lang
[22:12:02] dyce[m]: has joined #elixir-lang
[22:12:10] LordPtolemy[m]1: has joined #elixir-lang
[22:12:25] iAmerikan: has joined #elixir-lang
[22:12:34] wilo[m]: has joined #elixir-lang
[22:13:31] MatrixTravelerb4: has joined #elixir-lang
[22:13:55] whatyouhide: has joined #elixir-lang
[22:14:02] alxndr_: has joined #elixir-lang
[22:14:24] Nicd-[m]: has joined #elixir-lang
[22:19:24] MatrixTravelerb4: has joined #elixir-lang
[22:22:28] siruf: has joined #elixir-lang
[22:34:12] markmm: has joined #elixir-lang
[22:41:20] markmm: has joined #elixir-lang
[22:43:12] drincruz: has joined #elixir-lang
[22:49:31] also_uplime: has joined #elixir-lang
[22:53:33] griffinbyatt: has joined #elixir-lang
[22:54:08] avdi: has joined #elixir-lang
[22:54:09] Cthalupa: has joined #elixir-lang
[23:02:30] fastfresh: has joined #elixir-lang
[23:11:31] weird_error: has joined #elixir-lang
[23:17:58] dyce[m]: has joined #elixir-lang
[23:24:06] orbyt_: has joined #elixir-lang
[23:28:17] also_uplime: I'm writing an S-expression parser (ultimately for a lisp) in elixir, and was curious - would it be appropriate to send tokens to another Task, that collects them, and then at the end of the parsing, returns all of them?
[23:31:50] mahmudov: has joined #elixir-lang
[23:32:16] za1b1tsu: has joined #elixir-lang
[23:33:36] jmcgnh: has joined #elixir-lang