Search Haskell Channel Logs

Wednesday, March 8, 2017

#haskell channel featuring lyxia, kuribas, cocreature, Itkovian, dolio, jle`, and 7 others.

kuribas 2017-03-08 09:50:21
How do I force return () to be evaluated every time in "trace errStr (return ())"?
monochrom 2017-03-08 09:53:28
That "return()" is evaluated iff the whole "trace errStr (return())" is evaluated.
ski 2017-03-08 09:53:28
perhaps you want `errStr' outputted whenever this action is *executed* (not evaluated) ?
kuribas 2017-03-08 09:55:05
ski: yes
kuribas 2017-03-08 09:56:13
ski: it's not IO though, it's a State monad.
ski 2017-03-08 09:56:56
`State MyStateType' ?
kuribas 2017-03-08 09:56:56
yes
monochrom 2017-03-08 09:56:56
My iff sentence is still true for s/evaluate/execute/
kuribas 2017-03-08 09:56:56
:t unsafePerformIO
lambdabot 2017-03-08 09:56:56
error: Variable not in scope: unsafePerformIO
ski 2017-03-08 09:58:09
@type evaluate
lambdabot 2017-03-08 09:58:12
a -> IO a
ski 2017-03-08 09:59:41
(but presumably the difference doesn't make any difference in your case, in which case what monochrom said)
kuribas 2017-03-08 10:00:45
or maybe const (return ()) var, where var is a variable in the monad?
ski 2017-03-08 10:01:40
whatever `var' is, that is equal to just `return ()'
ski 2017-03-08 10:01:46
(not sure what you mean by "a variable in the monad")
monochrom 2017-03-08 10:01:56
That "return()" is evaluated iff the whole "const (return()) var" is evaluated. Similarly, executed.
kuribas 2017-03-08 10:02:23
ski: A variable that is only evaluated when the monad is executed.
monochrom 2017-03-08 10:02:35
Also, the var is ignored in all 4 cases.
ski 2017-03-08 10:02:48
monads are not run-time things, that can be executed or not
ski 2017-03-08 10:02:56
monadic actions can be executed, though
ski 2017-03-08 10:03:33
`var' is not evaluated when `const (return ()) var' is evaluated
kuribas 2017-03-08 10:04:16
ski: I don't care about var.
kuribas 2017-03-08 10:05:04
or "trace (const msg var) (return ())"?
ski 2017-03-08 10:05:13
i'm not sure why you mentioned `const' ..
kuribas 2017-03-08 10:06:35
I want to trick ghc into evaluating it...
kuribas 2017-03-08 10:07:30
Doesn't work if it inlines it to msg...
ski 2017-03-08 10:09:18
`const msg var' won't evaluate `var', regardless of inlining or not
kuribas 2017-03-08 10:09:56
ski: but it may evaluate the expression if var has changed...
monochrom 2017-03-08 10:11:49
No, const tricks GHC into not evaluating things.
kuribas 2017-03-08 10:12:07
ski: if const where a black box, it would try to evaluate it.
monochrom 2017-03-08 10:12:12
Why are you not talking about seq which does trick GHC into evaluating things?
kuribas 2017-03-08 10:12:58
monochrom: var `seq` trace msg (return ())?
monochrom 2017-03-08 10:13:05
var does not change, and const is not a black box.
monochrom 2017-03-08 10:13:16
I'm going to be blunt and ask "what are you smoking?"
monochrom 2017-03-08 10:13:47
That will evaluate var iff the whole thing is evaluated.
lyxia 2017-03-08 10:14:10
Show some code!
ski 2017-03-08 10:15:43
kuribas : even if `const' was in a library that was only loaded at run-time, `var' would still not be evaluated in `const (return ()) var'
kuribas 2017-03-08 10:16:51
ski: I only want the trace...
kuribas 2017-03-08 10:16:55
ski: ghc would try evaluating it, because it doesn't know var doesn't get evaluated.
lyxia 2017-03-08 10:17:27
kuribas: trace is already marked NOINLINE so it won't do funny things with inlining.
ski 2017-03-08 10:19:15
kuribas : no, it would not
Aruro 2017-03-08 10:20:09
is lense-like library should be part of haskell syntax?
kuribas 2017-03-08 10:20:09
lyxia: this is just a part of my code: http://lpaste.net/353329
ski 2017-03-08 10:20:37
unless we're talking about speculative evaluation of some sort, the traditional way to implement non-strict semantics is to *not* have argument expressions reduced before calling the function. instead the body of the function (or perhaps even what the caller decides to do with the result of the function) will determine when and if the arguments are reduced
dolio 2017-03-08 10:21:45
Note: GHC doesn't do speculative evaluation. :)
monochrom 2017-03-08 10:22:05
Yes, the evaluator expands the function body first. If the body doesn't mention a parameter, that parameter is ignored afterall.
monochrom 2017-03-08 10:22:08
This is why const is not going to be a black box like you think some imported C function is.
monochrom 2017-03-08 10:22:22
The evaluator will look inside.
ski 2017-03-08 10:23:00
in a sense, `const' is (or could as well be) "black-box", but it would still not have the operational semantics you were thinking
kuribas 2017-03-08 10:23:45
ski: const msg var, isn't a constant expression, when var is free...
kuribas 2017-03-08 10:23:54
ski: only after inlining.
monochrom 2017-03-08 10:24:31
This is not about inlining.
kuribas 2017-03-08 10:24:40
if const were a black box function, the evalutor wouldn't know it is constant.
kuribas 2017-03-08 10:24:51
So it would have to evaluate it.
ski 2017-03-08 10:25:08
no
ski 2017-03-08 10:25:21
it passes `msg' and `var', *unevaluated*, to `const'
monochrom 2017-03-08 10:25:27
There are many experiments you can perform to refute that hypothesis.
ski 2017-03-08 10:25:31
`const' then decides which of the arguments to evaluate
kuribas 2017-03-08 10:25:55
ski: now you are admitting it will evaluate const?
ski 2017-03-08 10:26:24
`const' itself (whose value is a function) will be evaluated, since it's the function expression in a function call
monochrom 2017-03-08 10:26:28
We have always asserted that "const" is evaluated. First.
monochrom 2017-03-08 10:26:44
Does not imply that the 2nd parameter will be evaluated. Ever.
kuribas 2017-03-08 10:27:14
monochrom: I don't care about the 2nd parameter...
ski 2017-03-08 10:27:17
`const' must be evaluated in order to determine the function body (with actual parameter expressions substituted for formal parameters) to continue evaluation at
monochrom 2017-03-08 10:27:22
You can define your own const-like function and turn off optimization and what-not. Everything we said will still hold.
monochrom 2017-03-08 10:27:49
OK, what do you care?
kuribas 2017-03-08 10:28:04
monochrom: that the debug trace gets outputted.
monochrom 2017-03-08 10:28:19
OK, it works for me. What's the problem?
ski 2017-03-08 10:28:41
(if `DEBUG' isn't defined, then `debug' is equal to `flip const', however)
kuribas 2017-03-08 10:28:56
monochrom: well, const get inlined, so it isn't a black box...
ski 2017-03-08 10:29:14
even if it doesn't get inlined, it will still behave exactly the same
monochrom 2017-03-08 10:29:22
I don't see the relevance.
kuribas 2017-03-08 10:29:30
ok, I'll try...
ski 2017-03-08 10:29:37
`const msg (error "boom !")' won't evaluate the `error' call, e.g.
monochrom 2017-03-08 10:32:23
You have an experiment I can reproduce to unambiguously refute what I said?
kuribas 2017-03-08 10:37:06
monochrom: right, I tested it. With (const msg freshVar), I see the trace, without only once.
kuribas 2017-03-08 10:37:06
monochrom: how would ghc now it cannot subsitute that with msg?
nilof 2017-03-08 10:37:06
Ah, you can't have several modules in the same file?
kuribas 2017-03-08 10:37:26
monochrom: does it know there is an trace or unsafePerformIO function?
Tuplanolla 2017-03-08 10:37:53
Your thought process is really difficult to follow, kuribas.
jle` 2017-03-08 10:38:24
nilof: correct
kuribas 2017-03-08 10:38:58
Tuplanolla: well, if I have 'debugM "mesg"', I see the trace only once. If I use 'debugM (const "msg" freshvar)', I see it every time it is executed.
kuribas 2017-03-08 10:39:16
Tuplanolla: what keeps ghc from inlining const, and rewriting the second into the first?
Tuplanolla 2017-03-08 10:40:03
Is this from `hslogger`?
Sh4pe 2017-03-08 10:40:09
Hi folks! Quick question: I import Data.ByteString.Char8 as C. Then, the statement `newtype Foo = C.ByteString` causes this error: `Qualified name in binding position: C.ByteString`. I don't understand why and I can't find a fix myself
lyxia 2017-03-08 10:40:24
this would be so much easier if we had a minimal example.
cocreature 2017-03-08 10:40:29
Sh4pe: you need to give a name to the constructor of your newtype
cocreature 2017-03-08 10:40:37
"newtype Foo = Foo C.ByteString" will work
Sh4pe 2017-03-08 10:41:04
cocreature: Ah - I see. Thanks!
kuribas 2017-03-08 10:41:31
Tuplanolla: no...
monochrom 2017-03-08 10:42:34
kuribas, I still do not know how to reproduce your experiment. How do I reproduce your experiment?
monochrom 2017-03-08 10:43:04
Hell, how do I do so with little effort? (Too lazy to even "stack install stuff")
kuribas 2017-03-08 10:43:59
> traverse_ [1..4] $ \i -> trace "debug message" $ return ()
lambdabot 2017-03-08 10:44:02
error:
lambdabot 2017-03-08 10:44:02
• Couldn't match expected type 'a0 -> f b0'
lambdabot 2017-03-08 10:44:03
with actual type '[Integer]'
Itkovian 2017-03-08 10:44:23
any idea why stack --compiler ghc-8.0.2 --stack-root=/usr/local/vpw/haskell/stack --extra-lib-dirs /usr/local/vpw/lib/ install split fails with a symbol from libgmp not foudn (which resides in /usr/local/vpw/lib/libgmp.a)
Itkovian 2017-03-08 10:44:35
it seems like the extra lib is not passed to ghc