Search Haskell Channel Logs

Tuesday, January 31, 2017

#haskell channel featuring mbrock, Liskni_si, luite_, reactormonk, ocharles, acowley,

ocharles 2017-01-31 10:50:47
Hello! Does anyone know why: addFinalizer () (putStrLn "Hello!") >> performGC doesn't print anything?
ocharles 2017-01-31 10:51:54
I guess it's because that "key" () is never actually allocated?
Liskni_si 2017-01-31 10:53:36
or maybe it points to some global () that's not being deallocated yet
luite_ 2017-01-31 10:54:09
yeah CAFs like that are statically allocated and shared a lot
ocharles 2017-01-31 10:56:14
ah, that makes sense
ocharles 2017-01-31 10:56:22
I think this point is the bit I overlooked:
ocharles 2017-01-31 10:56:36
WARNING: weak pointers to ordinary non-primitive Haskell types are particularly fragile, because the compiler is free to optimise away or duplicate the underlying data structure.
ocharles 2017-01-31 10:57:34
I'll try a different approach with weak IORefs
luite_ 2017-01-31 10:57:59
right. yes use something like mkWeakMVar or MkWeakIORef to be safe, they attach the ref to the underlying object
luite_ 2017-01-31 10:58:54
(that's MVar# or MutVar#, the MVar or IORef wrapper may be optimized away)
ocharles 2017-01-31 11:01:54
Yea, I roughly know how those work
reactormonk 2017-01-31 11:03:02
Is there a way to fully qualify a type? https://www.haskell.org/hoogle/?hoogle=URI.ByteString.URIRef+a+-%3E+Request
reactormonk 2017-01-31 11:03:36
Slightly related, if I were to write that function, should I stick it into a new hackage packet?
ocharles 2017-01-31 11:06:55
Slick. I have a little metrics library that if you don't actually use the metrics (they have a "registry" which is a map of name -> metric), they erase their own code to just be no-ops. And it literally works - perform a GC and `weigh` reports incrementing a counter allocates 0 bytes - but if you hold on to the registry it allocates 16 bytes (needed to
ocharles 2017-01-31 11:06:55
increment the underlying Double)
acowley 2017-01-31 11:11:29
ocharles: That's awesome!
ocharles 2017-01-31 11:12:04
acowley: yep! If this really does work, I'll write it up
acowley 2017-01-31 11:15:00
ocharles: I have a couple weak pointer-based resource management libraries that I've started over time but never pushed all the way through. People are understandably wary of promptness when it comes to the GC, but I like the idea of deliberately poking the GC.
ocharles 2017-01-31 11:16:30
Yea, this is pretty non-intrusive I think. You would normally run "buildRegistry", get a registry, and then pass it on to something to serve/push the metrics. But I can just have "discardMetrics" which builds a registry, discards it, and then runs performGC. Now all your instrumentation is a single pointer indirection to a chunk of code that does nothing
ocharles 2017-01-31 11:32:20
https://gist.github.com/ocharles/02df63b3c21648b04662f635a7fb3b74 benchmarks confirm it works :)
ocharles 2017-01-31 11:32:38
https://gist.github.com/ocharles/47b1f1f7dc445b3212f37f3f29557055 is the source
mbrock 2017-01-31 11:38:26
any experiences with or pointers to resources about using QuickCheck for verifying the behaviors of systems with resources that point at other resources with IDs?
mbrock 2017-01-31 11:39:33
that might be vague, but basically, I have a bunch of records containing maps of FooID to Foo, BarID to Bar, and so on -- implicit dependencies that don't seem to fit obviously into the Arbitrary paradigm