dmwit 2017-01-27 07:45:47
> let reportEnumFromThen e1 e2 = [e1 + i*(e2-e1) | i <- [0..]] in reportEnumFromThen 0 0.3
lambdabot 2017-01-27 07:45:49
[0.0,0.3,0.6,0.8999999999999999,1.2,1.5,1.7999999999999998,2.1,2.4,2.6999999...
Kristof_HT 2017-01-27 07:46:22
thanks for everyobdy, you guys don't realize how great it is to see meaningful discussion even on such simple example (as opposed to what i would expect on channels for most other programming languages)
dmwit 2017-01-27 07:47:32
> let reportEnumFromThen e1 e2 = let i = e2 - e1; go n = e1 + n*i : go (n+1) in go 0 in reportEnumFromThen 0 0.3 -- even stricter reading, and don't recurse on enumFromThen at another type
lambdabot 2017-01-27 07:47:35
[0.0,0.3,0.6,0.8999999999999999,1.2,1.5,1.7999999999999998,2.1,2.4,2.6999999...
Liskni_si 2017-01-27 07:52:14
I wonder why it's defined in such a way
Liskni_si 2017-01-27 07:52:49
sum (replicate n 0.3) is consistently closer to the right answer than head (drop n [0, 0.3 ..]) :-)
bennofs1 2017-01-27 07:54:02
Is there a stack command to execute and executable from the project, recompiling before if needed?
Liskni_si 2017-01-27 07:56:22
bennofs1: stack exec --package "the package you're in" -- foo seems to work
Liskni_si 2017-01-27 07:56:35
whether it's the intended usage, I'm not at all sure
bennofs1 2017-01-27 07:57:42
Liskni_si: does that first recompile the package if any files changed?
bennofs1 2017-01-27 07:57:59
ah ok, --package seems to do that, thx
Liskni_si 2017-01-27 07:58:02
bennofs1: stack 1.3.2 does in the one case I tried
Liskni_si 2017-01-27 07:58:17
but I really do think it's a hack :-)
Tuplanolla 2017-01-27 08:05:16
The first mistake would be to consider floating-point numbers simple, Kristof_HT.
monochrom 2017-01-27 08:07:01
"simple" is relative, too.
monochrom 2017-01-27 08:07:32
actually make it s/relative/subjective/
Kristof_HT 2017-01-27 08:10:00
dmwit and Cale - oh so the question was why I provided examples of which one's upper bound wasn't set to go as high as 1.2, that's why dmwit said they don't overlap, - i got it now - well you are right I might have chosen better examples nut the point was that multiplication of 0.3 * n will give you rounded number (0.9, 1.2, 1.5) and [0,0,3..n] gives you 0.8999999999999999 and so on
Kristof_HT 2017-01-27 08:10:11
but through all the replies now I do understand it better
monochrom 2017-01-27 08:11:49
> 0.3 * 3
lambdabot 2017-01-27 08:11:52
0.8999999999999999
monochrom 2017-01-27 08:11:55
eh?!
glguy 2017-01-27 08:13:22
> 0.3 * 3 :: CReal -- there we go
lambdabot 2017-01-27 08:13:25
0.9
Liskni_si 2017-01-27 08:19:56
I need to remember to never use floating point arithmetic ever again in my life :-)
Liskni_si 2017-01-27 08:20:16
(still don't understand why enumFromThen is defined as it is)
Kristof_HT 2017-01-27 08:20:28
I'm glad I'm catching those things early
dmwit 2017-01-27 08:20:43
Liskni_si: I'm tempted to say the current implementation of `enumFromThen` is buggy.
dmwit 2017-01-27 08:21:28
Since the way it's implemented, you get compounding rounding errors not just from repeated additions but also from repeatedly recalculating the interval.
dmwit 2017-01-27 08:22:34
> let enumFromThenSingleInterval e1 e2 = iterate ((e2-e1)+) e1 in enumFromThenSingleInterval 0 0.3
lambdabot 2017-01-27 08:22:36
[0.0,0.3,0.6,0.8999999999999999,1.2,1.5,1.8,2.1,2.4,2.6999999999999997,2.999...
Liskni_si 2017-01-27 08:22:51
https://github.com/ghc/packages-base/commit/e007a7cad7f402caaedacf1933e38b55d744ac4b
dmwit 2017-01-27 08:22:52
Probably still worse than what the Report says to do, but at least you get 1.2...
Liskni_si 2017-01-27 08:22:55
this seems to be the offending commit
monochrom 2017-01-27 08:23:44
I think "never use floating point" is too extreme. May as well never use computers.
monochrom 2017-01-27 08:24:09
However, "never be ignorant, never assume" is exactly right.
Tuplanolla 2017-01-27 08:24:24
My rule of thumb is to use floating-point whenever an analog signal would do.
dmwit 2017-01-27 08:24:30
"never be ignorant" is not actionable advice.
dmwit 2017-01-27 08:24:41
Human brains aren't big enough.
glguy 2017-01-27 08:24:47
dmwit: You don't even know
monochrom 2017-01-27 08:25:02
Oh "never" is never actionable. May the odds be never in your favour!
Liskni_si 2017-01-27 08:25:20
yeah, never again was a hyperbole :-)
monochrom 2017-01-27 08:26:16
But I guess I just needed "never assume".
nitrix 2017-01-27 08:26:25
Hi.
nitrix 2017-01-27 08:26:45
I have a stack.yaml for my executable requiring a local library which also has its own stack.yaml.
nitrix 2017-01-27 08:27:13
For some reason, the extra-deps of that local library doesn't seem to carry over to my executable and I'd have to duplicate them.
nitrix 2017-01-27 08:27:43
That seems a little dubious to me that these nested dependencies aren't figured out automagically, so I'm asking.
dgpratt 2017-01-27 08:29:15
where can I see a list of the predefined lenses in the ubiquitous lens library?
glguy 2017-01-27 08:29:40
?hackage lens
lambdabot 2017-01-27 08:29:40
http://hackage.haskell.org/package/lens
monochrom 2017-01-27 08:29:51
The docs, yeah. :)
arbitraria 2017-01-27 08:30:00
hello all, I am trying to [x++(chr y) | x <- ['P','B','C'], y <- [1..10]] and it doesn't work (also tried replacing chr with show), could someone maybe point me in the right direction?
Liskni_si 2017-01-27 08:30:13
nitrix: stack files aren't meant to nest, it's just your stack.yaml and a bunch of cabal packages
monochrom 2017-01-27 08:30:17
Unless you say "no no no I want them all in one single ebook"
glguy 2017-01-27 08:30:28
arbitraria: chr y isn't a list, so you can't ++ it
nitrix 2017-01-27 08:30:32
Liskni_si: Here's an example...
nitrix 2017-01-27 08:30:34
Liskni_si: https://github.com/z0w0/helm/blob/master/stack.yaml
nitrix 2017-01-27 08:30:47
Liskni_si: Someone using helm would have to list these three external dependencies themselves?
glguy 2017-01-27 08:30:48
arbitraria: 'P' isn't a list, either
glguy 2017-01-27 08:30:58
> ['P',chr 97]
lambdabot 2017-01-27 08:31:00
"Pa"
Cale 2017-01-27 08:31:15
Kristof_HT: btw, this isn't just a Haskell thing, this is just how floating point arithmetic works (and almost all languages provide floating point numbers because CPUs support them). You generally have to be wary about treating any floating point number as an exact quantity, there's always going to be some tolerance for error.
Liskni_si 2017-01-27 08:31:29
nitrix: yes
ph88 2017-01-27 08:31:40
i have this piece of code https://paste.fedoraproject.org/537782/48553613/ and i intended f on line 30 to be the same f as on line 10, but ghc is not having it. What am i doing wrong ?
Cale 2017-01-27 08:31:54
Kristof_HT: Of course, you can format the numbers to display in a prettier way, by rounding them even more :)
Cale 2017-01-27 08:32:06
> showFFloat (Just 2) pi ""
Liskni_si 2017-01-27 08:32:08
nitrix: normally you'd hope that helm and all its dependencies would be in stackage lts, but if they're not, you're expected to specify all that yourself as extra-deps
lambdabot 2017-01-27 08:32:10
"3.14"
arbitraria 2017-01-27 08:32:13
thank you! glguy
Cale 2017-01-27 08:32:26
> showFFloat (Just 2) 0.8999999999999999 ""
nitrix 2017-01-27 08:32:27
lambdabot: That isn't my question.
lambdabot 2017-01-27 08:32:29
"0.90"
nitrix 2017-01-27 08:32:36
Liskni_si: That isn't my question.
monochrom 2017-01-27 08:33:11
ph88: I see no "f" on line 10
nitrix 2017-01-27 08:33:33
Liskni_si: Again, my executable has a local dependency, which is listed in the stack.yaml file. That dependency, has dependencies of its own.
nitrix 2017-01-27 08:33:52
Liskni_si: Someone, my executable has to list the dependencies of that dependency, for it to work. And that doesn't feel right.
Liskni_si 2017-01-27 08:35:17
nitrix: Doesn't feel right, but it is indeed as designed. stack works with "curated" sets of packages, the stackage lts. If some dependency is in the lts, you don't need to list it. If it's just on hackage, you do. And that's it.
Liskni_si 2017-01-27 08:35:51
nitrix: And the dependency's stack.yaml file isn't considered at all.
Liskni_si 2017-01-27 08:36:11
Arguably it shouldn't even be there. :-)
monochrom 2017-01-27 08:36:27
In fact I see no reason to give "get" the type annotation "get :: f Exponent". The do-block already determines f, and the pattern "Exp ex" already determines Exponent. The only meta-explanation is that the author has an XY problem.
nitrix 2017-01-27 08:36:37
Liskni_si: You're answering something completely different to what I'm asking, but fear not, I found my issue.
monochrom 2017-01-27 08:37:26
I have a tale to tell about this, too! :)
monochrom 2017-01-27 08:38:20
I was in #math waiting for homework questions, and someone asked one: "x+1/y-2 ..." something. So I said, "add more parentheses".
monochrom 2017-01-27 08:38:46
The asker went on to clarify it as "(x)+1/(y)-2"
Cale 2017-01-27 08:39:06
monochrom: lol
Cale 2017-01-27 08:39:19
such helpful clarifications
Liskni_si 2017-01-27 08:39:36
nitrix: I really don't think I'm answering something different. You don't have to list your dependency's dependencies in the cabal/hpack file. You _might_ have to list your dependency's dependencies in stack.yaml and here I am telling you why.
monochrom 2017-01-27 08:40:08
I do not remember the exact expression, so I am paraphrasing now, to be fair. The real instance might be something less extreme, like "(2x)+1/y-2"
monochrom 2017-01-27 08:40:50
Still, people always clarify the part that needs the least clarification.
ph88 2017-01-27 08:41:37
monochrom, eh sorry i meant line 20 :/
monochrom 2017-01-27 08:42:03
Then you need ScopedTypeVariables and a few forall's.
ph88 2017-01-27 08:42:42
monochrom, the forall needs to be explicit ?
monochrom 2017-01-27 08:42:44
Or maybe no need for forall's. Read the GHC User Guide on how to use ScopedTypeVariables together with instance code.
nitrix 2017-01-27 08:42:48
Liskni_si: That makes no sense to me. Why would my executable need to explicitly list the dependencies of all my dependencies?
nitrix 2017-01-27 08:43:05
Liskni_si: I'm pushing code.
ph88 2017-01-27 08:43:14
monochrom, ok, i already have ScopedTypeVariables enabled though ^^
monochrom 2017-01-27 08:43:29
Call the GHC User's Guide. Call now.
monochrom 2017-01-27 08:43:46
Also like I said, I suspect XY problems.
nitrix 2017-01-27 08:44:22
Liskni_si: https://github.com/nitrix/lspace/blob/develop/stack.yaml
nitrix 2017-01-27 08:44:24
Liskni_si: https://github.com/nitrix/lspace/blob/develop/kawaii/stack.yaml
monochrom 2017-01-27 08:44:33
"(Exp ex) <- get :: f Exponent" cannot possibly be a type-clarifying annotation, let alone type-correcting.
nitrix 2017-01-27 08:44:48
Liskni_si: As you can see, the executable ends up listing very specific versions of the dependencies of that `kawaii` dependency.
Kristof_HT 2017-01-27 08:45:07
thank you all, back to work now, o7