ph88 2017-01-27 06:48:57
looks like it will land in 8.0.2 i was testing with 8.0.1
Kristof_HT 2017-01-27 06:49:39
what was the name of haskell channwl for beginners?
ph88 2017-01-27 06:49:50
#haskell-beginners
EvanR 2017-01-27 06:49:51
#haskell
Kristof_HT 2017-01-27 06:49:59
thank you
EvanR 2017-01-27 06:50:00
or that
ph88 2017-01-27 06:50:51
so 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 ?
srhb 2017-01-27 06:52:02
Kristof_HT: Plainly, the topics are often advanced in #haskell-beginners and not in #haskell -- and vice versa. You're free to ask any Haskell question in either location. Having more channels is great if there's a lot of traffic in one or the other, though. :-)
EvanR 2017-01-27 06:52:42
this channel seems very beginner friendly
Kristof_HT 2017-01-27 06:58:20
yes I did notice this channel to be friendly, and haskell people in general are very helpful
fragamus 2017-01-27 06:58:50
is there a good way to escape a file path for bash
fragamus 2017-01-27 06:59:41
i am forced to generate a bash command and send it to the interpeter
Liskni_si 2017-01-27 07:06:44
fragamus: not sure if there's a library for that but I'd consider using something like this: readProcess "/bin/bash" ["-c", "builtin printf %q \"$1\"", "--", "test$"] ""
Liskni_si 2017-01-27 07:06:55
(that's System.Process.readProcess)
fragamus 2017-01-27 07:07:07
I have filenames with special characters in them
fragamus 2017-01-27 07:07:29
I need to escape them
Liskni_si 2017-01-27 07:08:29
yeah, I know
Liskni_si 2017-01-27 07:08:33
let escape x = readProcess "/bin/bash" ["-c", "builtin printf %q \"$1\"", "--", x] ""
Liskni_si 2017-01-27 07:08:37
Prelude System.Process> escape "blah`rm -rf /` $(FOO)"
Liskni_si 2017-01-27 07:08:37
"blah\\`rm\\ -rf\\ /\\`\\ \\$\\(FOO\\)"
Liskni_si 2017-01-27 07:09:16
but there _may_ be better options than this :-)
fragamus 2017-01-27 07:10:17
oh wow
dgpratt 2017-01-27 07:10:42
is the Default typeclass among those that can be automatically derived?
cocreature 2017-01-27 07:11:37
dgpratt: no, it is also not clear what it should derive. if you have something like "data X = A | B" A and B are both valid choices for a default value
dgpratt 2017-01-27 07:11:52
makes sense, thanks cocreature
Liskni_si 2017-01-27 07:13:04
fragamus: this works too: let escape x = readProcess "/usr/bin/printf" ["%q", x] "", but it uses a different escaping algorithm apparently, so if you know you'll be feeding it into bash, the builtin printf may be better
fragamus 2017-01-27 07:14:46
escape "proj #3" fails to escape that pesky pound sign
Liskni_si 2017-01-27 07:16:46
does it?
fragamus 2017-01-27 07:16:57
yes
Liskni_si 2017-01-27 07:17:04
$ echo proj\ #3
Liskni_si 2017-01-27 07:17:04
proj #3
fragamus 2017-01-27 07:17:43
the space is escaped but the pound sign is not
Liskni_si 2017-01-27 07:17:55
yes but it doesn't need to be as you can see
Liskni_si 2017-01-27 07:18:12
it does escape it if it's at the beginning of the string
Liskni_si 2017-01-27 07:18:20
it's more clever than I thought :-)
fragamus 2017-01-27 07:20:12
this worked: touch 'proj\\ #3'
fragamus 2017-01-27 07:20:26
it didnt work until i placed the single quotes
Liskni_si 2017-01-27 07:21:01
do note that if you just type escape "" something in ghci, it prints it via the Show String instance
Liskni_si 2017-01-27 07:21:10
that is, escaped again for Haskell
Liskni_si 2017-01-27 07:21:26
if you want to copypaste into bash, escape "something" >>= putStrLn
sam__ 2017-01-27 07:21:39
hey does anybody know if I can use the FFI without depending on base? I really want to use C and make my own "base"
Kristof_HT 2017-01-27 07:21:53
ok... anybody cares to explain or point me to a resource to read, about why [0, 0.3 .. 1.5] does NOT result in [0, 0.3, 0.6, 0.9, 1.2, 1.5]
Liskni_si 2017-01-27 07:22:35
Kristof_HT: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
Liskni_si 2017-01-27 07:23:11
Kristof_HT: short answer, 0.3 isn't representable in base-2
Kristof_HT 2017-01-27 07:27:39
yes, this a good answer, I should have asked more precise question: why in haskell 0.3 * 4 will provide 1.2 while [0, 0.3 .. 0.9] will result in [0.0,0.3,0.6,0.8999999999999999]
Kristof_HT 2017-01-27 07:28:30
aka how patter matching will give different result than simple multiplication operator on same numbers
Tuplanolla 2017-01-27 07:28:53
@hoogle enumFromTo
lambdabot 2017-01-27 07:28:56
Prelude enumFromTo :: Enum a => a -> a -> [a]
lambdabot 2017-01-27 07:28:56
Data.Vector enumFromTo :: Enum a => a -> a -> Vector a
lambdabot 2017-01-27 07:28:56
Data.Vector.Fusion.Bundle enumFromTo :: Enum a => a -> a -> Bundle v a
Tuplanolla 2017-01-27 07:29:02
It uses that function, Kristof_HT.
Kristof_HT 2017-01-27 07:29:33
thank you !
Cale 2017-01-27 07:30:32
Kristof_HT: wait, what?
Cale 2017-01-27 07:30:54
> [0, 0.3 .. 1.3]
lambdabot 2017-01-27 07:30:56
[0.0,0.3,0.6,0.8999999999999999,1.1999999999999997]
Tuplanolla 2017-01-27 07:31:09
Business as usual.
pavonia 2017-01-27 07:31:12
> 0.3*4
Cale 2017-01-27 07:31:12
Are you asking why that's 1.1999999999999997 and not 1.2?
lambdabot 2017-01-27 07:31:15
1.2
dmwit 2017-01-27 07:31:24
Kristof_HT: I'm confused. Why would `0.3 * 4 = 1.2` and `[0, 0.3 .. 0.9] = [0.0,0.3,0.6,0.8999999999]` be in conflict?
pavonia 2017-01-27 07:31:48
> 0.3+0.3+0.3+0.3
lambdabot 2017-01-27 07:31:51
1.2
Liskni_si 2017-01-27 07:33:20
now I'm confused too, last [0, 0.3 .. 1.2] is 1.1999999999999997, but 0.3+0.3+0.3+0.3 is 1.2 :-D
Tuplanolla 2017-01-27 07:33:38
> printf "%.32f" (0.0 + 0.3 + 0.3 + 0.3 + 0.3 :: Double) :: String
lambdabot 2017-01-27 07:33:41
"1.20000000000000000000000000000000"
Tuplanolla 2017-01-27 07:33:50
Well, then...
Kristof_HT 2017-01-27 07:34:31
dmwit - i wouldn't say they are in conflict, was just surprised to see different result, and was wondering how pattern matching is handling floats under the hood
eschnett 2017-01-27 07:35:47
I think Julia uses a special mechanism for float ranges that ensures that the last value is obtained exactly, but very slightly modifying the step sizes
dmwit 2017-01-27 07:36:13
Kristof_HT: But what is different about the two results? They don't appear to overlap at all.
dmwit 2017-01-27 07:36:24
Kristof_HT: (Also, a minor terminology note: there's no pattern matching happening here.)
dmwit 2017-01-27 07:37:12
Liskni_si: FWIW, I too find that odd.
Cale 2017-01-27 07:38:36
> let myEnumFromThen n m = n `seq` m `seq` (n : myEnumFromThen m (m+m-n)) in myEnumFromThen 0 0.3
lambdabot 2017-01-27 07:38:38
[0.0,0.3,0.6,0.8999999999999999,1.1999999999999997,1.4999999999999996,1.7999...
Cale 2017-01-27 07:39:03
> let myEnumFromThen n m = n `seq` m `seq` (n : myEnumFromThen m (m+m-n)) in myEnumFromThen x y
lambdabot 2017-01-27 07:39:07
[x,y,y + y - x,y + y - x + (y + y - x) - y,y + y - x + (y + y - x) - y + (y ...
Cale 2017-01-27 07:39:17
> let myEnumFromThen n m = n `seq` m `seq` (n : myEnumFromThen m (m+m-n)) in myEnumFromThen x y !! 4
lambdabot 2017-01-27 07:39:20
y + y - x + (y + y - x) - y + (y + y - x + (y + y - x) - y) - (y + y - x)
fragamus 2017-01-27 07:39:24
Liskni_si thanks
Cale 2017-01-27 07:39:44
> let { x = 0; y = 0.3 } in y + y - x + (y + y - x) - y + (y + y - x + (y + y - x) - y) - (y + y - x)
lambdabot 2017-01-27 07:39:46
1.1999999999999997
Cale 2017-01-27 07:39:51
^^ that's why
Kristof_HT 2017-01-27 07:39:59
dmwit i really don't know what do you mean when you say they don't overlap
Cale 2017-01-27 07:41:08
Kristof_HT: One of the results was a list which didn't contain anything near 1.2 (and ought not to), and the other was 1.2
Cale 2017-01-27 07:41:57
Kristof_HT: You set the upper bound on the list too low if you wanted to see something like 1.2 in there
Cale 2017-01-27 07:43:16
The specified upper bound will always be less than or equal to half a step distance from the element that the list stops on (which is itself kind of a strange specification, but that's what it is)
dmwit 2017-01-27 07:44:55
Cale: Thanks for the explanation of why we don't get 1.2, that's very interesting. But isn't that in conflict with the Report? "The sequence enumFromThenTo e1 e2 e3 is the list [e1,e1 + i,e1 + 2i,…e3], where the increment, i, is e2 − e1." appears to require you to compute the interval just once, not re-compute it on every step, and then use multiplication.