Tuplanolla 2017-03-03 10:45:58
Can you give a rough estimate for how long `forkIO` takes?
Tuplanolla 2017-03-03 10:48:10
Three orders of magnitude is an acceptable uncertainty.
mauke 2017-03-03 10:49:08
I would imagine it to be super fast
geekosaur 2017-03-03 10:49:28
forkIO does virtually nothing itself except some accounting, so it should be fast
Tuplanolla 2017-03-03 10:51:22
There's a potential race condition when transferring the ownership of a `Handle` to a new thread, so I'd like to add a just-in-case wait to ensure the other thread can register it before unregistering it on the other side.
geekosaur 2017-03-03 10:53:12
you will likely want to use an MVar or similar, I think
monochrom 2017-03-03 10:53:46
Yeah, MVar will do the handshake nicely.
monochrom 2017-03-03 10:54:02
Err, no, not enough.
geekosaur 2017-03-03 10:55:16
forkIO does not actually create or schedule a thread, it creates a "spark" which the runtime will schedule on a thread. you cannot rely on the spark being scheduled on a thread in any timely fashion after forkIO returns; you must use synchronization
monochrom 2017-03-03 10:55:25
Actually, yes enough if you don't mind a time period of "the old owner no longer uses it, the new owner hasn't started using it"
monochrom 2017-03-03 10:56:38
The old owner does a putMVar, then don't use it anymore. The new owner does a takeMVar, then starts using it. putMVar finishes before takeMVar.
geekosaur 2017-03-03 10:56:44
there's also a question of whether having two registrations or zero registrations is considered the error condition (if the error condition is "both" then you need to rethink this)
Tuplanolla 2017-03-03 10:57:44
Then an `MVar` should do.
geekosaur 2017-03-03 10:57:44
uh, s/both/any state other than exactly one/
monochrom 2017-03-03 10:57:48
which is, admittedly, slightly different from the dual-pilot protocol, maybe? "I have control" happens before "you have control".
Tuplanolla 2017-03-03 11:03:31
Well, I just changed a leak to a double free.
monochrom 2017-03-03 11:04:52
haha
monochrom 2017-03-03 11:06:55
Don't just write free software. Write double-free software!
Tuplanolla 2017-03-03 11:09:49
I'll have to trust this "a Handle will be automatically closed when the garbage collector detects that it has become unreferenced by the program" remark.
monochrom 2017-03-03 11:10:47
That sentence can be trusted. But the timing is less predictable.
Tuplanolla 2017-03-03 11:11:04
That's fine for a failsafe.
monochrom 2017-03-03 11:11:20
Also a human's skill of determining whether their code unreferences anything.
voidhorse 2017-03-03 11:23:55
Preferred way to write Haskell? IDE, vim, text editor, stone tablet?
monochrom 2017-03-03 11:24:59
May I lump vim with text editor?
APic 2017-03-03 11:26:20
Emacs.
lyxia 2017-03-03 11:26:24
generated from coq
Tuplanolla 2017-03-03 11:26:32
Correct answer, lyxia.
voidhorse 2017-03-03 11:26:50
Monochrom Yeah, I just wanted to distinguish from a text editor running in the terminal from one with a standalone ui
monochrom 2017-03-03 11:27:46
There are two schools.
monochrom 2017-03-03 11:28:06
One school goes with Leksah, an IDE. It takes some effort to install, and you may or may not like it at the end. If you do, great.
monochrom 2017-03-03 11:28:25
The other school goes with a text editor of a personal choice.
fDev2179 2017-03-03 11:28:53
Vim ftw
voidhorse 2017-03-03 11:28:56
Cool--I tried leksah back two or so years ago--I don't remember liking it too much
monochrom 2017-03-03 11:29:01
Both schools agree that stone tablets are great for thinking and planning. Or whiteboards.
voidhorse 2017-03-03 11:29:59
I guess leksah is probably the closest thing to something like an IntelliJ ide for Haskell --from the looks of it
voidhorse 2017-03-03 11:30:27
Ignoring idea Haskell plugins of course
Rembane 2017-03-03 11:30:37
emacs and the right plugins seems to be a nice experience for many.
dgpratt 2017-03-03 11:31:26
if I'm reading something that discusses a "top" type and a "bottom" type in the context of a type lattice, I suppose that "forall a. a" could be the top type and...Void could be the bottom type? my other thought was maybe "exists a. a"?
lyxia 2017-03-03 11:34:04
I imagine this is about subtyping and something like exists a. a would be at the top, forall a. a at the bottom (isomorphic to Void)
monochrom 2017-03-03 11:37:25
Yeah, forall is at the bottom, exist is at the top.
dgpratt 2017-03-03 11:37:45
ok, thanks
dgpratt 2017-03-03 11:41:50
I suppose that my misapprehension of "forall a. a" has at least something to do with the fact that I usually encounter it in negative position (he said knowing full well he was risking saying something stupid)