Search Haskell Channel Logs

Friday, February 24, 2017

#haskell channel featuring monochrom, wedify, dmwit, nshepperd, erisco, lambdabot, and 6 others.

robertkennedy 2017-02-24 13:49:51
Yesterday we tried to construct a g so `g show 7 True == ["7","True"]` and `g fromIntegral (7 :: Int) (8 :: Integer) == [7,8]`.
wedify 2017-02-24 13:50:01
recursion-ninja: if it does i think you would use -optl
lyxia 2017-02-24 13:50:35
robertkennedy: did you succeed
recursion-ninja 2017-02-24 13:51:08
wedify: could you elaborate on how to use -optl ?
recursion-ninja 2017-02-24 13:51:47
wedify: Would I add -optl as a GHC command line option?
robertkennedy 2017-02-24 13:52:09
We got something like `g f x y = [f x, f y] :: forall c x y b. (c x, c y) => (forall a. c a -> b) -> x -> y -> [b]`
robertkennedy 2017-02-24 13:53:23
Which compiles, but I can't actually input `g show True (7 :: Int)`
erisco 2017-02-24 13:53:31
are you related to Bob Kent?
erisco 2017-02-24 13:54:22
by the identity relation? :P
monochrom 2017-02-24 13:56:47
(forall a. c a -> b)? (forall a. c a => b)
monochrom 2017-02-24 13:57:07
No, neither.
monochrom 2017-02-24 13:57:27
forall a. c a => a -> b
robertkennedy 2017-02-24 13:57:42
Sorry yeah that should be what you put
robertkennedy 2017-02-24 13:57:51
Let me lpaste this
wedify 2017-02-24 14:00:35
recursion-ninja: have you confirmed the existence of the library somewhere? it sounds to me like the debugging version of the rts hasn't been built for some reason
recursion-ninja 2017-02-24 14:02:02
wedify: I have no idea where to look for the library on my system. It very well could be missing. Do you know how to confirm it's existance?
lpaste_ 2017-02-24 14:02:03
robertkennedy pasted "g show True 7 == ["True","7"]" at http://lpaste.net/352952
erisco 2017-02-24 14:03:28
I tried to do it myself and ran into the same "untouchable" thing
wedify 2017-02-24 14:03:28
recursion-ninja: you on a linux system? if so i'd look in '/lib' or '/usr/lib'. on windows and mac i've no idea
wizard1337 2017-02-24 14:03:46
so why am i as the programmer expected to optimize my haskell code,... what prevents the compiler from handling any known form of optimization?
wedify 2017-02-24 14:04:05
wizard1337: undeciablity
recursion-ninja 2017-02-24 14:04:26
wedify: yes, a linux system.
wizard1337 2017-02-24 14:04:46
wedify: can you elaborate?
monochrom 2017-02-24 14:05:27
robertkennedy: It seems the computer is saying it doesn't know that c0=Show will work beautifully.
robertkennedy 2017-02-24 14:05:39
erisco: I've been bumping up on that a lot lately - ever since I started to use the real gadt power
erisco 2017-02-24 14:06:02
robertkennedy, enable TypeApplications and use g @Show show
wedify 2017-02-24 14:06:07
recursion-ninja: on my system the rts stuff is in '/lib/ghc-8.0.1/rts'
robertkennedy 2017-02-24 14:07:27
Ahhah!
robertkennedy 2017-02-24 14:07:41
Weird syntax
erisco 2017-02-24 14:07:53
it seems it won't infer the constraint
erisco 2017-02-24 14:08:01
not sure if that is a bug or oversight or purposefully not a feature
erisco 2017-02-24 14:10:48
not sure what you can do from fromIntegral as you cannot partially apply type synonyms
erisco 2017-02-24 14:10:57
seems to carry over to context synonyms
erisco 2017-02-24 14:11:49
you can define type NumIntegral b a = (Num a, Integral b) but g @(NumIntegral Int) is an error
monochrom 2017-02-24 14:12:07
@type fromIntegral
lambdabot 2017-02-24 14:12:10
(Num b, Integral a) => a -> b
monochrom 2017-02-24 14:12:44
I think it suffices to have @Integral near the beginning, and add :: Int at the end (for b)
erisco 2017-02-24 14:12:44
I have it backwards XD
erisco 2017-02-24 14:12:57
but it doesn't matter because you still cannot partially apply it
erisco 2017-02-24 14:14:21
you're completely right
erisco 2017-02-24 14:14:49
okay, but for any time we need a context with more than one constraint we're stuck
wedify 2017-02-24 14:16:37
wizard1337: it's offtopic so i won't say much but basically to figure out that you need an optimization requires an algorithm and finding algorithms that can run in minutes or seconds is really, really hard
lyxia 2017-02-24 14:19:10
robertkennedy: there's no way to infer which c you mean, because you can always specialize any function to add arbitrary constraints.
erisco 2017-02-24 14:19:41
it can't take the minimal?
lyxia 2017-02-24 14:19:52
robertkennedy: you would need a type on the right of "=>" to carry c
erisco 2017-02-24 14:20:14
it takes the minimal any other time it is inferring which constraints you need
barrucadu 2017-02-24 14:26:27
wizard1337: In general, the problem is truly impossible to solve, this is proven. In specific cases, things can be done. By throwing lots of manpower at the problem, more and more specific cases can be figured out.
monochrom 2017-02-24 14:26:53
"It's only a matter of time."
erisco 2017-02-24 14:28:09
genetically evolve your optimisations
lyxia 2017-02-24 14:28:21
erisco: It might be sound to "just" unify c with Show because it's the only constraint that is there but that rule looks mighty fishy.
erisco 2017-02-24 14:28:47
how many millennia would that take?
monochrom 2017-02-24 14:29:21
If you happen to have written a really slow bubble sort
erisco 2017-02-24 14:29:32
how long until it evolves quicksort :P
monochrom 2017-02-24 14:29:37
It's faster to just wait for it to finish
monochrom 2017-02-24 14:29:54
than to wait for a future compiler to recognize it and replace it with a decent sort.
erisco 2017-02-24 14:33:21
but this is incapable of finding novel optimisations
monochrom 2017-02-24 14:34:12
You don't know that, because I haven't said how it can be done.
monochrom 2017-02-24 14:34:55
But observe that #haskell could collectively do that kind of things, and #haskell cannot really be described as "incapable of finding novel optimizations"
erisco 2017-02-24 14:34:59
"known to humanity"
dmwit 2017-02-24 14:35:49
erisco: I have a constructive proof that there is an algorithm which occasionally spits out novel optimizations. Step one in the proof is to observe that compilers do not have an empty set of optimizations.
dmwit 2017-02-24 14:36:02
Step two is to ask, "where did those optimizations come from?".
robertkennedy 2017-02-24 14:36:53
I've wondered if we couldn't get orders of magnitude speed increases by forking computations optimistically. Like if you do `if x == y then f else g`, it could first compute that `hash x == hash y`, and begin computing f while it waits to confirm
dmwit 2017-02-24 14:36:53
robertkennedy: See `par`
dmwit 2017-02-24 14:37:11
The original paper about it even used the word "optimistic" just like you. =)
erisco 2017-02-24 14:37:30
merely the combination of known optimisations isn't what I'd consider novel
erisco 2017-02-24 14:37:40
no more than a collage is novel
robertkennedy 2017-02-24 14:37:50
Oh tight ty dimwit
monochrom 2017-02-24 14:38:12
I forgot to say that I gave only one minute to my hypothetical optimizer, so it settled for Googling.
dmwit 2017-02-24 14:38:19
erisco: I feel that monochrom and I have utterly failed to communicate with you somehow. But I feel helpless to correct this problem.
nshepperd 2017-02-24 14:38:26
-O15: compiler searches stack overflow for keywords related to the snippet of code to be optimised, filter results for things that can be proven to have same semantics via source-to-source transformation, take the fastest under some microbenchmark
monochrom 2017-02-24 14:38:43
If you give it a year, it will first develop a proof of P=NP, then apply it to PE 498.
erisco 2017-02-24 14:39:30
dmwit, seems so!
monochrom 2017-02-24 14:39:36
Or failing that, it will plagiarize someone else.
erisco 2017-02-24 14:40:16
to me the news will run!
dmwit 2017-02-24 14:40:16
erisco: I wonder: do you believe there is an algorithm that could act exactly as you do when put in the same situation?
erisco 2017-02-24 14:41:19
dmwit, well then the optimiser is far more elaborate than 'the optimizer simply sees "oh it's PE 498" and substitute the fastest solution known to humanity'
erisco 2017-02-24 14:41:44
so I failed to receive the intended generality of this optimiser
robertkennedy 2017-02-24 14:41:56
dmwit: I can't seem to find that paper, do you remember the author?