Comments (5)
What is the problem with calling it twice? It could potentially change the mapping function, but I don't see a problem with that? Perhaps I'm missing something.
Maybe it isn't a problem, although I can't see a reason to change the mapping function.
This is not type safe as the msg transformer function could return a type different to that which the process accepts as a message.
You can type the spawn function to make sure they have to be the same return type.
For example this produces a compiler error
fn myfunc(foo: fn() -> a, bar: fn() -> a) {
todo
}
fn demo() {
myfunc(fn() { 2 }, fn() { 2.0 })
}
Does this mean the process will hold a map of functions that take pids/ports and return a message?
Basically yes, although I would have the key of the map be the reference from the monitor, it's possible to have more than one monitor point to the same pid
from midas.
Thanks for sharing! This is very cool :)
This is the same design that the gleam-experiments/otp_process library currently uses: https://github.com/gleam-experiments/otp_process/blob/02f8ba0b5b3c3c39096ad7117f9a486e6c5281eb/src/gleam/otp/process.gleam#L141
Still needs to be called only once, cannot be enforced.
What is the problem with calling it twice? It could potentially change the mapping function, but I don't see a problem with that? Perhaps I'm missing something.
Option 2
This is not type safe as the msg transformer function could return a type different to that which the process accepts as a message.
Very similar except the mapping function is passed when the monitor is created.
Does this mean the process will hold a map of functions that take pids/ports and return a message? I think we'd need to remove the function from the map once the that down message has been received to prevent a memory leak.
from midas.
I think there is an option 4.
process.spawn_link(fn(receive) {
// continue ...
}, [TrapExit(fn(pid, reason) { Exit(pid, reason) })])
Then if you are not trapping exits you can just put an empty list.
process.spawn_link(fn(receive) {
// continue ...
}, [])
This is much neater than the Error(Nil) as last argument.
Also other process flags and spawn options could be passed in that list.
p.s. this is my new favourite approach
from midas.
That is 100% what the my OTP process module does 😁
(Or did, I'm currently fiddling with it)
from midas.
Looks like it was a while back, but still! I like this design.
from midas.
Related Issues (20)
- Docker HOT 1
- JSON library HOT 2
- DB access HOT 8
- Create a template to start a new midas project HOT 2
- Input Parsing and error handling HOT 4
- Code reloading HOT 1
- Parameterize type of body in Request type HOT 1
- Put midas Dockerfile in this repo
- Routing/Endpoint DSL HOT 2
- Supervisors are give a child spec with a run function rather than a spawn_link function HOT 1
- Cookie based Sessions + CSRF
- Flash messages in cookies
- HTML safe templates
- asset compilation
- Logging HOT 2
- Bug reporting
- Document a way to run "mix task"
- Using midas within a Phoenix project HOT 4
- Add Error handling to template example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from midas.