ertes 2017-02-23 22:49:09
how can i "touch" a value without actually evaluating it? i just want to tell GC that i still need that value
ertes 2017-02-23 22:49:19
(needing IO is ok)
alexbiehl 2017-02-23 22:50:35
ertes: Try Control.Monad.Primitive.touch
alexbiehl 2017-02-23 22:50:41
But why would you want that?
ertes 2017-02-23 22:50:48
background: i need this in an unsafePerformIO-block that would otherwise let-float to the top-level
ertes 2017-02-23 22:52:17
yeah, touch/touch# seem to do it, although i would feel safer if they were actually documented =)
ertes 2017-02-23 22:52:20
thank you
ertes 2017-02-23 22:53:15
i could just use (const action x), but then GHC will likely optimise the dependency on x away
ertes 2017-02-23 22:57:48
actually… is there a variant of 'touch' that doesn't even prevent GC? i really just need to *refer* to the value somehow in order to prevent let-floating
MarcelineVQ 2017-02-23 23:04:44
ertes: is inline at all appropriate? I've never used it
MarcelineVQ 2017-02-23 23:04:59
specifically http://hackage.haskell.org/package/base-4.9.1.0/docs/GHC-Exts.html#v:inline
ertes 2017-02-23 23:07:34
MarcelineVQ: not sure how to use it for this purpose
ertes 2017-02-23 23:08:11
nevermind, i've enabled -fno-full-laziness
ertes 2017-02-23 23:08:38
would have preferred not to do that though
MarcelineVQ 2017-02-23 23:13:15
let floating is an echoing arcane mutter that dredges up images of oily vines obscured in a quaking and somehow ribald shadow, grasping, grasping, or something, ghc source has some interested leads on it when searching the word 'prevent' though
MarcelineVQ 2017-02-23 23:16:50
reallyUnsafePtrEquality# for example mentions that it must not be floated, and seems to use a flag called can_fail to do so, so it'd be interesting if there was one whos only purpose was to apply that tag to something else. appearantly can_fail and has_side_effects on primops both prevent let from floating out, though not from in
MarcelineVQ 2017-02-23 23:18:15
though there's probably a really simple language trick somewhere to accomplish this
ertes 2017-02-23 23:31:36
MarcelineVQ: there is also the "i really don't want to research this right now" trick: -fno-full-laziness =)
MarcelineVQ 2017-02-23 23:32:36
looks like touch does what that line of thinking would do anyway
MarcelineVQ 2017-02-23 23:34:36
:>
bennofs1 2017-02-23 23:36:15
ertes: how about putting your code into a no-inline Int -> IO () function and calling that function with some constant?
bennofs1 2017-02-23 23:36:40
oh, that problably means the whole expression `f constant` can be lifted out though..
bpa2 2017-02-23 23:37:06
I am knew to #haskell and do not know what is meant to happen? Can somebody explain?!?!
bennofs1 2017-02-23 23:37:36
bpa2: what do you need help with?
bpa2 2017-02-23 23:37:43
Haha now I see my own post!!
bpa2 2017-02-23 23:39:01
Thank you bennofs I will get back when I have formulated my question. This was just an experimental run....