Open deadfoxygrandpa opened 9 years ago
I will take a look at it today! The main reason it hasn't been added is that it hasn't been needed so far. elm-node is still experimental, and I was building out features that were needed in elm-oracle. I'll respond here when I finish up support for this.
Oh, I actually just figured it out. I was looking at an older method for creating input Signals, but there's a newer helper function that makes it possible.
Speaking of, I just added this locally, with a new Console.stdin : Signal String
signal. Would you be open to a pull request?
Oh, and the reason I'm interested (I guess I should explain):
I integrated elm-oracle
into my Sublime Text package to show the type signatures of functions that your cursor is on, but I've found that, on my computer at least, the overhead of creating a new nodejs process is a couple hundred milliseconds.
I've slightly modified elm-oracle
locally with this Console.stdin
signal, and I can get a persistent process that responds to new queries in just a few milliseconds instead of a few hundreds of milliseconds.
Speaking of, would you accept a pull request on elm-oracle
that adds another command line flag to create a persistent process instead of responding to one search query at a time and then exiting?
Sure! That is actually the most important issue on the elm-oracle tracker, elmcast/elm-oracle#6. Feel free to do the PR for elm-node first. Thanks for working on this.
Out of curiosity, why was this change reverted in 45a740bf5dfef37e071a79a5c83e4aae4841a919?
Because oh how it was implemented, it was causing an issue where any elm-node program using the Console package would hang instead of closing.
I would love to add support for this back in a better way. I am curious what use case you have?
I'm toying with implementing MAL (Make-a-Lisp, https://github.com/kanaka/mal) in Elm, and a way to get console input through elm-node would be fantastic. I'd be willing to experiment with possible solutions if you have any general direction of how you'd like this to work.
Very cool!
I can definitely add that back then. I wasn't aware anyone was actually using elm-node. :) I'll be sure to do development in a branch from now on. I am working on elm related stuff all day today, so l'll add this to the list.
Let me know if you run into any more problems.
I was trying to add a function to get user input from stdin, but I can't figure it out. Node doesn't seem to have a simple
get_line()
type function that blocks (because Node's "thing" is non-blocking). That seems to make it hard to make a Task that reads from stdin. But Elm seems to need the DOM to create a new inputSignal
.Am I missing something? Is this the reason you guys haven't added something like this yet?